Use PHPUnit 6.0 on PHP 7.* test lines
This commit is contained in:
parent
c55b7349ae
commit
96ecd3c798
5
phpunit
5
phpunit
@ -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';
|
||||
|
@ -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",
|
||||
|
@ -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()
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
@ -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",
|
||||
|
@ -19,7 +19,7 @@
|
||||
"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",
|
||||
@ -27,9 +27,9 @@
|
||||
"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",
|
||||
|
@ -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;
|
||||
@ -21,8 +22,9 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
* 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
|
||||
@ -30,7 +32,7 @@ class ConsoleLoggerTest extends LoggerInterfaceTest
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
@ -49,10 +51,121 @@ class ConsoleLoggerTest extends LoggerInterfaceTest
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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\\": "" },
|
||||
|
@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
|
||||
*/
|
||||
public function testTranslationFileIsValid($filePath)
|
||||
{
|
||||
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()
|
||||
|
@ -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.*"
|
||||
},
|
||||
|
@ -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",
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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",
|
||||
|
Reference in New Issue
Block a user