/** * Test form create. * * @return void */ public function testForm() { $expected = ['form' => ['method' => 'post', 'accept-charset' => 'utf-8', 'class' => 'un-form', 'action' => '/'], 'div' => ['style' => 'display:none;'], 'input' => ['type' => 'hidden', 'class' => 'form-control', 'name' => '_method', 'value' => 'POST'], '/div']; $this->assertHtml($expected, $this->Form->create(false)); $this->assertSame('</form>', $this->Form->end()); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// $expected = ['form' => ['method' => 'post', 'accept-charset' => 'utf-8', 'class' => 'un-form jsForm', 'action' => '/'], 'div' => ['style' => 'display:none;'], 'input' => ['type' => 'hidden', 'class' => 'form-control', 'name' => '_method', 'value' => 'POST'], '/div']; $this->assertHtml($expected, $this->Form->create(false, ['jsForm' => true])); $this->assertSame('<input type="hidden" name="action" class="jsFormAction form-control" value=""/></form>', $this->Form->end()); //////////////////////////////////////////////////////////////////////////////////////////////////////////////// $Request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Pages', 'action' => 'index', 'pass' => []]]); $View = new AppView($Request); $Form = new FormHelper($View); $expected = ['form' => ['method' => 'post', 'accept-charset' => 'utf-8', 'class' => 'un-form jsForm', 'action' => '/test_plugin/pages/process'], 'div' => ['style' => 'display:none;'], 'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'], '/div']; $this->assertHtml($expected, $Form->create(false, ['process' => true])); $this->assertSame('<input type="hidden" name="action" class="jsFormAction" value=""/></form>', $Form->end()); }