public function testCreateEmpty() { $formAction = FormAction::createEmpty(); $this->assertTrue($formAction->isEmpty()); $this->assertFalse(isset($formAction[FormAction::PATH])); $this->assertFalse(isset($formAction[FormAction::ROUTE_NAME])); $this->assertFalse(isset($formAction[FormAction::ROUTE_PARAMETERS])); $this->assertNull($formAction[FormAction::PATH]); $this->assertNull($formAction[FormAction::ROUTE_NAME]); $this->assertNull($formAction[FormAction::ROUTE_PARAMETERS]); $this->assertNull($formAction->getPath()); $this->assertNull($formAction->getRouteName()); $this->assertNull($formAction->getRouteParameters()); $this->assertSame('', $formAction->toString()); }
public function testBuildViewWithEmptyFormParams() { $formName = 'test_form'; $formView = new FormView(); $formAccessor = $this->getMock('Oro\\Bundle\\LayoutBundle\\Layout\\Form\\FormAccessorInterface'); $formAccessor->expects($this->never())->method('getForm'); $formAccessor->expects($this->once())->method('getView')->with(null)->will($this->returnValue($formView)); $formAccessor->expects($this->once())->method('getAction')->will($this->returnValue(FormAction::createEmpty())); $formAccessor->expects($this->once())->method('getMethod')->will($this->returnValue(null)); $formAccessor->expects($this->once())->method('getEnctype')->will($this->returnValue(null)); $this->context->getResolver()->setOptional([$formName]); $this->context->set($formName, $formAccessor); $view = $this->getBlockView(FormStartType::NAME, ['form_name' => $formName]); $this->assertSame($formView, $view->vars['form']); $this->assertArrayNotHasKey('action_path', $view->vars); $this->assertArrayNotHasKey('action_route_name', $view->vars); $this->assertArrayNotHasKey('action_route_parameters', $view->vars); $this->assertArrayNotHasKey('method', $view->vars); $this->assertArrayNotHasKey('enctype', $view->vars); }
/** * Makes sure that the action, method and enctype are initialized. */ protected function ensureParamsInitialized() { if ($this->paramsInitialized) { return; } if (null === $this->action) { $action = $this->getForm()->getConfig()->getAction(); $this->action = $action ? FormAction::createByPath($action) : FormAction::createEmpty(); } if (null === $this->method) { $this->method = $this->getForm()->getConfig()->getMethod(); } if (null !== $this->method) { $this->method = strtoupper($this->method); } if (null === $this->enctype && $this->getFormView()->vars['multipart']) { $this->enctype = 'multipart/form-data'; } $this->paramsInitialized = true; }
public function testCreateFormAccessorByFormActionObject() { $context = new LayoutContext(); $form = $this->getMock('Symfony\\Component\\Form\\FormInterface'); $formAction = FormAction::createEmpty(); $context['form'] = $form; $context['form_action'] = $formAction; $context['form_method'] = 'method'; $context['form_enctype'] = 'enctype'; $this->contextConfigurator->configureContext($context); $context->resolve(); $this->assertInstanceOf('Oro\\Bundle\\LayoutBundle\\Layout\\Form\\FormAccessor', $context['form']); /** @var FormAccessor $formAccessor */ $formAccessor = $context['form']; $this->assertSame($form, $formAccessor->getForm()); $this->assertSame($formAction, $formAccessor->getAction()); $this->assertEquals('METHOD', $formAccessor->getMethod()); $this->assertEquals('enctype', $formAccessor->getEnctype()); }