if ($emptyData instanceof \Closure
) { $emptyData =
$emptyData($form);
} $this->
assertSame($emptyData,
$form->
getViewData());
$this->
assertEquals($expectedData,
$form->
getNormData());
$this->
assertEquals($expectedData,
$form->
getData());
} public static function provideEmptyData() { $expectedData = \DateTime::
createFromFormat('Y-m-d H:i', '2018-11-11 21:23'
);
$lazyEmptyData =
static fn (FormInterface
$form) =>
$form->
getConfig()->
getCompound() ?
['date' =>
['year' => '2018', 'month' => '11', 'day' => '11'
], 'time' =>
['hour' => '21', 'minute' => '23'
]] : '2018-11-11T21:23';
return [ 'Simple field' =>
['single_text', '2018-11-11T21:23',
$expectedData],
'Compound text field' =>
['text',
['date' =>
['year' => '2018', 'month' => '11', 'day' => '11'
], 'time' =>
['hour' => '21', 'minute' => '23'
]],
$expectedData],
'Compound choice field' =>
['choice',
['date' =>
['year' => '2018', 'month' => '11', 'day' => '11'
], 'time' =>
['hour' => '21', 'minute' => '23'
]],
$expectedData],
'Simple field lazy' =>
['single_text',
$lazyEmptyData,
$expectedData],
'Compound text field lazy' =>
['text',
$lazyEmptyData,
$expectedData],
'Compound choice field lazy' =>
['choice',
$lazyEmptyData,
$expectedData],
];
}