Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
Map example
'foo' =>
$object
,
]
)
)
;
$form
=
new
Form
(
$config
)
;
$form
->
setData
(
'foo'
)
;
$this
->
assertSame
(
$object
,
$form
->
getViewData
(
)
)
;
}
public
function
testViewDataMayBeArrayAccessIfDataClassIsNull
(
)
{
$arrayAccess
=
new
Map
(
)
;
$config
=
new
FormConfigBuilder
(
'name', null,
new
EventDispatcher
(
)
)
;
$config
->
addViewTransformer
(
new
FixedDataTransformer
(
[
'' => '',
'foo' =>
$arrayAccess
,
]
)
)
;
$form
=
new
Form
(
$config
)
;
$form
->
setData
(
'foo'
)
;
$this
->
assertSame
(
$arrayAccess
,
$form
->
getViewData
(
)
)
;
}
->
setDataMapper
(
new
DataMapper
(
)
)
->
setData
(
$object
)
->
getForm
(
)
;
$form
->
submit
(
[
]
)
;
$this
->
assertSame
(
$object
,
$form
->
getData
(
)
)
;
}
public
function
testSubmitMapsSubmittedChildrenOntoEmptyData
(
)
{
$object
=
new
Map
(
)
;
$form
=
$this
->
getBuilder
(
)
->
setCompound
(
true
)
->
setDataMapper
(
new
DataMapper
(
)
)
->
setEmptyData
(
$object
)
->
setData
(
null
)
->
getForm
(
)
;
$form
->
add
(
$child
=
$this
->
getBuilder
(
'name'
)
->
setCompound
(
false
)
->
getForm
(
)
)
;
$form
->
submit
(
[
'name' => 'Bernhard',
]
)
;