Procházet zdrojové kódy

[Form] simplified previous merge and fixed unit test

Fabien Potencier před 14 roky
rodič
revize
beecac3adb

+ 0 - 16
src/Symfony/Component/Form/Exception/FormNotBoundException.php

@@ -1,16 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Form\Exception;
-
-class FormNotBoundException extends FormException
-{
-}

+ 1 - 3
src/Symfony/Component/Form/Form.php

@@ -14,7 +14,6 @@ namespace Symfony\Component\Form;
 use Symfony\Component\Form\Event\DataEvent;
 use Symfony\Component\Form\Event\FilterDataEvent;
 use Symfony\Component\Form\Exception\FormException;
-use Symfony\Component\Form\Exception\FormNotBoundException;
 use Symfony\Component\Form\Exception\UnexpectedTypeException;
 use Symfony\Component\Form\Exception\TransformationFailedException;
 use Symfony\Component\HttpFoundation\Request;
@@ -676,11 +675,10 @@ class Form implements \IteratorAggregate, FormInterface
     public function isValid()
     {
         if (!$this->isBound()) {
-            throw new FormNotBoundException('Can not validate a form that is not bound');
+            throw new \LogicException('You cannot call isValid() on a form that is not bound.');
         }
 
         if ($this->hasErrors()) {
-
             return false;
         }
 

+ 4 - 1
tests/Symfony/Tests/Component/Form/FormTest.php

@@ -329,9 +329,12 @@ class FormTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($form->isValid());
     }
 
+    /**
+     * @expectedException \LogicException
+     */
     public function testNotValidIfNotBound()
     {
-        $this->assertFalse($this->form->isValid());
+        $this->form->isValid();
     }
 
     public function testNotValidIfErrors()