[Form] simplified previous merge and fixed unit test

This commit is contained in:
Fabien Potencier 2011-07-04 12:12:42 +02:00
parent c36f8d6459
commit beecac3adb
3 changed files with 5 additions and 20 deletions

View File

@ -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
{
}

View File

@ -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;
}

View File

@ -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()