Skip to content

Use PHPUnit 6.0 on PHP 7.* test lines #21698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion phpunit
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env php
<?php

// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/d3157d942a4590121dfd23f9cadf519ca6ad4ac7
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/2a45e94c3cde63d8cdfa729e51b80f85b1ab37f6

if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
exit(1);
}
if (PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.0');
}
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Doctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"require-dev": {
"symfony/stopwatch": "~2.2",
"symfony/dependency-injection": "~2.2",
"symfony/form": "~2.7.12|^2.8.5",
"symfony/form": "~2.7.25|^2.8.18",
"symfony/http-kernel": "~2.2",
"symfony/property-access": "~2.3",
"symfony/security": "~2.2",
"symfony/expression-language": "~2.2",
"symfony/validator": "^2.5.5",
"symfony/validator": "~2.7.25|^2.8.18",
"symfony/translation": "^2.0.5",
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": "~2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ require_once __DIR__.'/../../bootstrap.php';

@trigger_error('root deprecation', E_USER_DEPRECATED);

eval(<<<'EOPHP'
namespace PHPUnit\Util;

class Test
{
public static function getGroups()
{
return array();
}
}
EOPHP
);

class PHPUnit_Util_Test
{
public static function getGroups()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require-dev": {
"symfony/asset": "~2.7",
"symfony/finder": "~2.3",
"symfony/form": "~2.7.23|^2.8.16",
"symfony/form": "~2.7.25|^2.8.18",
"symfony/http-kernel": "~2.3",
"symfony/intl": "~2.3",
"symfony/routing": "~2.2",
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"symfony/event-dispatcher": "~2.5",
"symfony/finder": "^2.0.5",
"symfony/http-foundation": "~2.7",
"symfony/http-kernel": "~2.7.23|^2.8.16",
"symfony/http-kernel": "~2.7.25|^2.8.18",
"symfony/filesystem": "~2.3",
"symfony/routing": "~2.7.24|^2.8.17",
"symfony/security-core": "~2.6.13|~2.7.9|~2.8",
Expand All @@ -40,7 +40,7 @@
"symfony/dom-crawler": "^2.0.5",
"symfony/intl": "~2.3",
"symfony/security": "~2.6",
"symfony/form": "~2.7.23|^2.8.16",
"symfony/form": "~2.7.25|^2.8.18",
"symfony/class-loader": "~2.1",
"symfony/expression-language": "~2.6",
"symfony/process": "^2.0.5",
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Bundle/SecurityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
"php": ">=5.3.9",
"symfony/security": "~2.7",
"symfony/security-acl": "~2.7",
"symfony/http-kernel": "~2.2"
"symfony/http-kernel": "~2.7"
},
"require-dev": {
"symfony/browser-kit": "~2.4",
"symfony/console": "~2.7",
"symfony/css-selector": "^2.0.5",
"symfony/dependency-injection": "^2.6.6",
"symfony/dom-crawler": "^2.0.5",
"symfony/form": "~2.7",
"symfony/framework-bundle": "~2.7",
"symfony/http-foundation": "~2.3",
"symfony/form": "~2.7.15|^2.8.8",
"symfony/framework-bundle": "~2.7.25|^2.8.18",
"symfony/http-foundation": "~2.7",
"symfony/twig-bundle": "~2.7",
"symfony/twig-bridge": "^2.7.4",
"symfony/process": "^2.0.5",
Expand Down
121 changes: 117 additions & 4 deletions src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Symfony\Component\Console\Tests\Logger;

use Psr\Log\Test\LoggerInterfaceTest;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Tests\Fixtures\DummyOutput;
Expand All @@ -21,16 +22,17 @@
* Console logger test.
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ConsoleLoggerTest extends LoggerInterfaceTest
class ConsoleLoggerTest extends TestCase
{
/**
* @var DummyOutput
*/
protected $output;

/**
* {@inheritdoc}
* @return LoggerInterface
*/
public function getLogger()
{
Expand All @@ -49,10 +51,121 @@ public function getLogger()
}

/**
* {@inheritdoc}
* Return the log messages in order.
*
* @return string[]
*/
public function getLogs()
{
return $this->output->getLogs();
}

public function testImplements()
{
$this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
}

/**
* @dataProvider provideLevelsAndMessages
*/
public function testLogsAtAllLevels($level, $message)
{
$logger = $this->getLogger();
$logger->{$level}($message, array('user' => 'Bob'));
$logger->log($level, $message, array('user' => 'Bob'));

$expected = array(
$level.' message of level '.$level.' with context: Bob',
$level.' message of level '.$level.' with context: Bob',
);
$this->assertEquals($expected, $this->getLogs());
}

public function provideLevelsAndMessages()
{
return array(
LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
);
}

/**
* @expectedException \Psr\Log\InvalidArgumentException
*/
public function testThrowsOnInvalidLevel()
{
$logger = $this->getLogger();
$logger->log('invalid level', 'Foo');
}

public function testContextReplacement()
{
$logger = $this->getLogger();
$logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));

$expected = array('info {Message {nothing} Bob Bar a}');
$this->assertEquals($expected, $this->getLogs());
}

public function testObjectCastToString()
{
if (method_exists($this, 'createPartialMock')) {
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
} else {
$dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
}
$dummy->expects($this->once())
->method('__toString')
->will($this->returnValue('DUMMY'));

$this->getLogger()->warning($dummy);

$expected = array('warning DUMMY');
$this->assertEquals($expected, $this->getLogs());
}

public function testContextCanContainAnything()
{
$context = array(
'bool' => true,
'null' => null,
'string' => 'Foo',
'int' => 0,
'float' => 0.5,
'nested' => array('with object' => new DummyTest()),
'object' => new \DateTime(),
'resource' => fopen('php://memory', 'r'),
);

$this->getLogger()->warning('Crazy context data', $context);

$expected = array('warning Crazy context data');
$this->assertEquals($expected, $this->getLogs());
}

public function testContextExceptionKeyCanBeExceptionOrOtherValues()
{
$logger = $this->getLogger();
$logger->warning('Random message', array('exception' => 'oops'));
$logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));

