Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getLoaderForContextMapping example
trait
ContextMappingTestTrait
{
abstract
protected
function
getLoaderForContextMapping
(
)
: LoaderInterface;
public
function
testLoadContexts
(
)
{
$this
->
assertLoadedContexts
(
)
;
}
public
function
assertLoadedContexts
(
string
$dummyClass
= ContextDummy::
class
, string
$parentClass
= ContextDummyParent::
class
)
: void
{
$loader
=
$this
->
getLoaderForContextMapping
(
)
;
$classMetadata
=
new
ClassMetadata
(
$dummyClass
)
;
$parentClassMetadata
=
new
ClassMetadata
(
$parentClass
)
;
$loader
->
loadClassMetadata
(
$parentClassMetadata
)
;
$classMetadata
->
merge
(
$parentClassMetadata
)
;
$loader
->
loadClassMetadata
(
$classMetadata
)
;
$attributes
=
$classMetadata
->
getAttributesMetadata
(
)
;
$this
->
assertLoadedContexts
(
$this
->
getNamespace
(
)
.'\ContextDummyPromotedProperties',
$this
->
getNamespace
(
)
.'\ContextDummyParent'
)
;
}
public
function
testThrowsOnContextOnInvalidMethod
(
)
{
$class
=
$this
->
getNamespace
(
)
.'\BadMethodContextDummy';
$this
->
expectException
(
MappingException::
class
)
;
$this
->
expectExceptionMessage
(
sprintf
(
'Context on "%s::badMethod()" cannot be added',
$class
)
)
;
$loader
=
$this
->
getLoaderForContextMapping
(
)
;
$classMetadata
=
new
ClassMetadata
(
$class
)
;
$loader
->
loadClassMetadata
(
$classMetadata
)
;
}
public
function
testCanHandleUnrelatedIgnoredMethods
(
)
{
$class
=
$this
->
getNamespace
(
)
.'\Entity45016';
$this
->
expectException
(
MappingException::
class
)
;