Skip to content

Commit

Permalink
merged branch tvlooy/form_test (PR #6375)
Browse files Browse the repository at this point in the history
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: colinfrei@ec56379

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

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
  • Loading branch information
fabpot committed Dec 18, 2012
2 parents 0b69f09 + cda1621 commit 7bc9caa
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
*/
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();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/AbstractTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
*/
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();
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function setData($modelData)

// 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);
Expand Down Expand Up @@ -532,7 +532,7 @@ public function bind($submittedData)

// 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);
Expand Down Expand Up @@ -594,7 +594,7 @@ public function bind($submittedData)
// 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);
Expand All @@ -620,7 +620,7 @@ public function bind($submittedData)
$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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function createBuilderForProperty($class, $property, $data = null, array
$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);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function resolveAndAddType(FormTypeInterface $type)
);
}

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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -27,7 +27,7 @@ public static function handleBC($errorNumber, $message, $file, $line, $context)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/Tests/AbstractFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function getBuilder($name = 'name', EventDispatcherInterface $dispatch
*/
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')
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/Tests/CompoundFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ public function testHasChildren()
{
$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();
}
Expand Down Expand Up @@ -231,7 +231,7 @@ public function testRemove()
$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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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
{
Expand Down Expand Up @@ -41,7 +41,7 @@ protected function tearDown()
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);
Expand All @@ -52,7 +52,7 @@ public function testFixRadio()
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);
Expand All @@ -63,7 +63,7 @@ public function testFixZero()
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -26,7 +26,7 @@ protected function setUp()
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');
Expand All @@ -38,7 +38,7 @@ public function testFixHttpUrl()
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');
Expand All @@ -50,7 +50,7 @@ public function testSkipKnownUrl()
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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -49,7 +49,7 @@ protected function getForm($name = 'name', $propertyPath = null)

protected function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Tests\FormInterface');
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
}

public function getBooleanMatrix1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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
{
Expand Down Expand Up @@ -62,7 +62,7 @@ private function getDataMapper()

protected function getMockForm()
{
return $this->getMock('Symfony\Component\Form\Tests\FormInterface');
return $this->getMock('Symfony\Component\Form\Test\FormInterface');
}

public function testPreSetDataResizesForm()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -26,7 +26,7 @@ protected function setUp()
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();
Expand All @@ -38,7 +38,7 @@ public function testTrim()
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();
Expand All @@ -59,7 +59,7 @@ public function testTrimUtf8($chars)
$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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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
{
Expand Down Expand Up @@ -60,7 +60,7 @@ protected function getDataMapper()

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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
{
Expand Down Expand Up @@ -94,7 +94,7 @@ private function getForm($name = 'name', $propertyPath = null, $dataClass = null

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
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Form/Tests/FormFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testAddType()
->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();
}
Expand All @@ -97,7 +97,7 @@ public function testHasType()
->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();
}
Expand All @@ -116,7 +116,7 @@ public function testGetType()
->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();
}
Expand Down Expand Up @@ -638,6 +638,6 @@ private function getMockType()

private function getMockFormBuilder()
{
return $this->getMock('Symfony\Component\Form\Tests\FormBuilderInterface');
return $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp()
->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()
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Tests/FormRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testGetTypeReturnsAddedType()
->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();

Expand Down Expand Up @@ -225,7 +225,7 @@ public function testHasTypeAfterAdding()

$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();

Expand Down

0 comments on commit 7bc9caa

Please sign in to comment.