Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ValidatorCacheWarmer example
public
function
testWarmUp
(
)
{
$validatorBuilder
=
new
ValidatorBuilder
(
)
;
$validatorBuilder
->
addXmlMapping
(
__DIR__.'/../Fixtures/Validation/Resources/person.xml'
)
;
$validatorBuilder
->
addYamlMapping
(
__DIR__.'/../Fixtures/Validation/Resources/author.yml'
)
;
$validatorBuilder
->
addMethodMapping
(
'loadValidatorMetadata'
)
;
$validatorBuilder
->
enableAttributeMapping
(
)
;
$file
=
sys_get_temp_dir
(
)
.'/cache-validator.php';
@
unlink
(
$file
)
;
$warmer
=
new
ValidatorCacheWarmer
(
$validatorBuilder
,
$file
)
;
$warmer
->
warmUp
(
\
dirname
(
$file
)
)
;
$this
->
assertFileExists
(
$file
)
;
$arrayPool
=
new
PhpArrayAdapter
(
$file
,
new
NullAdapter
(
)
)
;
$this
->
assertTrue
(
$arrayPool
->
getItem
(
'Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person'
)
->
isHit
(
)
)
;
$this
->
assertTrue
(
$arrayPool
->
getItem
(
'Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author'
)
->
isHit
(
)
)
;
}
public
function
testWarmUpWithAnnotations
(
)
{