/** * @test */ public function canGetContainerInstanceFromTemplateVariables() { $sheet = Form\Container\Sheet::create(); $instance = $this->createMockedInstanceForVariableContainerTests(); ObjectAccess::getProperty($instance, 'viewHelperVariableContainer', TRUE)->expects($this->any())->method('exists')->will($this->returnValue(FALSE)); ObjectAccess::getProperty($instance, 'templateVariableContainer', TRUE)->expects($this->any())->method('exists')->will($this->returnValue(TRUE)); ObjectAccess::getProperty($instance, 'templateVariableContainer', TRUE)->expects($this->any())->method('get')->will($this->returnValue($sheet)); $output = $this->callInaccessibleMethod($instance, 'getContainer'); $this->assertSame($sheet, $output); }
/** * @param array $settings * @return Form */ public static function create(array $settings = array()) { $form = parent::create($settings); if (TRUE === isset($settings['sheets'])) { foreach ($settings['sheets'] as $sheetName => $sheetSettings) { if (FALSE === isset($sheetSettings['name'])) { $sheetSettings['name'] = $sheetName; } $sheet = Form\Container\Sheet::create($sheetSettings); $form->add($sheet); } } return $form; }