Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getTestValues example
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$entity
->
expects
(
$this
->
once
(
)
)
->
method
(
'setComponent'
)
->
with
(
'field_name_test',
[
'test setting'
]
)
->
will
(
$this
->
returnSelf
(
)
)
;
$entity
->
expects
(
$this
->
once
(
)
)
->
method
(
'save'
)
->
with
(
)
;
$plugin
=
new
TestPerComponentEntityDisplay
(
$entity
)
;
$this
->
assertSame
(
[
'entity_type_test', 'bundle_test', 'view_mode_test', 'field_name_test'
]
,
$plugin
->
import
(
$row
)
)
;
$this
->
assertSame
(
[
'entity_type_test', 'bundle_test', 'view_mode_test'
]
,
$plugin
->
getTestValues
(
)
)
;
}
}
class
TestPerComponentEntityDisplay
extends
ComponentEntityDisplayBase
{
const
MODE_NAME = 'view_mode';
protected
$testValues
;
protected
$entity
;
public
function
__construct
(
$entity
)
{
$this
->entity =
$entity
;
}
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$entity
->
expects
(
$this
->
once
(
)
)
->
method
(
'setComponent'
)
->
with
(
'field_name_test',
[
'test setting'
]
)
->
will
(
$this
->
returnSelf
(
)
)
;
$entity
->
expects
(
$this
->
once
(
)
)
->
method
(
'save'
)
->
with
(
)
;
$plugin
=
new
TestPerComponentEntityFormDisplay
(
$entity
)
;
$this
->
assertSame
(
[
'entity_type_test', 'bundle_test', 'form_mode_test', 'field_name_test'
]
,
$plugin
->
import
(
$row
)
)
;
$this
->
assertSame
(
[
'entity_type_test', 'bundle_test', 'form_mode_test'
]
,
$plugin
->
getTestValues
(
)
)
;
}
}
class
TestPerComponentEntityFormDisplay
extends
PerComponentEntityFormDisplay
{
const
MODE_NAME = 'form_mode';
protected
$testValues
;
protected
$entity
;
public
function
__construct
(
$entity
)
{
$this
->entity =
$entity
;
}