[Form] simplified previous merge and fixed unit test
This commit is contained in:
parent
c36f8d6459
commit
beecac3adb
@ -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
|
||||
{
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user