merged branch tvlooy/form_test (PR #6375)

This PR was merged into the master branch.

Commits
-------

cda1621 Move FormInterface too
0544351 Move DeprecationErrorHandler to Test folder so it's not removed when building the zip file
f56a2b9 Fix #6374 move FormBuilderInterface from Tests to Test

Discussion
----------

Fix #6374 move FormBuilderInterface from Tests to Test

---------------------------------------------------------------------------

by fabpot at 2012-12-16T07:47:55Z

Are there any other classes in the tests that might be useful for testing userland forms? ping @bschussek

---------------------------------------------------------------------------

by colinfrei at 2012-12-16T08:24:51Z

The DeprecationErrorHandler will need to be in the Test directory as well, as its handleBC method is used for handling BC code that's not in tests.

---------------------------------------------------------------------------

by colinfrei at 2012-12-16T09:06:51Z

Wanted to make a pull request to tvlooy's branch with the DeprecationErrorHandler stuff, but can't figure out how to do that - the commit is here: ec56379042

---------------------------------------------------------------------------

by stof at 2012-12-16T19:53:59Z

@fabpot The other extending interfaces provided for mocking purpose (as mocking an interface extending ``Traversable`` directly does not work). So we have FormInterface too at least
This commit is contained in:
Fabien Potencier 2012-12-18 13:05:19 +01:00
commit 7bc9caa979
22 changed files with 46 additions and 46 deletions

View File

@ -51,7 +51,7 @@ abstract class AbstractType implements FormTypeInterface
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$resolver->setDefaults($this->getDefaultOptions(array()));
$resolver->addAllowedValues($this->getAllowedOptionValues(array()));
restore_error_handler();

View File

@ -44,7 +44,7 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$resolver->setDefaults($this->getDefaultOptions());
$resolver->addAllowedValues($this->getAllowedOptionValues());
restore_error_handler();

View File

@ -367,7 +367,7 @@ class Form implements \IteratorAggregate, FormInterface
// Hook to change content of the data
if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA) || $dispatcher->hasListeners(FormEvents::SET_DATA)) {
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$event = new FormEvent($this, $modelData);
restore_error_handler();
$dispatcher->dispatch(FormEvents::PRE_SET_DATA, $event);
@ -532,7 +532,7 @@ class Form implements \IteratorAggregate, FormInterface
// Hook to change content of the data bound by the browser
if ($dispatcher->hasListeners(FormEvents::PRE_BIND) || $dispatcher->hasListeners(FormEvents::BIND_CLIENT_DATA)) {
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$event = new FormEvent($this, $submittedData);
restore_error_handler();
$dispatcher->dispatch(FormEvents::PRE_BIND, $event);
@ -594,7 +594,7 @@ class Form implements \IteratorAggregate, FormInterface
// Hook to change content of the data into the normalized
// representation
if ($dispatcher->hasListeners(FormEvents::BIND) || $dispatcher->hasListeners(FormEvents::BIND_NORM_DATA)) {
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$event = new FormEvent($this, $normData);
restore_error_handler();
$dispatcher->dispatch(FormEvents::BIND, $event);
@ -620,7 +620,7 @@ class Form implements \IteratorAggregate, FormInterface
$dispatcher->dispatch(FormEvents::POST_BIND, $event);
}
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
foreach ($this->config->getValidators() as $validator) {
$validator->validate($this);
}

View File

@ -99,7 +99,7 @@ class FormFactory implements FormFactoryInterface
$typeGuess = $guesser->guessType($class, $property);
$maxLengthGuess = $guesser->guessMaxLength($class, $property);
// Keep $minLengthGuess for BC until Symfony 2.3
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$minLengthGuess = $guesser->guessMinLength($class, $property);
restore_error_handler();
$requiredGuess = $guesser->guessRequired($class, $property);

View File

@ -131,7 +131,7 @@ class FormRegistry implements FormRegistryInterface
);
}
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$this->addType($this->resolvedTypeFactory->createResolvedType(
$type,
$typeExtensions,

View File

@ -1,6 +1,6 @@
<?php
namespace Symfony\Component\Form\Tests;
namespace Symfony\Component\Form\Test;
use Symfony\Component\Form\FormInterface as NonTestFormInterface;
use Symfony\Component\Form\FormEvent;
@ -27,7 +27,7 @@ class DeprecationErrorHandler
public static function getFormEvent(NonTestFormInterface $form, $data)
{
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$event = new FormEvent($form, $data);
restore_error_handler();

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Tests;
namespace Symfony\Component\Form\Test;
interface FormBuilderInterface extends \Iterator, \Symfony\Component\Form\FormBuilderInterface
{

View File

@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Tests;
namespace Symfony\Component\Form\Test;
interface FormInterface extends \Iterator, \Symfony\Component\Form\FormInterface
{

View File

@ -76,7 +76,7 @@ abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
*/
protected function getMockForm($name = 'name')
{
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$form->expects($this->any())
->method('getName')

View File

@ -118,14 +118,14 @@ class CompoundFormTest extends AbstractFormTest
{
$this->form->add($this->getBuilder()->getForm());
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->assertTrue($this->form->hasChildren());
restore_error_handler();
}
public function testHasNoChildren()
{
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->assertFalse($this->form->hasChildren());
restore_error_handler();
}
@ -231,7 +231,7 @@ class CompoundFormTest extends AbstractFormTest
$this->form->remove('foo');
$this->assertNull($child->getParent());
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->assertFalse($this->form->hasChildren());
restore_error_handler();
}

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener;
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
{
@ -41,7 +41,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
public function testFixRadio()
{
$data = '1';
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$this->listener->preBind($event);
@ -52,7 +52,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
public function testFixZero()
{
$data = '0';
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$this->listener->preBind($event);
@ -63,7 +63,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
public function testIgnoreEmptyString()
{
$data = '';
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$this->listener->preBind($event);

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
{
@ -26,7 +26,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
public function testFixHttpUrl()
{
$data = "www.symfony.com";
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
@ -38,7 +38,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
public function testSkipKnownUrl()
{
$data = "http://www.symfony.com";
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');
@ -50,7 +50,7 @@ class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
public function testSkipOtherProtocol()
{
$data = "ftp://www.symfony.com";
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$filter = new FixUrlProtocolListener('http');

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase
{
@ -49,7 +49,7 @@ abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase
protected function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Tests\FormInterface');
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
}
public function getBooleanMatrix1()

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
{
@ -62,7 +62,7 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
protected function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Tests\FormInterface');
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
}
public function testPreSetDataResizesForm()

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
class TrimListenerTest extends \PHPUnit_Framework_TestCase
{
@ -26,7 +26,7 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase
public function testTrim()
{
$data = " Foo! ";
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$filter = new TrimListener();
@ -38,7 +38,7 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase
public function testTrimSkipNonStrings()
{
$data = 1234;
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$filter = new TrimListener();
@ -59,7 +59,7 @@ class TrimListenerTest extends \PHPUnit_Framework_TestCase
$data = mb_convert_encoding(pack('H*', implode('', $chars)), 'UTF-8', 'UCS-2BE');
$data = $data."ab\ncd".$data;
$form = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$event = DeprecationErrorHandler::getFormEvent($form, $data);
$filter = new TrimListener();

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase
{
@ -60,7 +60,7 @@ class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase
protected function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Tests\FormInterface');
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
}
// https://github.com/symfony/symfony/pull/5838

View File

@ -16,7 +16,7 @@ use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
/**
* @author Bernhard Schussek <bschussek@gmail.com>

View File

@ -18,7 +18,7 @@ use Symfony\Component\Form\Util\PropertyPath;
use Symfony\Component\Form\Extension\Validator\Constraints\Form;
use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Form\Tests\DeprecationErrorHandler;
use Symfony\Component\Form\Test\DeprecationErrorHandler;
class ValidationListenerTest extends \PHPUnit_Framework_TestCase
{
@ -94,7 +94,7 @@ class ValidationListenerTest extends \PHPUnit_Framework_TestCase
private function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Tests\FormInterface');
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
}
// More specific mapping tests can be found in ViolationMapperTest

View File

@ -85,7 +85,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
->method('addType')
->with($resolvedType);
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->factory->addType($type);
restore_error_handler();
}
@ -97,7 +97,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
->with('name')
->will($this->returnValue('RESULT'));
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->assertSame('RESULT', $this->factory->hasType('name'));
restore_error_handler();
}
@ -116,7 +116,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
->with('name')
->will($this->returnValue($resolvedType));
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->assertEquals($type, $this->factory->getType('name'));
restore_error_handler();
}
@ -638,6 +638,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
private function getMockFormBuilder()
{
return $this->getMock('Symfony\Component\Form\Tests\FormBuilderInterface');
return $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
}
}

View File

@ -33,7 +33,7 @@ abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase
->addExtensions($this->getExtensions())
->getFormFactory();
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
}
protected function tearDown()

View File

@ -76,7 +76,7 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
->method('getName')
->will($this->returnValue('foo'));
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->registry->addType($resolvedType);
restore_error_handler();
@ -225,7 +225,7 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($this->registry->hasType('foo'));
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$this->registry->addType($resolvedType);
restore_error_handler();

View File

@ -644,7 +644,7 @@ class SimpleFormTest extends AbstractFormTest
{
$test = $this;
$validator = $this->getFormValidator();
set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handle'));
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$form = $this->getBuilder()
->addValidator($validator)
->getForm();
@ -686,7 +686,7 @@ class SimpleFormTest extends AbstractFormTest
{
$type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface');
$view = $this->getMock('Symfony\Component\Form\FormView');
$parentForm = $this->getMock('Symfony\Component\Form\Tests\FormInterface');
$parentForm = $this->getMock('Symfony\Component\Form\Test\FormInterface');
$parentView = $this->getMock('Symfony\Component\Form\FormView');
$form = $this->getBuilder()->setType($type)->getForm();
$form->setParent($parentForm);