Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[2.5] cleanup deprecated uses
  • Loading branch information
nicolas-grekas committed Jan 5, 2015
1 parent 6537359 commit 237c315
Show file tree
Hide file tree
Showing 44 changed files with 272 additions and 200 deletions.
Expand Up @@ -265,6 +265,23 @@ public function testInitShorthandEntityName()
);

$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
}

public function testLegacyInitShorthandEntityName()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);

$item1 = new SingleIntIdEntity(1, 'Foo');
$item2 = new SingleIntIdEntity(2, 'Bar');

$this->em->persist($item1);
$this->em->persist($item2);

$choiceList = new EntityChoiceList(
$this->em,
'SymfonyTestsDoctrine:SingleIntIdEntity'
);

$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
}
}
Expand Up @@ -20,4 +20,9 @@ public function testGetIndicesForValuesIgnoresNonExistingValues()
{
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
}

public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
{
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
}
}
Expand Up @@ -23,7 +23,6 @@
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator;
use Doctrine\ORM\Tools\SchemaTool;

/**
Expand Down
Expand Up @@ -183,7 +183,6 @@ public function testGetValuesForChoices()
);

$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
}

public function testDifferentEqualObjectsAreChoosen()
Expand All @@ -202,12 +201,58 @@ public function testDifferentEqualObjectsAreChoosen()

$choosenItem = new Item(1, 'Foo');

$this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
$this->assertEquals(array('1'), $choiceList->getValuesForChoices(array($choosenItem)));
}

public function testGetIndicesForNullChoices()
public function testLegacygetIndicesForChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);

$item1 = new Item(1, 'Foo');
$item2 = new Item(2, 'Bar');

ItemQuery::$result = array(
$item1,
$item2,
);

$choiceList = new ModelChoiceList(
self::ITEM_CLASS,
'value',
null,
null,
null,
null
);

$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
}

public function testLegacyDifferentEqualObjectsAreChoosen()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);

$item = new Item(1, 'Foo');

ItemQuery::$result = array(
$item,
);

$choiceList = new ModelChoiceList(
self::ITEM_CLASS,
'value',
array($item)
);

$choosenItem = new Item(1, 'Foo');

$this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
}

public function testLegacyGetIndicesForNullChoices()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);

$item = new Item(1, 'Foo');
$choiceList = new ModelChoiceList(
self::ITEM_CLASS,
Expand Down
Expand Up @@ -36,7 +36,7 @@ protected function setUp()
'form_div_layout.html.twig',
'custom_widgets.html.twig',
));
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));

$this->extension = new FormExtension($renderer);

Expand Down
Expand Up @@ -35,7 +35,7 @@ protected function setUp()
'form_table_layout.html.twig',
'custom_widgets.html.twig',
));
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));

$this->extension = new FormExtension($renderer);

Expand Down
Expand Up @@ -12,33 +12,37 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;

class SessionHelperTest extends \PHPUnit_Framework_TestCase
{
protected $request;
protected $requestStack;

protected function setUp()
{
$this->request = new Request();
$request = new Request();

$session = new Session(new MockArraySessionStorage());
$session->set('foobar', 'bar');
$session->getFlashBag()->set('notice', 'bar');

$this->request->setSession($session);
$request->setSession($session);

$this->requestStack = new RequestStack();
$this->requestStack->push($request);
}

protected function tearDown()
{
$this->request = null;
$this->requestStack = null;
}

public function testFlash()
{
$helper = new SessionHelper($this->request);
$helper = new SessionHelper($this->requestStack);

$this->assertTrue($helper->hasFlash('notice'));

Expand All @@ -47,13 +51,13 @@ public function testFlash()

public function testGetFlashes()
{
$helper = new SessionHelper($this->request);
$helper = new SessionHelper($this->requestStack);
$this->assertEquals(array('notice' => array('bar')), $helper->getFlashes());
}

public function testGet()
{
$helper = new SessionHelper($this->request);
$helper = new SessionHelper($this->requestStack);

$this->assertEquals('bar', $helper->get('foobar'));
$this->assertEquals('foo', $helper->get('bar', 'foo'));
Expand All @@ -63,7 +67,7 @@ public function testGet()

public function testGetName()
{
$helper = new SessionHelper($this->request);
$helper = new SessionHelper($this->requestStack);

$this->assertEquals('session', $helper->getName());
}
Expand Down
Expand Up @@ -15,8 +15,13 @@
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
use Symfony\Bundle\TwigBundle\Node\RenderNode;

class RenderTokenParserTest extends TestCase
class LegacyRenderTokenParserTest extends TestCase
{
public function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}

/**
* @dataProvider getTestsForRender
*/
Expand Down
Expand Up @@ -13,10 +13,12 @@

use Symfony\Component\ClassLoader\ApcUniversalClassLoader;

class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

if (!extension_loaded('apc')) {
$this->markTestSkipped('The apc extension is not available.');
}
Expand Down
Expand Up @@ -13,8 +13,13 @@

use Symfony\Component\ClassLoader\UniversalClassLoader;

class UniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}

/**
* @dataProvider getLoadClassTests
*/
Expand Down
Expand Up @@ -17,8 +17,13 @@
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Output\StreamOutput;

class DialogHelperTest extends \PHPUnit_Framework_TestCase
class LegacyDialogHelperTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}

public function testSelect()
{
$dialog = new DialogHelper();
Expand Down
Expand Up @@ -14,8 +14,13 @@
use Symfony\Component\Console\Helper\ProgressHelper;
use Symfony\Component\Console\Output\StreamOutput;

class ProgressHelperTest extends \PHPUnit_Framework_TestCase
class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}

public function testAdvance()
{
$progress = new ProgressHelper();
Expand Down
Expand Up @@ -14,12 +14,13 @@
use Symfony\Component\Console\Helper\TableHelper;
use Symfony\Component\Console\Output\StreamOutput;

class TableHelperTest extends \PHPUnit_Framework_TestCase
class LegacyTableHelperTest extends \PHPUnit_Framework_TestCase
{
protected $stream;

protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->stream = fopen('php://memory', 'r+');
}

Expand Down
10 changes: 9 additions & 1 deletion src/Symfony/Component/Console/Tests/Input/StringInputTest.php
Expand Up @@ -39,8 +39,16 @@ public function testInputOptionWithGivenString()
$input = new StringInput('--foo=bar');
$input->bind($definition);
$this->assertEquals('bar', $input->getOption('foo'));
}

public function testLegacyInputOptionDefinitionInConstructor()
{
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);

$definition = new InputDefinition(
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
);

// definition in constructor
$input = new StringInput('--foo=bar', $definition);
$this->assertEquals('bar', $input->getOption('foo'));
}
Expand Down

This file was deleted.

This file was deleted.

12 changes: 8 additions & 4 deletions src/Symfony/Component/EventDispatcher/Tests/EventTest.php
Expand Up @@ -60,24 +60,28 @@ public function testStopPropagationAndIsPropagationStopped()
$this->assertTrue($this->event->isPropagationStopped());
}

public function testSetDispatcher()
public function testLegacySetDispatcher()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setDispatcher($this->dispatcher);
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
}

public function testGetDispatcher()
public function testLegacyGetDispatcher()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getDispatcher());
}

public function testGetName()
public function testLegacyGetName()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertNull($this->event->getName());
}

public function testSetName()
public function testLegacySetName()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->event->setName('foo');
$this->assertEquals('foo', $this->event->getName());
}
Expand Down

0 comments on commit 237c315

Please sign in to comment.