Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
TestContextAwarePlugin example
/** * @covers ::applyContextMapping */
public
function
testApplyContextMapping
(
)
{
$entity
= EntityTest::
create
(
[
]
)
;
$context_definition
= EntityContextDefinition::
fromEntity
(
$entity
)
;
$context
= EntityContext::
fromEntity
(
$entity
)
;
$definition
=
[
'context_definitions' =>
[
'a_context_id' =>
$context_definition
]
]
;
$plugin
=
new
TestContextAwarePlugin
(
[
]
, 'test_plugin_id',
$definition
)
;
(
new
ContextHandler
(
)
)
->
applyContextMapping
(
$plugin
,
[
'a_context_id' =>
$context
]
)
;
$result
=
$plugin
->
getContext
(
'a_context_id'
)
;
$this
->
assertInstanceOf
(
EntityContext::
class
,
$result
)
;
$this
->
assertSame
(
$context
,
$result
)
;
}
/** * @covers ::applyContextMapping */
private
$configurablePlugin
;
/** * {@inheritdoc} */
protected
function
setUp
(
)
: void
{
parent::
setUp
(
)
;
$plugin_definition
=
new
TestContextAwarePluginDefinition
(
)
;
$plugin_definition
->
addContextDefinition
(
'nato_letter', ContextDefinition::
create
(
'string'
)
)
;
$this
->plugin =
new
TestContextAwarePlugin
(
[
]
, 'the_sisko',
$plugin_definition
)
;
$this
->configurablePlugin =
new
TestConfigurableContextAwarePlugin
(
[
]
, 'the_sisko',
$plugin_definition
)
;
}
/** * @covers ::getContextDefinitions */
public
function
testGetContextDefinitions
(
)
{
$this
->
assertIsArray
(
$this
->plugin->
getContextDefinitions
(
)
)
;
}
/** * @covers ::getContextDefinition */