Merge branch '2.8' into 3.2

* 2.8:
  Use PHPUnit 6.0 on PHP 7.* test lines
This commit is contained in:
Nicolas Grekas 2017-02-21 15:41:00 +01:00
commit 442cf595be
16 changed files with 174 additions and 20 deletions

View File

@ -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';

View File

@ -23,14 +23,14 @@
"require-dev": {
"symfony/stopwatch": "~2.8|~3.0",
"symfony/dependency-injection": "~2.8|~3.0",
"symfony/form": "^3.0.5",
"symfony/form": "^3.2.5",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/property-access": "~2.8|~3.0",
"symfony/property-info": "~2.8|3.0",
"symfony/proxy-manager-bridge": "~2.8|~3.0",
"symfony/security": "~2.8|~3.0",
"symfony/expression-language": "~2.8|~3.0",
"symfony/validator": "~2.8|~3.0",
"symfony/validator": "^2.8.18|^3.2.5",
"symfony/translation": "~2.8|~3.0",
"doctrine/data-fixtures": "1.0.*",
"doctrine/dbal": "~2.4",

View File

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

View File

@ -11,9 +11,10 @@
namespace Symfony\Bridge\PhpUnit\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\DnsMock;
class DnsMockTest extends \PHPUnit_Framework_TestCase
class DnsMockTest extends TestCase
{
protected function tearDown()
{

View File

@ -22,7 +22,7 @@
"require-dev": {
"symfony/asset": "~2.8|~3.0",
"symfony/finder": "~2.8|~3.0",
"symfony/form": "~3.1.9|^3.2.2",
"symfony/form": "^3.2.5",
"symfony/http-kernel": "~3.2",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/routing": "~2.8|~3.0",

View File

@ -23,7 +23,7 @@
"symfony/config": "~2.8|~3.0",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/http-foundation": "~3.1",
"symfony/http-kernel": "~3.2.2|~3.3",
"symfony/http-kernel": "^3.2.5",
"symfony/polyfill-mbstring": "~1.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/finder": "~2.8|~3.0",
@ -41,7 +41,7 @@
"symfony/dom-crawler": "~2.8|~3.0",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/security": "~2.8|~3.0",
"symfony/form": "~2.8.16|~3.1.9|^3.2.2",
"symfony/form": "^2.8.18|^3.2.5",
"symfony/expression-language": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0",
"symfony/security-core": "~3.2",

View File

@ -28,7 +28,7 @@
"symfony/css-selector": "~2.8|~3.0",
"symfony/dom-crawler": "~2.8|~3.0",
"symfony/form": "~2.8|~3.0",
"symfony/framework-bundle": "~3.1",
"symfony/framework-bundle": "^3.2.5",
"symfony/http-foundation": "~2.8|~3.0",
"symfony/security-acl": "~2.8|~3.0",
"symfony/templating": "~2.8|~3.0",

View File

@ -13,6 +13,18 @@ namespace Symfony\Component\Cache\Tests\Adapter;
use Cache\IntegrationTests\CachePoolTest;
if (!class_exists('PHPUnit_Framework_TestCase')) {
abstract class AdapterTestCase
{
public static function setUpBeforeClass()
{
self::markTestSkipped('cache/integration-tests is not yet compatible with namespaced phpunit versions.');
}
}
return;
}
abstract class AdapterTestCase extends CachePoolTest
{
protected function setUp()

View File

@ -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\Output\BufferedOutput;
@ -22,8 +23,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
@ -31,7 +33,7 @@ class ConsoleLoggerTest extends LoggerInterfaceTest
protected $output;
/**
* {@inheritdoc}
* @return LoggerInterface
*/
public function getLogger()
{
@ -50,7 +52,9 @@ class ConsoleLoggerTest extends LoggerInterfaceTest
}
/**
* {@inheritdoc}
* Return the log messages in order.
*
* @return string[]
*/
public function getLogs()
{
@ -101,4 +105,113 @@ class ConsoleLoggerTest extends LoggerInterfaceTest
$logger->error('bar');
$this->assertTrue($logger->hasErrored());
}
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()
{
}
}

View File

@ -18,14 +18,14 @@
"require": {
"php": ">=5.5.9",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/intl": "~2.8|~3.0",
"symfony/intl": "^2.8.18|^3.2.5",
"symfony/options-resolver": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/property-access": "~2.8|~3.0"
},
"require-dev": {
"doctrine/collections": "~1.0",
"symfony/validator": "~2.8|~3.0",
"symfony/validator": "^2.8.18|^3.2.5",
"symfony/dependency-injection": "~2.8|~3.0",
"symfony/http-foundation": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",

View File

@ -25,7 +25,7 @@
"symfony/expression-language": "~2.8|~3.0",
"symfony/http-foundation": "~2.8|~3.0",
"symfony/ldap": "~3.1",
"symfony/validator": "~2.8|~3.0",
"symfony/validator": "^2.8.18|^3.2.5",
"psr/log": "~1.0"
},
"suggest": {

View File

@ -35,7 +35,7 @@
"symfony/finder": "~2.8|~3.0",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/routing": "~2.8|~3.0",
"symfony/validator": "~2.8|~3.0",
"symfony/validator": "^2.8.18|^3.2.5",
"symfony/expression-language": "~2.8|~3.0",
"symfony/ldap": "~3.1",
"psr/log": "~1.0"

View File

@ -21,7 +21,7 @@
},
"require-dev": {
"symfony/config": "~2.8|~3.0",
"symfony/intl": "~2.8|~3.0",
"symfony/intl": "^2.8.18|^3.2.5",
"symfony/yaml": "~2.8|~3.0",
"psr/log": "~1.0"
},

View File

@ -22,7 +22,7 @@
},
"require-dev": {
"symfony/http-foundation": "~2.8|~3.0",
"symfony/intl": "~2.8|~3.0",
"symfony/intl": "^2.8.18|^3.2.5",
"symfony/yaml": "~2.8|~3.0",
"symfony/config": "~2.8|~3.0",
"symfony/expression-language": "~2.8|~3.0",

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Inline;
use Symfony\Component\Yaml\Yaml;
@ -651,10 +652,15 @@ class InlineTest extends TestCase
/**
* @dataProvider getInvalidBinaryData
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testParseInvalidBinaryData($data, $expectedMessage)
{
$this->setExpectedExceptionRegExp('\Symfony\Component\Yaml\Exception\ParseException', $expectedMessage);
if (method_exists($this, 'expectException')) {
$this->expectExceptionMessageRegExp($expectedMessage);
} else {
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
}
Inline::parse($data);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Parser;
@ -1314,10 +1315,15 @@ EOT
/**
* @dataProvider getInvalidBinaryData
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testParseInvalidBinaryData($data, $expectedMessage)
{
$this->setExpectedExceptionRegExp('\Symfony\Component\Yaml\Exception\ParseException', $expectedMessage);
if (method_exists($this, 'expectException')) {
$this->expectExceptionMessageRegExp($expectedMessage);
} else {
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
}
$this->parser->parse($data);
}