@@ -4,21 +4,21 @@ |
||
| 4 | 4 | |
| 5 | 5 | class SearchTest extends FormTestCase { |
| 6 | 6 | |
| 7 | - /** @test */ |
|
| 8 | - public function it_can_be_rendered() |
|
| 9 | - { |
|
| 10 | - $form = $this->form(); |
|
| 11 | - $form->search('foo'); |
|
| 12 | - $this->assertContains('<input name="foo" value=""', $form->render()); |
|
| 13 | - $this->assertContains('<button name="foo_button"', $form->render()); |
|
| 14 | - } |
|
| 7 | + /** @test */ |
|
| 8 | + public function it_can_be_rendered() |
|
| 9 | + { |
|
| 10 | + $form = $this->form(); |
|
| 11 | + $form->search('foo'); |
|
| 12 | + $this->assertContains('<input name="foo" value=""', $form->render()); |
|
| 13 | + $this->assertContains('<button name="foo_button"', $form->render()); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - /** @test */ |
|
| 17 | - public function it_renders_a_default_value() |
|
| 18 | - { |
|
| 19 | - $form = $this->form(); |
|
| 20 | - $form->search('foo')->default('bar'); |
|
| 21 | - $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 22 | - } |
|
| 16 | + /** @test */ |
|
| 17 | + public function it_renders_a_default_value() |
|
| 18 | + { |
|
| 19 | + $form = $this->form(); |
|
| 20 | + $form->search('foo')->default('bar'); |
|
| 21 | + $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | } |
@@ -4,85 +4,85 @@ |
||
| 4 | 4 | |
| 5 | 5 | class CheckboxTest extends FormTestCase { |
| 6 | 6 | |
| 7 | - /** @test */ |
|
| 8 | - public function it_can_be_rendered() |
|
| 9 | - { |
|
| 10 | - $form = $this->form(); |
|
| 11 | - $form->checkbox('foo'); |
|
| 12 | - $this->assertContains('<input name="foo" type="checkbox"', $form->render()); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - /** @test */ |
|
| 16 | - public function it_is_unchecked_by_default() |
|
| 17 | - { |
|
| 18 | - $form = $this->form(); |
|
| 19 | - $form->checkbox('foo'); |
|
| 20 | - $this->assertNotContains('checked="checked"', $form->render()); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** @test */ |
|
| 24 | - public function it_can_be_checked() |
|
| 25 | - { |
|
| 26 | - $form = $this->form(); |
|
| 27 | - $form->checkbox('foo')->checked(); |
|
| 28 | - $this->assertContains('checked="checked"', $form->render()); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** @test */ |
|
| 32 | - public function it_renders_model_values() |
|
| 33 | - { |
|
| 34 | - $form = $this->form(); |
|
| 35 | - $form->defaults($this->model(['foo'=>1])); |
|
| 36 | - $form->checkbox('foo'); |
|
| 37 | - $this->assertContains('checked="checked"', $form->render()); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** @test */ |
|
| 41 | - public function it_can_fill_model_values() |
|
| 42 | - { |
|
| 43 | - $model = $this->model(['foo'=>'']); |
|
| 44 | - |
|
| 45 | - $form = $this->form(); |
|
| 46 | - $form->checkbox('foo')->checked(); |
|
| 47 | - $form->fill($model); |
|
| 48 | - |
|
| 49 | - $form->assertEquals($model->foo, 1); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** @test */ |
|
| 53 | - public function it_can_be_unchecked() |
|
| 54 | - { |
|
| 55 | - $form = $this->form(); |
|
| 56 | - $form->checkbox('foo')->checked()->unchecked(); |
|
| 57 | - $this->assertNotContains('checked="checked"', $form->render()); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** @test */ |
|
| 61 | - public function it_provides_expected_values() |
|
| 62 | - { |
|
| 63 | - $form = $this->form(); |
|
| 64 | - $form->checkbox('foo'); |
|
| 65 | - |
|
| 66 | - $this->assertFalse($form->get('foo')); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** @test */ |
|
| 70 | - public function it_provides_expected_default_values() |
|
| 71 | - { |
|
| 72 | - $form = $this->form(); |
|
| 73 | - $form->checkbox('foo')->checked(); |
|
| 74 | - |
|
| 75 | - $this->assertTrue($form->get('foo')); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** @test */ |
|
| 7 | + /** @test */ |
|
| 8 | + public function it_can_be_rendered() |
|
| 9 | + { |
|
| 10 | + $form = $this->form(); |
|
| 11 | + $form->checkbox('foo'); |
|
| 12 | + $this->assertContains('<input name="foo" type="checkbox"', $form->render()); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + /** @test */ |
|
| 16 | + public function it_is_unchecked_by_default() |
|
| 17 | + { |
|
| 18 | + $form = $this->form(); |
|
| 19 | + $form->checkbox('foo'); |
|
| 20 | + $this->assertNotContains('checked="checked"', $form->render()); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** @test */ |
|
| 24 | + public function it_can_be_checked() |
|
| 25 | + { |
|
| 26 | + $form = $this->form(); |
|
| 27 | + $form->checkbox('foo')->checked(); |
|
| 28 | + $this->assertContains('checked="checked"', $form->render()); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** @test */ |
|
| 32 | + public function it_renders_model_values() |
|
| 33 | + { |
|
| 34 | + $form = $this->form(); |
|
| 35 | + $form->defaults($this->model(['foo'=>1])); |
|
| 36 | + $form->checkbox('foo'); |
|
| 37 | + $this->assertContains('checked="checked"', $form->render()); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** @test */ |
|
| 41 | + public function it_can_fill_model_values() |
|
| 42 | + { |
|
| 43 | + $model = $this->model(['foo'=>'']); |
|
| 44 | + |
|
| 45 | + $form = $this->form(); |
|
| 46 | + $form->checkbox('foo')->checked(); |
|
| 47 | + $form->fill($model); |
|
| 48 | + |
|
| 49 | + $form->assertEquals($model->foo, 1); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** @test */ |
|
| 53 | + public function it_can_be_unchecked() |
|
| 54 | + { |
|
| 55 | + $form = $this->form(); |
|
| 56 | + $form->checkbox('foo')->checked()->unchecked(); |
|
| 57 | + $this->assertNotContains('checked="checked"', $form->render()); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** @test */ |
|
| 61 | + public function it_provides_expected_values() |
|
| 62 | + { |
|
| 63 | + $form = $this->form(); |
|
| 64 | + $form->checkbox('foo'); |
|
| 65 | + |
|
| 66 | + $this->assertFalse($form->get('foo')); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** @test */ |
|
| 70 | + public function it_provides_expected_default_values() |
|
| 71 | + { |
|
| 72 | + $form = $this->form(); |
|
| 73 | + $form->checkbox('foo')->checked(); |
|
| 74 | + |
|
| 75 | + $this->assertTrue($form->get('foo')); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** @test */ |
|
| 79 | 79 | public function it_validates_required() |
| 80 | 80 | { |
| 81 | - $this->assertValid(function($form) { $form->checkbox('foo'); }); |
|
| 82 | - $this->assertValid(function($form) { $form->checkbox('foo')->checked()->required(); }); |
|
| 81 | + $this->assertValid(function($form) { $form->checkbox('foo'); }); |
|
| 82 | + $this->assertValid(function($form) { $form->checkbox('foo')->checked()->required(); }); |
|
| 83 | 83 | |
| 84 | - $this->assertNotValid(function($form) { $form->checkbox('foo')->required(); }); |
|
| 85 | - $this->assertNotValid(function($form) { $form->checkbox('foo')->checked()->unchecked()->required(); }); |
|
| 86 | - } |
|
| 84 | + $this->assertNotValid(function($form) { $form->checkbox('foo')->required(); }); |
|
| 85 | + $this->assertNotValid(function($form) { $form->checkbox('foo')->checked()->unchecked()->required(); }); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -4,169 +4,169 @@ |
||
| 4 | 4 | |
| 5 | 5 | class TextTest extends FormTestCase { |
| 6 | 6 | |
| 7 | - /** @test */ |
|
| 8 | - public function it_can_be_rendered() |
|
| 9 | - { |
|
| 10 | - $form = $this->form(); |
|
| 11 | - $form->text('foo'); |
|
| 12 | - $this->assertContains('<input name="foo" value=""', $form->render()); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - /** @test */ |
|
| 16 | - public function it_renders_a_default_value() |
|
| 17 | - { |
|
| 18 | - $form = $this->form(); |
|
| 19 | - $form->text('foo')->default('bar'); |
|
| 20 | - $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** @test */ |
|
| 24 | - public function it_renders_model_values() |
|
| 25 | - { |
|
| 26 | - $form = $this->form(); |
|
| 27 | - $form->defaults($this->model(['foo'=>'bar'])); |
|
| 28 | - $form->text('foo'); |
|
| 29 | - $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** @test */ |
|
| 33 | - public function it_can_fill_model_values() |
|
| 34 | - { |
|
| 35 | - $model = $this->model(['foo'=>'']); |
|
| 36 | - |
|
| 37 | - $form = $this->form(); |
|
| 38 | - $form->text('foo')->default('bar'); |
|
| 39 | - $form->fill($model); |
|
| 40 | - |
|
| 41 | - $form->assertEquals($model->foo, 'bar'); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** @test */ |
|
| 45 | - public function it_escapes_value() |
|
| 46 | - { |
|
| 47 | - $form = $this->form(); |
|
| 48 | - $form->text('foo')->default('bar&'); |
|
| 49 | - $this->assertContains('<input name="foo" value="bar&"', $form->render()); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** @test */ |
|
| 53 | - public function it_provides_expected_values() |
|
| 54 | - { |
|
| 55 | - $form = $this->form(); |
|
| 56 | - $form->text('foo'); |
|
| 57 | - |
|
| 58 | - $this->assertSame($form->get('foo'), ''); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** @test */ |
|
| 62 | - public function it_provides_expected_default_values() |
|
| 63 | - { |
|
| 64 | - $form = $this->form(); |
|
| 65 | - $form->text('foo')->default('bar'); |
|
| 66 | - |
|
| 67 | - $this->assertSame($form->get('foo'), 'bar'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** @test */ |
|
| 7 | + /** @test */ |
|
| 8 | + public function it_can_be_rendered() |
|
| 9 | + { |
|
| 10 | + $form = $this->form(); |
|
| 11 | + $form->text('foo'); |
|
| 12 | + $this->assertContains('<input name="foo" value=""', $form->render()); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + /** @test */ |
|
| 16 | + public function it_renders_a_default_value() |
|
| 17 | + { |
|
| 18 | + $form = $this->form(); |
|
| 19 | + $form->text('foo')->default('bar'); |
|
| 20 | + $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** @test */ |
|
| 24 | + public function it_renders_model_values() |
|
| 25 | + { |
|
| 26 | + $form = $this->form(); |
|
| 27 | + $form->defaults($this->model(['foo'=>'bar'])); |
|
| 28 | + $form->text('foo'); |
|
| 29 | + $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** @test */ |
|
| 33 | + public function it_can_fill_model_values() |
|
| 34 | + { |
|
| 35 | + $model = $this->model(['foo'=>'']); |
|
| 36 | + |
|
| 37 | + $form = $this->form(); |
|
| 38 | + $form->text('foo')->default('bar'); |
|
| 39 | + $form->fill($model); |
|
| 40 | + |
|
| 41 | + $form->assertEquals($model->foo, 'bar'); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** @test */ |
|
| 45 | + public function it_escapes_value() |
|
| 46 | + { |
|
| 47 | + $form = $this->form(); |
|
| 48 | + $form->text('foo')->default('bar&'); |
|
| 49 | + $this->assertContains('<input name="foo" value="bar&"', $form->render()); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** @test */ |
|
| 53 | + public function it_provides_expected_values() |
|
| 54 | + { |
|
| 55 | + $form = $this->form(); |
|
| 56 | + $form->text('foo'); |
|
| 57 | + |
|
| 58 | + $this->assertSame($form->get('foo'), ''); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** @test */ |
|
| 62 | + public function it_provides_expected_default_values() |
|
| 63 | + { |
|
| 64 | + $form = $this->form(); |
|
| 65 | + $form->text('foo')->default('bar'); |
|
| 66 | + |
|
| 67 | + $this->assertSame($form->get('foo'), 'bar'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** @test */ |
|
| 71 | 71 | public function it_validates_required() |
| 72 | 72 | { |
| 73 | - $this->assertValid(function($form) { $form->text('foo'); }); |
|
| 73 | + $this->assertValid(function($form) { $form->text('foo'); }); |
|
| 74 | 74 | |
| 75 | - $this->assertNotValid(function($form) { $form->text('foo')->required(); }); |
|
| 76 | - } |
|
| 75 | + $this->assertNotValid(function($form) { $form->text('foo')->required(); }); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** @test */ |
|
| 78 | + /** @test */ |
|
| 79 | 79 | public function it_validates_between() |
| 80 | 80 | { |
| 81 | - $this->assertValid(function($form) { $form->text('foo')->between(5, 7); }); |
|
| 82 | - $this->assertValid(function($form) { $form->text('foo')->between(5, 7)->default('123456'); }); |
|
| 81 | + $this->assertValid(function($form) { $form->text('foo')->between(5, 7); }); |
|
| 82 | + $this->assertValid(function($form) { $form->text('foo')->between(5, 7)->default('123456'); }); |
|
| 83 | 83 | |
| 84 | - $this->assertNotValid(function($form) { $form->text('foo')->between(5, 7)->required(); }); |
|
| 85 | - $this->assertNotValid(function($form) { $form->text('foo')->between(5, 7)->default('123'); }); |
|
| 86 | - $this->assertNotValid(function($form) { $form->text('foo')->between(5, 7)->default('123456789'); }); |
|
| 87 | - } |
|
| 84 | + $this->assertNotValid(function($form) { $form->text('foo')->between(5, 7)->required(); }); |
|
| 85 | + $this->assertNotValid(function($form) { $form->text('foo')->between(5, 7)->default('123'); }); |
|
| 86 | + $this->assertNotValid(function($form) { $form->text('foo')->between(5, 7)->default('123456789'); }); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** @test */ |
|
| 89 | + /** @test */ |
|
| 90 | 90 | public function it_validates_min() |
| 91 | 91 | { |
| 92 | - $this->assertValid(function($form) { $form->text('foo')->min(5); }); |
|
| 93 | - $this->assertValid(function($form) { $form->text('foo')->min(5)->default('123456789'); }); |
|
| 92 | + $this->assertValid(function($form) { $form->text('foo')->min(5); }); |
|
| 93 | + $this->assertValid(function($form) { $form->text('foo')->min(5)->default('123456789'); }); |
|
| 94 | 94 | |
| 95 | - $this->assertNotValid(function($form) { $form->text('foo')->min(5)->required(); }); |
|
| 96 | - $this->assertNotValid(function($form) { $form->text('foo')->min(5)->default('123'); }); |
|
| 97 | - } |
|
| 95 | + $this->assertNotValid(function($form) { $form->text('foo')->min(5)->required(); }); |
|
| 96 | + $this->assertNotValid(function($form) { $form->text('foo')->min(5)->default('123'); }); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** @test */ |
|
| 99 | + /** @test */ |
|
| 100 | 100 | public function it_validates_max() |
| 101 | 101 | { |
| 102 | - $this->assertValid(function($form) { $form->text('foo')->max(5); }); |
|
| 103 | - $this->assertValid(function($form) { $form->text('foo')->max(5)->default('123'); }); |
|
| 102 | + $this->assertValid(function($form) { $form->text('foo')->max(5); }); |
|
| 103 | + $this->assertValid(function($form) { $form->text('foo')->max(5)->default('123'); }); |
|
| 104 | 104 | |
| 105 | - $this->assertNotValid(function($form) { $form->text('foo')->max(5)->required(); }); |
|
| 106 | - $this->assertNotValid(function($form) { $form->text('foo')->max(5)->default('123456789'); }); |
|
| 107 | - } |
|
| 105 | + $this->assertNotValid(function($form) { $form->text('foo')->max(5)->required(); }); |
|
| 106 | + $this->assertNotValid(function($form) { $form->text('foo')->max(5)->default('123456789'); }); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** @test */ |
|
| 109 | + /** @test */ |
|
| 110 | 110 | public function it_validates_alpha() |
| 111 | 111 | { |
| 112 | - $this->assertValid(function($form) { $form->text('foo')->alpha(); }); |
|
| 113 | - $this->assertValid(function($form) { $form->text('foo')->alpha()->default('valid'); }); |
|
| 112 | + $this->assertValid(function($form) { $form->text('foo')->alpha(); }); |
|
| 113 | + $this->assertValid(function($form) { $form->text('foo')->alpha()->default('valid'); }); |
|
| 114 | 114 | |
| 115 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha()->required(); }); |
|
| 116 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha()->default('inv@lid'); }); |
|
| 117 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha()->default('123456'); }); |
|
| 118 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha()->default('abc123'); }); |
|
| 119 | - } |
|
| 115 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha()->required(); }); |
|
| 116 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha()->default('inv@lid'); }); |
|
| 117 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha()->default('123456'); }); |
|
| 118 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha()->default('abc123'); }); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** @test */ |
|
| 121 | + /** @test */ |
|
| 122 | 122 | public function it_validates_alpha_num() |
| 123 | 123 | { |
| 124 | - $this->assertValid(function($form) { $form->text('foo')->alpha_num(); }); |
|
| 125 | - $this->assertValid(function($form) { $form->text('foo')->alpha_num()->default('valid'); }); |
|
| 126 | - $this->assertValid(function($form) { $form->text('foo')->alpha_num()->default('valid123'); }); |
|
| 127 | - $this->assertValid(function($form) { $form->text('foo')->alpha_num()->default('123'); }); |
|
| 128 | - |
|
| 129 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->required(); }); |
|
| 130 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->default('valid 123'); }); |
|
| 131 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->default('valid_123'); }); |
|
| 132 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->default('inv@lid123'); }); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** @test */ |
|
| 124 | + $this->assertValid(function($form) { $form->text('foo')->alpha_num(); }); |
|
| 125 | + $this->assertValid(function($form) { $form->text('foo')->alpha_num()->default('valid'); }); |
|
| 126 | + $this->assertValid(function($form) { $form->text('foo')->alpha_num()->default('valid123'); }); |
|
| 127 | + $this->assertValid(function($form) { $form->text('foo')->alpha_num()->default('123'); }); |
|
| 128 | + |
|
| 129 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->required(); }); |
|
| 130 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->default('valid 123'); }); |
|
| 131 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->default('valid_123'); }); |
|
| 132 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_num()->default('inv@lid123'); }); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** @test */ |
|
| 136 | 136 | public function it_validates_alpha_dash() |
| 137 | 137 | { |
| 138 | - $this->assertValid(function($form) { $form->text('foo')->alpha_dash(); }); |
|
| 139 | - $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid'); }); |
|
| 140 | - $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid123'); }); |
|
| 141 | - $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid-123'); }); |
|
| 142 | - $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid_123'); }); |
|
| 143 | - $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('123'); }); |
|
| 144 | - |
|
| 145 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_dash()->required(); }); |
|
| 146 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_dash()->default('valid 123'); }); |
|
| 147 | - $this->assertNotValid(function($form) { $form->text('foo')->alpha_dash()->default('inv@lid123'); }); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** @test */ |
|
| 138 | + $this->assertValid(function($form) { $form->text('foo')->alpha_dash(); }); |
|
| 139 | + $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid'); }); |
|
| 140 | + $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid123'); }); |
|
| 141 | + $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid-123'); }); |
|
| 142 | + $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('valid_123'); }); |
|
| 143 | + $this->assertValid(function($form) { $form->text('foo')->alpha_dash()->default('123'); }); |
|
| 144 | + |
|
| 145 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_dash()->required(); }); |
|
| 146 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_dash()->default('valid 123'); }); |
|
| 147 | + $this->assertNotValid(function($form) { $form->text('foo')->alpha_dash()->default('inv@lid123'); }); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** @test */ |
|
| 151 | 151 | public function it_validates_in() |
| 152 | 152 | { |
| 153 | - $this->assertValid(function($form) { $form->text('foo')->in(); }); |
|
| 154 | - $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b','c']); }); |
|
| 155 | - $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->default('a'); }); |
|
| 153 | + $this->assertValid(function($form) { $form->text('foo')->in(); }); |
|
| 154 | + $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b','c']); }); |
|
| 155 | + $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->default('a'); }); |
|
| 156 | 156 | |
| 157 | - $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->required(); }); |
|
| 158 | - $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->default('d'); }); |
|
| 159 | - } |
|
| 157 | + $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->required(); }); |
|
| 158 | + $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->default('d'); }); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** @test */ |
|
| 161 | + /** @test */ |
|
| 162 | 162 | public function it_validates_not_in() |
| 163 | 163 | { |
| 164 | - $this->assertValid(function($form) { $form->text('foo')->not_in(); }); |
|
| 165 | - $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b','c']); }); |
|
| 166 | - $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->default('d'); }); |
|
| 164 | + $this->assertValid(function($form) { $form->text('foo')->not_in(); }); |
|
| 165 | + $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b','c']); }); |
|
| 166 | + $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->default('d'); }); |
|
| 167 | 167 | |
| 168 | - $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->required(); }); |
|
| 169 | - $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->default('a'); }); |
|
| 170 | - } |
|
| 168 | + $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->required(); }); |
|
| 169 | + $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->default('a'); }); |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | } |
@@ -151,22 +151,22 @@ |
||
| 151 | 151 | public function it_validates_in() |
| 152 | 152 | { |
| 153 | 153 | $this->assertValid(function($form) { $form->text('foo')->in(); }); |
| 154 | - $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b','c']); }); |
|
| 155 | - $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->default('a'); }); |
|
| 154 | + $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b', 'c']); }); |
|
| 155 | + $this->assertValid(function($form) { $form->text('foo')->in(['a', 'b', 'c'])->default('a'); }); |
|
| 156 | 156 | |
| 157 | - $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->required(); }); |
|
| 158 | - $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b','c'])->default('d'); }); |
|
| 157 | + $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b', 'c'])->required(); }); |
|
| 158 | + $this->assertNotValid(function($form) { $form->text('foo')->in(['a', 'b', 'c'])->default('d'); }); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** @test */ |
| 162 | 162 | public function it_validates_not_in() |
| 163 | 163 | { |
| 164 | 164 | $this->assertValid(function($form) { $form->text('foo')->not_in(); }); |
| 165 | - $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b','c']); }); |
|
| 166 | - $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->default('d'); }); |
|
| 165 | + $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b', 'c']); }); |
|
| 166 | + $this->assertValid(function($form) { $form->text('foo')->not_in(['a', 'b', 'c'])->default('d'); }); |
|
| 167 | 167 | |
| 168 | - $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->required(); }); |
|
| 169 | - $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b','c'])->default('a'); }); |
|
| 168 | + $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b', 'c'])->required(); }); |
|
| 169 | + $this->assertNotValid(function($form) { $form->text('foo')->not_in(['a', 'b', 'c'])->default('a'); }); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
@@ -4,136 +4,136 @@ |
||
| 4 | 4 | |
| 5 | 5 | class PasswordTest extends FormTestCase { |
| 6 | 6 | |
| 7 | - /** @test */ |
|
| 8 | - public function it_can_be_rendered() |
|
| 9 | - { |
|
| 10 | - $form = $this->form(); |
|
| 11 | - $form->password('foo'); |
|
| 12 | - $this->assertContains('<input name="foo" type="password"', $form->render()); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - /** @test */ |
|
| 16 | - public function it_will_not_render_a_default_value() |
|
| 17 | - { |
|
| 18 | - $form = $this->form(); |
|
| 19 | - $form->password('foo')->default('bar'); |
|
| 20 | - $this->assertNotContains('value="bar"', $form->render()); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** @test */ |
|
| 24 | - public function it_will_not_render_a_model_value() |
|
| 25 | - { |
|
| 26 | - $form = $this->form(); |
|
| 27 | - $form->defaults($this->model(['foo'=>'bar'])); |
|
| 28 | - $form->password('foo'); |
|
| 29 | - $this->assertNotContains('value="bar"', $form->render()); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** @test */ |
|
| 33 | - public function it_cannot_fill_model_values_using_default() |
|
| 34 | - { |
|
| 35 | - $model = $this->model(['foo'=>'']); |
|
| 36 | - |
|
| 37 | - $form = $this->form(); |
|
| 38 | - $form->password('foo')->default('bar'); |
|
| 39 | - $form->fill($model); |
|
| 40 | - |
|
| 41 | - $form->assertEmpty($model->foo); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** @test */ |
|
| 45 | - public function it_can_fill_model_values_using_request() |
|
| 46 | - { |
|
| 47 | - $model = $this->model(['foo'=>'']); |
|
| 48 | - |
|
| 49 | - $request = $this->request(); |
|
| 50 | - $request->method('all')->will($this->returnValue(['foo'=>'bar', 'baz'=>true])); |
|
| 51 | - $request->method('get')->will($this->returnValueMap([ |
|
| 52 | - ['foo', 'bar'], |
|
| 53 | - ['baz', true], |
|
| 54 | - ])); |
|
| 55 | - |
|
| 56 | - $form = $this->form($request); |
|
| 57 | - $form->password('foo'); |
|
| 58 | - $form->button('baz'); |
|
| 59 | - |
|
| 60 | - $form->fill($model); |
|
| 61 | - |
|
| 62 | - $this->assertNotEmpty($model->foo); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** @test */ |
|
| 66 | - public function it_encrypts_passwords_automatically() |
|
| 67 | - { |
|
| 68 | - $model = $this->model(['foo'=>'']); |
|
| 69 | - |
|
| 70 | - $request = $this->request(); |
|
| 71 | - $request->method('all')->will($this->returnValue(['foo'=>'bar', 'baz'=>true])); |
|
| 72 | - $request->method('get')->will($this->returnValueMap([ |
|
| 73 | - ['foo', 'bar'], |
|
| 74 | - ['baz', true], |
|
| 75 | - ])); |
|
| 76 | - |
|
| 77 | - $form = $this->form($request); |
|
| 78 | - $form->password('foo'); |
|
| 79 | - $form->button('baz'); |
|
| 80 | - |
|
| 81 | - $form->fill($model); |
|
| 82 | - |
|
| 83 | - $this->assertNotSame($model->foo, 'bar'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** @test */ |
|
| 87 | - public function it_can_check_if_password_matches() |
|
| 88 | - { |
|
| 89 | - $model = $this->model(['foo'=>'']); |
|
| 90 | - |
|
| 91 | - $request = $this->request(); |
|
| 92 | - $request->method('all')->will($this->returnValue(['foo'=>'bar', 'baz'=>true])); |
|
| 93 | - $request->method('get')->will($this->returnValueMap([ |
|
| 94 | - ['foo', 'bar'], |
|
| 95 | - ['baz', true], |
|
| 96 | - ])); |
|
| 97 | - |
|
| 98 | - $form = $this->form($request); |
|
| 99 | - $form->password('foo'); |
|
| 100 | - $form->button('baz'); |
|
| 101 | - |
|
| 102 | - $form->fill($model); |
|
| 103 | - |
|
| 104 | - $hash = $form->password('foo')->hash('bar'); |
|
| 105 | - $invalid_hash = $form->password('foo')->hash('invalid'); |
|
| 106 | - $empty_hash = $form->password('foo')->hash(''); |
|
| 107 | - |
|
| 108 | - $this->assertTrue($form->password('foo')->matches($hash)); |
|
| 109 | - $this->assertFalse($form->password('foo')->matches($invalid_hash)); |
|
| 110 | - $this->assertFalse($form->password('foo')->matches($empty_hash)); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** @test */ |
|
| 114 | - public function it_provides_expected_values() |
|
| 115 | - { |
|
| 116 | - $form = $this->form(); |
|
| 117 | - $form->password('foo'); |
|
| 118 | - |
|
| 119 | - $this->assertSame($form->get('foo'), ''); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** @test */ |
|
| 123 | - public function it_will_not_provide_default_values() |
|
| 124 | - { |
|
| 125 | - $form = $this->form(); |
|
| 126 | - $form->password('foo')->default('bar'); |
|
| 127 | - |
|
| 128 | - $this->assertSame($form->get('foo'), ''); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** @test */ |
|
| 7 | + /** @test */ |
|
| 8 | + public function it_can_be_rendered() |
|
| 9 | + { |
|
| 10 | + $form = $this->form(); |
|
| 11 | + $form->password('foo'); |
|
| 12 | + $this->assertContains('<input name="foo" type="password"', $form->render()); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + /** @test */ |
|
| 16 | + public function it_will_not_render_a_default_value() |
|
| 17 | + { |
|
| 18 | + $form = $this->form(); |
|
| 19 | + $form->password('foo')->default('bar'); |
|
| 20 | + $this->assertNotContains('value="bar"', $form->render()); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** @test */ |
|
| 24 | + public function it_will_not_render_a_model_value() |
|
| 25 | + { |
|
| 26 | + $form = $this->form(); |
|
| 27 | + $form->defaults($this->model(['foo'=>'bar'])); |
|
| 28 | + $form->password('foo'); |
|
| 29 | + $this->assertNotContains('value="bar"', $form->render()); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** @test */ |
|
| 33 | + public function it_cannot_fill_model_values_using_default() |
|
| 34 | + { |
|
| 35 | + $model = $this->model(['foo'=>'']); |
|
| 36 | + |
|
| 37 | + $form = $this->form(); |
|
| 38 | + $form->password('foo')->default('bar'); |
|
| 39 | + $form->fill($model); |
|
| 40 | + |
|
| 41 | + $form->assertEmpty($model->foo); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** @test */ |
|
| 45 | + public function it_can_fill_model_values_using_request() |
|
| 46 | + { |
|
| 47 | + $model = $this->model(['foo'=>'']); |
|
| 48 | + |
|
| 49 | + $request = $this->request(); |
|
| 50 | + $request->method('all')->will($this->returnValue(['foo'=>'bar', 'baz'=>true])); |
|
| 51 | + $request->method('get')->will($this->returnValueMap([ |
|
| 52 | + ['foo', 'bar'], |
|
| 53 | + ['baz', true], |
|
| 54 | + ])); |
|
| 55 | + |
|
| 56 | + $form = $this->form($request); |
|
| 57 | + $form->password('foo'); |
|
| 58 | + $form->button('baz'); |
|
| 59 | + |
|
| 60 | + $form->fill($model); |
|
| 61 | + |
|
| 62 | + $this->assertNotEmpty($model->foo); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** @test */ |
|
| 66 | + public function it_encrypts_passwords_automatically() |
|
| 67 | + { |
|
| 68 | + $model = $this->model(['foo'=>'']); |
|
| 69 | + |
|
| 70 | + $request = $this->request(); |
|
| 71 | + $request->method('all')->will($this->returnValue(['foo'=>'bar', 'baz'=>true])); |
|
| 72 | + $request->method('get')->will($this->returnValueMap([ |
|
| 73 | + ['foo', 'bar'], |
|
| 74 | + ['baz', true], |
|
| 75 | + ])); |
|
| 76 | + |
|
| 77 | + $form = $this->form($request); |
|
| 78 | + $form->password('foo'); |
|
| 79 | + $form->button('baz'); |
|
| 80 | + |
|
| 81 | + $form->fill($model); |
|
| 82 | + |
|
| 83 | + $this->assertNotSame($model->foo, 'bar'); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** @test */ |
|
| 87 | + public function it_can_check_if_password_matches() |
|
| 88 | + { |
|
| 89 | + $model = $this->model(['foo'=>'']); |
|
| 90 | + |
|
| 91 | + $request = $this->request(); |
|
| 92 | + $request->method('all')->will($this->returnValue(['foo'=>'bar', 'baz'=>true])); |
|
| 93 | + $request->method('get')->will($this->returnValueMap([ |
|
| 94 | + ['foo', 'bar'], |
|
| 95 | + ['baz', true], |
|
| 96 | + ])); |
|
| 97 | + |
|
| 98 | + $form = $this->form($request); |
|
| 99 | + $form->password('foo'); |
|
| 100 | + $form->button('baz'); |
|
| 101 | + |
|
| 102 | + $form->fill($model); |
|
| 103 | + |
|
| 104 | + $hash = $form->password('foo')->hash('bar'); |
|
| 105 | + $invalid_hash = $form->password('foo')->hash('invalid'); |
|
| 106 | + $empty_hash = $form->password('foo')->hash(''); |
|
| 107 | + |
|
| 108 | + $this->assertTrue($form->password('foo')->matches($hash)); |
|
| 109 | + $this->assertFalse($form->password('foo')->matches($invalid_hash)); |
|
| 110 | + $this->assertFalse($form->password('foo')->matches($empty_hash)); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** @test */ |
|
| 114 | + public function it_provides_expected_values() |
|
| 115 | + { |
|
| 116 | + $form = $this->form(); |
|
| 117 | + $form->password('foo'); |
|
| 118 | + |
|
| 119 | + $this->assertSame($form->get('foo'), ''); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** @test */ |
|
| 123 | + public function it_will_not_provide_default_values() |
|
| 124 | + { |
|
| 125 | + $form = $this->form(); |
|
| 126 | + $form->password('foo')->default('bar'); |
|
| 127 | + |
|
| 128 | + $this->assertSame($form->get('foo'), ''); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** @test */ |
|
| 132 | 132 | public function it_validates_required() |
| 133 | 133 | { |
| 134 | - $this->assertValid(function($form) { $form->password('foo'); }); |
|
| 134 | + $this->assertValid(function($form) { $form->password('foo'); }); |
|
| 135 | 135 | |
| 136 | - $this->assertNotValid(function($form) { $form->password('foo')->required(); }); |
|
| 137 | - } |
|
| 136 | + $this->assertNotValid(function($form) { $form->password('foo')->required(); }); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | } |
@@ -4,156 +4,156 @@ |
||
| 4 | 4 | |
| 5 | 5 | class NumberTest extends FormTestCase { |
| 6 | 6 | |
| 7 | - /** @test */ |
|
| 8 | - public function it_can_be_rendered() |
|
| 9 | - { |
|
| 10 | - $form = $this->form(); |
|
| 11 | - $form->number('foo'); |
|
| 12 | - $this->assertContains('<input name="foo" value=""', $form->render()); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - /** @test */ |
|
| 16 | - public function it_renders_a_default_value() |
|
| 17 | - { |
|
| 18 | - $form = $this->form(); |
|
| 19 | - $form->number('foo')->default('123'); |
|
| 20 | - $this->assertContains('<input name="foo" value="123"', $form->render()); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - /** @test */ |
|
| 24 | - public function it_renders_model_values() |
|
| 25 | - { |
|
| 26 | - $form = $this->form(); |
|
| 27 | - $form->defaults($this->model(['foo'=>'bar'])); |
|
| 28 | - $form->number('foo'); |
|
| 29 | - $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** @test */ |
|
| 33 | - public function it_can_fill_model_values() |
|
| 34 | - { |
|
| 35 | - $model = $this->model(['foo'=>'']); |
|
| 36 | - |
|
| 37 | - $form = $this->form(); |
|
| 38 | - $form->number('foo')->default('bar'); |
|
| 39 | - $form->fill($model); |
|
| 40 | - |
|
| 41 | - $form->assertEquals($model->foo, 'bar'); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** @test */ |
|
| 45 | - public function it_escapes_value() |
|
| 46 | - { |
|
| 47 | - $form = $this->form(); |
|
| 48 | - $form->number('foo')->default('123&'); |
|
| 49 | - $this->assertContains('<input name="foo" value="123&"', $form->render()); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** @test */ |
|
| 53 | - public function it_provides_expected_values() |
|
| 54 | - { |
|
| 55 | - $form = $this->form(); |
|
| 56 | - $form->number('foo'); |
|
| 57 | - |
|
| 58 | - $this->assertSame($form->get('foo'), ''); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** @test */ |
|
| 62 | - public function it_provides_expected_default_values() |
|
| 63 | - { |
|
| 64 | - $form = $this->form(); |
|
| 65 | - $form->number('foo')->default('123'); |
|
| 66 | - |
|
| 67 | - $this->assertSame($form->get('foo'), '123'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** @test */ |
|
| 7 | + /** @test */ |
|
| 8 | + public function it_can_be_rendered() |
|
| 9 | + { |
|
| 10 | + $form = $this->form(); |
|
| 11 | + $form->number('foo'); |
|
| 12 | + $this->assertContains('<input name="foo" value=""', $form->render()); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + /** @test */ |
|
| 16 | + public function it_renders_a_default_value() |
|
| 17 | + { |
|
| 18 | + $form = $this->form(); |
|
| 19 | + $form->number('foo')->default('123'); |
|
| 20 | + $this->assertContains('<input name="foo" value="123"', $form->render()); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + /** @test */ |
|
| 24 | + public function it_renders_model_values() |
|
| 25 | + { |
|
| 26 | + $form = $this->form(); |
|
| 27 | + $form->defaults($this->model(['foo'=>'bar'])); |
|
| 28 | + $form->number('foo'); |
|
| 29 | + $this->assertContains('<input name="foo" value="bar"', $form->render()); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** @test */ |
|
| 33 | + public function it_can_fill_model_values() |
|
| 34 | + { |
|
| 35 | + $model = $this->model(['foo'=>'']); |
|
| 36 | + |
|
| 37 | + $form = $this->form(); |
|
| 38 | + $form->number('foo')->default('bar'); |
|
| 39 | + $form->fill($model); |
|
| 40 | + |
|
| 41 | + $form->assertEquals($model->foo, 'bar'); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** @test */ |
|
| 45 | + public function it_escapes_value() |
|
| 46 | + { |
|
| 47 | + $form = $this->form(); |
|
| 48 | + $form->number('foo')->default('123&'); |
|
| 49 | + $this->assertContains('<input name="foo" value="123&"', $form->render()); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** @test */ |
|
| 53 | + public function it_provides_expected_values() |
|
| 54 | + { |
|
| 55 | + $form = $this->form(); |
|
| 56 | + $form->number('foo'); |
|
| 57 | + |
|
| 58 | + $this->assertSame($form->get('foo'), ''); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** @test */ |
|
| 62 | + public function it_provides_expected_default_values() |
|
| 63 | + { |
|
| 64 | + $form = $this->form(); |
|
| 65 | + $form->number('foo')->default('123'); |
|
| 66 | + |
|
| 67 | + $this->assertSame($form->get('foo'), '123'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** @test */ |
|
| 71 | 71 | public function it_validates_required() |
| 72 | 72 | { |
| 73 | - $this->assertValid(function($form) { $form->number('foo'); }); |
|
| 73 | + $this->assertValid(function($form) { $form->number('foo'); }); |
|
| 74 | 74 | |
| 75 | - $this->assertNotValid(function($form) { $form->number('foo')->required(); }); |
|
| 76 | - } |
|
| 75 | + $this->assertNotValid(function($form) { $form->number('foo')->required(); }); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** @test */ |
|
| 78 | + /** @test */ |
|
| 79 | 79 | public function it_validates_numeric() |
| 80 | 80 | { |
| 81 | - $this->assertValid(function($form) { $form->number('foo')->default(123); }); |
|
| 81 | + $this->assertValid(function($form) { $form->number('foo')->default(123); }); |
|
| 82 | 82 | |
| 83 | - $this->assertNotValid(function($form) { $form->number('foo')->default('abc'); }); |
|
| 84 | - } |
|
| 83 | + $this->assertNotValid(function($form) { $form->number('foo')->default('abc'); }); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** @test */ |
|
| 86 | + /** @test */ |
|
| 87 | 87 | public function it_validates_between() |
| 88 | 88 | { |
| 89 | - $this->assertValid(function($form) { $form->number('foo')->between(5, 7); }); |
|
| 90 | - $this->assertValid(function($form) { $form->number('foo')->between(5, 7)->default('5'); }); |
|
| 91 | - $this->assertValid(function($form) { $form->number('foo')->between(5, 7)->default('6'); }); |
|
| 92 | - $this->assertValid(function($form) { $form->number('foo')->between(5, 7)->default('7'); }); |
|
| 89 | + $this->assertValid(function($form) { $form->number('foo')->between(5, 7); }); |
|
| 90 | + $this->assertValid(function($form) { $form->number('foo')->between(5, 7)->default('5'); }); |
|
| 91 | + $this->assertValid(function($form) { $form->number('foo')->between(5, 7)->default('6'); }); |
|
| 92 | + $this->assertValid(function($form) { $form->number('foo')->between(5, 7)->default('7'); }); |
|
| 93 | 93 | |
| 94 | - $this->assertNotValid(function($form) { $form->number('foo')->between(5, 7)->required(); }); |
|
| 95 | - $this->assertNotValid(function($form) { $form->number('foo')->between(5, 7)->default('3'); }); |
|
| 96 | - $this->assertNotValid(function($form) { $form->number('foo')->between(5, 7)->default('12'); }); |
|
| 97 | - } |
|
| 94 | + $this->assertNotValid(function($form) { $form->number('foo')->between(5, 7)->required(); }); |
|
| 95 | + $this->assertNotValid(function($form) { $form->number('foo')->between(5, 7)->default('3'); }); |
|
| 96 | + $this->assertNotValid(function($form) { $form->number('foo')->between(5, 7)->default('12'); }); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** @test */ |
|
| 99 | + /** @test */ |
|
| 100 | 100 | public function it_validates_min() |
| 101 | 101 | { |
| 102 | - $this->assertValid(function($form) { $form->number('foo')->min(5); }); |
|
| 103 | - $this->assertValid(function($form) { $form->number('foo')->min(5)->default(5); }); |
|
| 104 | - $this->assertValid(function($form) { $form->number('foo')->min(5)->default(10); }); |
|
| 102 | + $this->assertValid(function($form) { $form->number('foo')->min(5); }); |
|
| 103 | + $this->assertValid(function($form) { $form->number('foo')->min(5)->default(5); }); |
|
| 104 | + $this->assertValid(function($form) { $form->number('foo')->min(5)->default(10); }); |
|
| 105 | 105 | |
| 106 | - $this->assertNotValid(function($form) { $form->number('foo')->min(5)->required(); }); |
|
| 107 | - $this->assertNotValid(function($form) { $form->number('foo')->min(5)->default(3); }); |
|
| 108 | - $this->assertNotValid(function($form) { $form->number('foo')->min(5)->default(-5); }); |
|
| 109 | - } |
|
| 106 | + $this->assertNotValid(function($form) { $form->number('foo')->min(5)->required(); }); |
|
| 107 | + $this->assertNotValid(function($form) { $form->number('foo')->min(5)->default(3); }); |
|
| 108 | + $this->assertNotValid(function($form) { $form->number('foo')->min(5)->default(-5); }); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** @test */ |
|
| 111 | + /** @test */ |
|
| 112 | 112 | public function it_validates_max() |
| 113 | 113 | { |
| 114 | - $this->assertValid(function($form) { $form->number('foo')->max(5); }); |
|
| 115 | - $this->assertValid(function($form) { $form->number('foo')->max(5)->default(3); }); |
|
| 116 | - $this->assertValid(function($form) { $form->number('foo')->max(5)->default(5); }); |
|
| 114 | + $this->assertValid(function($form) { $form->number('foo')->max(5); }); |
|
| 115 | + $this->assertValid(function($form) { $form->number('foo')->max(5)->default(3); }); |
|
| 116 | + $this->assertValid(function($form) { $form->number('foo')->max(5)->default(5); }); |
|
| 117 | 117 | |
| 118 | - $this->assertNotValid(function($form) { $form->number('foo')->max(5)->required(); }); |
|
| 119 | - $this->assertNotValid(function($form) { $form->number('foo')->max(5)->default(5.1); }); |
|
| 120 | - $this->assertNotValid(function($form) { $form->number('foo')->max(5)->default(10); }); |
|
| 121 | - $this->assertNotValid(function($form) { $form->number('foo')->max(5)->default(12345); }); |
|
| 122 | - } |
|
| 118 | + $this->assertNotValid(function($form) { $form->number('foo')->max(5)->required(); }); |
|
| 119 | + $this->assertNotValid(function($form) { $form->number('foo')->max(5)->default(5.1); }); |
|
| 120 | + $this->assertNotValid(function($form) { $form->number('foo')->max(5)->default(10); }); |
|
| 121 | + $this->assertNotValid(function($form) { $form->number('foo')->max(5)->default(12345); }); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** @test */ |
|
| 124 | + /** @test */ |
|
| 125 | 125 | public function it_validates_integer() |
| 126 | 126 | { |
| 127 | - $this->assertValid(function($form) { $form->number('foo')->integer(); }); |
|
| 128 | - $this->assertValid(function($form) { $form->number('foo')->integer()->default(4); }); |
|
| 129 | - $this->assertValid(function($form) { $form->number('foo')->integer()->default('4'); }); |
|
| 127 | + $this->assertValid(function($form) { $form->number('foo')->integer(); }); |
|
| 128 | + $this->assertValid(function($form) { $form->number('foo')->integer()->default(4); }); |
|
| 129 | + $this->assertValid(function($form) { $form->number('foo')->integer()->default('4'); }); |
|
| 130 | 130 | |
| 131 | - $this->assertNotValid(function($form) { $form->number('foo')->integer()->required(); }); |
|
| 132 | - $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(10.3); }); |
|
| 133 | - $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(1/3); }); |
|
| 134 | - $this->assertNotValid(function($form) { $form->number('foo')->integer()->default('10.2'); }); |
|
| 135 | - } |
|
| 131 | + $this->assertNotValid(function($form) { $form->number('foo')->integer()->required(); }); |
|
| 132 | + $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(10.3); }); |
|
| 133 | + $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(1/3); }); |
|
| 134 | + $this->assertNotValid(function($form) { $form->number('foo')->integer()->default('10.2'); }); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** @test */ |
|
| 137 | + /** @test */ |
|
| 138 | 138 | public function it_validates_in() |
| 139 | 139 | { |
| 140 | - $this->assertValid(function($form) { $form->number('foo')->in(); }); |
|
| 141 | - $this->assertValid(function($form) { $form->number('foo')->in([1, 2, 3]); }); |
|
| 142 | - $this->assertValid(function($form) { $form->number('foo')->in([1, 2, 3])->default(1); }); |
|
| 140 | + $this->assertValid(function($form) { $form->number('foo')->in(); }); |
|
| 141 | + $this->assertValid(function($form) { $form->number('foo')->in([1, 2, 3]); }); |
|
| 142 | + $this->assertValid(function($form) { $form->number('foo')->in([1, 2, 3])->default(1); }); |
|
| 143 | 143 | |
| 144 | - $this->assertNotValid(function($form) { $form->number('foo')->in([1, 2, 3])->required(); }); |
|
| 145 | - $this->assertNotValid(function($form) { $form->number('foo')->in([1, 2, 3])->default(4); }); |
|
| 146 | - } |
|
| 144 | + $this->assertNotValid(function($form) { $form->number('foo')->in([1, 2, 3])->required(); }); |
|
| 145 | + $this->assertNotValid(function($form) { $form->number('foo')->in([1, 2, 3])->default(4); }); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** @test */ |
|
| 148 | + /** @test */ |
|
| 149 | 149 | public function it_validates_not_in() |
| 150 | 150 | { |
| 151 | - $this->assertValid(function($form) { $form->number('foo')->not_in(); }); |
|
| 152 | - $this->assertValid(function($form) { $form->number('foo')->not_in([1, 2, 3]); }); |
|
| 153 | - $this->assertValid(function($form) { $form->number('foo')->not_in([1, 2, 3])->default(4); }); |
|
| 151 | + $this->assertValid(function($form) { $form->number('foo')->not_in(); }); |
|
| 152 | + $this->assertValid(function($form) { $form->number('foo')->not_in([1, 2, 3]); }); |
|
| 153 | + $this->assertValid(function($form) { $form->number('foo')->not_in([1, 2, 3])->default(4); }); |
|
| 154 | 154 | |
| 155 | - $this->assertNotValid(function($form) { $form->number('foo')->not_in([1, 2, 3])->required(); }); |
|
| 156 | - $this->assertNotValid(function($form) { $form->number('foo')->not_in([1, 2, 3])->default(1); }); |
|
| 157 | - } |
|
| 155 | + $this->assertNotValid(function($form) { $form->number('foo')->not_in([1, 2, 3])->required(); }); |
|
| 156 | + $this->assertNotValid(function($form) { $form->number('foo')->not_in([1, 2, 3])->default(1); }); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | } |
@@ -130,7 +130,7 @@ |
||
| 130 | 130 | |
| 131 | 131 | $this->assertNotValid(function($form) { $form->number('foo')->integer()->required(); }); |
| 132 | 132 | $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(10.3); }); |
| 133 | - $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(1/3); }); |
|
| 133 | + $this->assertNotValid(function($form) { $form->number('foo')->integer()->default(1 / 3); }); |
|
| 134 | 134 | $this->assertNotValid(function($form) { $form->number('foo')->integer()->default('10.2'); }); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | if ($form->submitted()) { |
| 9 | 9 | |
| 10 | - $model = new stdClass; |
|
| 11 | - $model->foo = ''; |
|
| 10 | + $model = new stdClass; |
|
| 11 | + $model->foo = ''; |
|
| 12 | 12 | |
| 13 | - $form->fill($model); |
|
| 13 | + $form->fill($model); |
|
| 14 | 14 | |
| 15 | - exit('Submitted ['.$model->foo.']'); |
|
| 15 | + exit('Submitted ['.$model->foo.']'); |
|
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | if ($form->submitted()) { |
| 9 | 9 | |
| 10 | - exit('Submitted ['.$form->get('foo').']'); |
|
| 10 | + exit('Submitted ['.$form->get('foo').']'); |
|
| 11 | 11 | |
| 12 | 12 | } |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | if ($form->submitted()) { |
| 9 | 9 | |
| 10 | - exit('Submitted ['.$form->get('foo').']'); |
|
| 10 | + exit('Submitted ['.$form->get('foo').']'); |
|
| 11 | 11 | |
| 12 | 12 | } |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | if ($form->submitted()) { |
| 9 | 9 | |
| 10 | - exit('Submitted ['.$form->get('foo').']'); |
|
| 10 | + exit('Submitted ['.$form->get('foo').']'); |
|
| 11 | 11 | |
| 12 | 12 | } |
| 13 | 13 | |