Skip to content

Commit

Permalink
Merge branch '3.4' into 4.2
Browse files Browse the repository at this point in the history
* 3.4:
  [Serializer] Respect ignored attributes in cache key of normalizer
  fix resetting the COLUMN environment variable
  Fix TestRunner compatibility to PhpUnit 8
  prevent mixup of the object to populate
  • Loading branch information
xabbuh committed Apr 8, 2019
2 parents 0d786d3 + 7a3060a commit ec41d76
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 208 deletions.
20 changes: 19 additions & 1 deletion src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ class CommandForV5 extends \PHPUnit_TextUI_Command
*/
protected function createRunner()
{
return new TestRunnerForV5($this->arguments['loader']);
$listener = new SymfonyTestsListenerForV5();

$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : array();

$registeredLocally = false;

foreach ($this->arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListenerForV5) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}

if (!$registeredLocally) {
$this->arguments['listeners'][] = $listener;
}

return parent::createRunner();
}
}
22 changes: 20 additions & 2 deletions src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use PHPUnit\TextUI\Command as BaseCommand;
use PHPUnit\TextUI\TestRunner as BaseRunner;
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;

/**
* {@inheritdoc}
Expand All @@ -27,6 +27,24 @@ class CommandForV6 extends BaseCommand
*/
protected function createRunner(): BaseRunner
{
return new TestRunner($this->arguments['loader']);
$listener = new SymfonyTestsListener();

$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];

$registeredLocally = false;

foreach ($this->arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListener) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}

if (!$registeredLocally) {
$this->arguments['listeners'][] = $listener;
}

return parent::createRunner();
}
}
48 changes: 0 additions & 48 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php

This file was deleted.

49 changes: 0 additions & 49 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php

This file was deleted.

49 changes: 0 additions & 49 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php

This file was deleted.

16 changes: 8 additions & 8 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ protected function setUp()
$this->colSize = getenv('COLUMNS');
}

protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
putenv('SHELL_VERBOSITY');
unset($_ENV['SHELL_VERBOSITY']);
unset($_SERVER['SHELL_VERBOSITY']);
}

public static function setUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
Expand Down Expand Up @@ -1749,14 +1757,6 @@ public function testThrowingErrorListener()
$tester = new ApplicationTester($application);
$tester->run(['command' => 'foo']);
}

protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv('SHELL_VERBOSITY');
unset($_ENV['SHELL_VERBOSITY']);
unset($_SERVER['SHELL_VERBOSITY']);
}
}

class CustomApplication extends Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp()

protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
}

public function testMultipleStart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp()

protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
$this->command = null;
$this->tester = null;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Console/Tests/TerminalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ protected function setUp()
$this->lineSize = getenv('LINES');
}

protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
}

public function test()
{
putenv('COLUMNS=100');
Expand All @@ -40,12 +46,6 @@ public function test()
$this->assertSame(60, $terminal->getHeight());
}

protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
}

public function test_zero_values()
{
putenv('COLUMNS=0');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref

return $object;
}
// clean up even if no match
unset($context[static::OBJECT_TO_POPULATE]);

$constructor = $this->getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
if ($constructor) {
Expand Down Expand Up @@ -453,7 +455,7 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
throw new LogicException(sprintf('Cannot create an instance of %s from serialized data because the serializer inject in "%s" is not a denormalizer', $parameter->getClass(), self::class));
}
$parameterClass = $parameter->getClass()->getName();
$parameterData = $this->serializer->denormalize($parameterData, $parameterClass, $format, $this->createChildContext($context, $parameterName));
$parameterData = $this->serializer->denormalize($parameterData, $parameterClass, $format, $this->createChildContext($context, $parameterName, $format));
}
} catch (\ReflectionException $e) {
throw new RuntimeException(sprintf('Could not determine the class of the parameter "%s".', $parameterName), 0, $e);
Expand All @@ -468,14 +470,15 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
}

/**
* @param array $parentContext
* @param string $attribute
* @param array $parentContext
* @param string $attribute Attribute name
* @param string|null $format
*
* @return array
*
* @internal
*/
protected function createChildContext(array $parentContext, $attribute)
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
{
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
Expand Down

0 comments on commit ec41d76

Please sign in to comment.