|
5 | 5 | require_once 'MockForm.php';
|
6 | 6 |
|
7 | 7 | class FormTest extends PHPUnit_Framework_TestCase {
|
| 8 | + public function testClassString(){ |
| 9 | + $mock = new MockLayout(); |
| 10 | + $form = Form::create('id', function($f){}, ['layout' => $mock, 'class' => 'foo bar']); |
| 11 | + $this->assertEquals('POST', $mock->form_attr['method']); |
| 12 | + $this->assertEquals(['form', 'mock', 'foo', 'bar'], $mock->form_attr['class']); |
| 13 | + } |
| 14 | + |
| 15 | + public function testClassArray(){ |
| 16 | + $mock = new MockLayout(); |
| 17 | + $form = Form::create('id', function($f){}, ['layout' => $mock, 'class' => ['foo', 'bar']]); |
| 18 | + $this->assertEquals('POST', $mock->form_attr['method']); |
| 19 | + $this->assertEquals(['form', 'mock', 'foo', 'bar'], $mock->form_attr['class']); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * @expectedException PHPUnit_Framework_Error_Notice |
| 24 | + */ |
| 25 | + public function testLayoutMissing(){ |
| 26 | + $form = Form::create('id', function($f){}, ['layout' => 'foobar']); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @expectedException PHPUnit_Framework_Error |
| 31 | + */ |
| 32 | + public function testLayoutInvalidClass(){ |
| 33 | + $form = Form::create('id', function($f){}, ['layout' => new stdClass]); |
| 34 | + } |
| 35 | + |
8 | 36 | public function testHttpMethodDefault(){
|
9 | 37 | $mock = new MockLayout();
|
10 | 38 | $form = Form::create('id', function($f){}, ['layout' => $mock]);
|
|
0 commit comments