$expected = array(
'warning Random message',
'critical Uncaught Exception!',
);
$this->assertEquals($expected, $this->getLogs());
}
}

class DummyTest
{
public function __toString()
{
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"require": {
"php": ">=5.3.9",
"symfony/event-dispatcher": "~2.1",
"symfony/intl": "~2.4",
"symfony/intl": "~2.7.25|^2.8.18",
"symfony/options-resolver": "~2.6",
"symfony/property-access": "~2.3"
},
"require-dev": {
"doctrine/collections": "~1.0",
"symfony/validator": "^2.6.8",
"symfony/validator": "~2.7.25|^2.8.18",
"symfony/http-foundation": "~2.2",
"symfony/http-kernel": "~2.4",
"symfony/security-csrf": "~2.4",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Locale/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.9",
"symfony/intl": "~2.7"
"symfony/intl": "~2.7.25|^2.8.18"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Locale\\": "" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
}
}

public function provideTranslationFiles()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Security/Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"symfony/event-dispatcher": "~2.1",
"symfony/expression-language": "~2.6",
"symfony/http-foundation": "~2.4",
"symfony/validator": "^2.5.9",
"symfony/validator": "~2.7.25|^2.8.18",
"psr/log": "~1.0",
"ircmaxell/password-compat": "1.0.*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Security/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"symfony/finder": "~2.3",
"symfony/intl": "~2.3",
"symfony/routing": "~2.2",
"symfony/validator": "^2.5.9",
"symfony/validator": "~2.7.25|^2.8.18",
"doctrine/common": "~2.2",
"doctrine/dbal": "~2.2",
"psr/log": "~1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Translation/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"require-dev": {
"symfony/config": "~2.7",
"symfony/intl": "~2.4",
"symfony/intl": "~2.7.25|^2.8.18",
"symfony/yaml": "~2.2",
"psr/log": "~1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require-dev": {
"doctrine/common": "~2.3",
"symfony/http-foundation": "~2.3",
"symfony/intl": "~2.7.4|~2.8",
"symfony/intl": "~2.7.25|^2.8.18",
"symfony/yaml": "^2.0.5",
"symfony/config": "~2.2",
"symfony/property-access": "~2.3",
Expand Down