|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
13 | 13 |
|
| 14 | +use Symfony\Component\Form\FormError; |
| 15 | + |
14 | 16 | class DateTimeTypeTest extends LocalizedTestCase
|
15 | 17 | {
|
16 | 18 | public function testSubmit_dateTime()
|
@@ -386,4 +388,53 @@ public function testDontPassHtml5TypeIfNotSingleText()
|
386 | 388 | $view = $form->createView();
|
387 | 389 | $this->assertFalse(isset($view->vars['type']));
|
388 | 390 | }
|
| 391 | + |
| 392 | + public function testDateTypeChoiceErrorsBubbleUp() |
| 393 | + { |
| 394 | + $error = new FormError('Invalid!'); |
| 395 | + $form = $this->factory->create('datetime', null); |
| 396 | + |
| 397 | + $form['date']->addError($error); |
| 398 | + |
| 399 | + $this->assertSame(array(), $form['date']->getErrors()); |
| 400 | + $this->assertSame(array($error), $form->getErrors()); |
| 401 | + } |
| 402 | + |
| 403 | + public function testDateTypeSingleTextErrorsBubbleUp() |
| 404 | + { |
| 405 | + $error = new FormError('Invalid!'); |
| 406 | + $form = $this->factory->create('datetime', null, array( |
| 407 | + 'date_widget' => 'single_text' |
| 408 | + )); |
| 409 | + |
| 410 | + $form['date']->addError($error); |
| 411 | + |
| 412 | + $this->assertSame(array(), $form['date']->getErrors()); |
| 413 | + $this->assertSame(array($error), $form->getErrors()); |
| 414 | + } |
| 415 | + |
| 416 | + public function testTimeTypeChoiceErrorsBubbleUp() |
| 417 | + { |
| 418 | + $error = new FormError('Invalid!'); |
| 419 | + $form = $this->factory->create('datetime', null); |
| 420 | + |
| 421 | + $form['time']->addError($error); |
| 422 | + |
| 423 | + $this->assertSame(array(), $form['time']->getErrors()); |
| 424 | + $this->assertSame(array($error), $form->getErrors()); |
| 425 | + } |
| 426 | + |
| 427 | + public function testTimeTypeSingleTextErrorsBubbleUp() |
| 428 | + { |
| 429 | + $error = new FormError('Invalid!'); |
| 430 | + $form = $this->factory->create('datetime', null, array( |
| 431 | + 'time_widget' => 'single_text' |
| 432 | + )); |
| 433 | + |
| 434 | + $form['time']->addError($error); |
| 435 | + |
| 436 | + $this->assertSame(array(), $form['time']->getErrors()); |
| 437 | + $this->assertSame(array($error), $form->getErrors()); |
| 438 | + } |
| 439 | + |
389 | 440 | }
|
0 commit comments