8000 minor #21698 Use PHPUnit 6.0 on PHP 7.* test lines (nicolas-grekas) · symfony/symfony@9a2122d · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 9a2122d

Browse files
minor #21698 Use PHPUnit 6.0 on PHP 7.* test lines (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- Use PHPUnit 6.0 on PHP 7.* test lines | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | need #21694 first | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 96ecd3c Use PHPUnit 6.0 on PHP 7.* test lines
2 parents c55b734 + 96ecd3c commit 9a2122d

File tree

14 files changed

+155
-22
lines changed

14 files changed

+155
-22
lines changed

phpunit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/usr/bin/env php
22
<?php
33

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

66
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
77
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
88
exit(1);
99
}
10+
if (PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
11+
putenv('SYMFONY_PHPUNIT_VERSION=6.0');
12+
}
1013
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
1114
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
"require-dev": {
2323
"symfony/stopwatch": "~2.2",
2424
"symfony/dependency-injection": "~2.2",
25-
"symfony/form": "~2.7.12|^2.8.5",
25+
"symfony/form": "~2.7.25|^2.8.18",
2626
"symfony/http-kernel": "~2.2",
2727
"symfony/property-access": "~2.3",
2828
"symfony/security": "~2.2",
2929
"symfony/expression-language": "~2.2",
30-
"symfony/validator": "^2.5.5",
30+
"symfony/validator": "~2.7.25|^2.8.18",
3131
"symfony/translation": "^2.0.5",
3232
"doctrine/data-fixtures": "1.0.*",
3333
"doctrine/dbal": "~2.4",

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ require_once __DIR__.'/../../bootstrap.php';
1818

1919
@trigger_error('root deprecation', E_USER_DEPRECATED);
2020

21+
eval(<<<'EOPHP'
22+
namespace PHPUnit\Util;
23+
24+
class Test
25+
{
26+
public static function getGroups()
27+
{
28+
return array();
29+
}
30+
}
31+
EOPHP
32+
);
33+
2134
class PHPUnit_Util_Test
2235
{
2336
public static function getGroups()

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"symfony/asset": "~2.7",
2424
"symfony/finder": "~2.3",
25-
"symfony/form": "~2.7.23|^2.8.16",
25+
"symfony/form": "~2.7.25|^2.8.18",
2626
"symfony/http-kernel": "~2.3",
2727
"symfony/intl": "~2.3",
2828
"symfony/routing": "~2.2",

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/event-dispatcher": "~2.5",
2424
"symfony/finder": "^2.0.5",
2525
"symfony/http-foundation": "~2.7",
26-
"symfony/http-kernel": "~2.7.23|^2.8.16",
26+
"symfony/http-kernel": "~2.7.25|^2.8.18",
2727
"symfony/filesystem": "~2.3",
2828
"symfony/routing": "~2.7.24|^2.8.17",
2929
"symfony/security-core": "~2.6.13|~2.7.9|~2.8",
@@ -40,7 +40,7 @@
4040
"symfony/dom-crawler": "^2.0.5",
4141
"symfony/intl": "~2.3",
4242
"symfony/security": "~2.6",
43-
"symfony/form": "~2.7.23|^2.8.16",
43+
"symfony/form": "~2.7.25|^2.8.18",
4444
"symfony/class-loader": "~2.1",
4545
"symfony/expression-language": "~2.6",
4646
"symfony/process": "^2.0.5",

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
"php": ">=5.3.9",
2020
"symfony/security": "~2.7",
2121
"symfony/security-acl": "~2.7",
22-
"symfony/http-kernel": "~2.2"
22+
"symfony/http-kernel": "~2.7"
2323
},
2424
"require-dev": {
2525
"symfony/browser-kit": "~2.4",
2626
"symfony/console": "~2.7",
2727
"symfony/css-selector": "^2.0.5",
2828
"symfony/dependency-injection": "^2.6.6",
2929
"symfony/dom-crawler": "^2.0.5",
30-
"symfony/form": "~2.7",
31-
"symfony/framework-bundle": "~2.7",
32-
"symfony/http-foundation": "~2.3",
30+
"symfony/form": "~2.7.15|^2.8.8",
31+
"symfony/framework-bundle": "~2.7.25|^2.8.18",
32+
"symfony/http-foundation": "~2.7",
3333
"symfony/twig-bundle": "~2.7",
3434
"symfony/twig-bridge": "^2.7.4",
3535
"symfony/process": "^2.0.5",

src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace Symfony\Component\Console\Tests\Logger;
1313

14-
use Psr\Log\Test\LoggerInterfaceTest;
14+
use PHPUnit\Framework\TestCase;
15+
use Psr\Log\LoggerInterface;
1516
use Psr\Log\LogLevel;
1617
use Symfony\Component\Console\Logger\ConsoleLogger;
1718
use Symfony\Component\Console\Tests\Fixtures\DummyOutput;
@@ -21,16 +22,17 @@
2122
* Console logger test.
2223
*
2324
* @author Kévin Dunglas <dunglas@gmail.com>
25+
* @author Jordi Boggiano <j.boggiano@seld.be>
2426
*/
25-
class ConsoleLoggerTest extends LoggerInterfaceTest
27+
class ConsoleLoggerTest extends TestCase
2628
{
2729
/**
2830
* @var DummyOutput
2931
*/
3032
protected $output;
3133

3234
/**
33-
* {@inheritdoc}
35+
* @return LoggerInterface
3436
*/
3537
public function getLogger()
3638
{
@@ -49,10 +51,121 @@ public function getLogger()
4951
}
5052

5153
/**
52-
* {@inheritdoc}
54+
* Return the log messages in order.
55+
*
56+
* @return string[]
5357
*/
5458
public function getLogs()
5559
{
5660
return $this->output->getLogs();
5761
}
62+
63+
public function testImplements()
64+
{
65+
$this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
66+
}
67+
68+
/**
69+
* @dataProvider provideLevelsAndMessages
70+
*/
71+
public function testLogsAtAllLevels($level, $message)
72+
{
73+
$logger = $this->getLogger();
74+
$logger->{$level}($message, array('user' => 'Bob'));
75+
$logger->log($level, $message, array('user' => 'Bob'));
76+
77+
$expected = array(
78+
$level.' message of level '.$level.' with context: Bob',
79+
$level.' message of level '.$level.' with context: Bob',
80+
);
81+
$this->assertEquals($expected, $this->getLogs());
82+
}
83+
84+
public function provideLevelsAndMessages()
85+
{
86+
return array(
87+
LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
88+
LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
89+
LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
90+
LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
91+
LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
92+
LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
93+
LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
94+
LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
95+
);
96+
}
97+
98+
/**
99+
* @expectedException \Psr\Log\InvalidArgumentException
100+
*/
101+
public function testThrowsOnInvalidLevel()
102+
{
103+
$logger = $this->getLogger();
104+
$logger->log('invalid level', 'Foo');
105+
}
106+
107+
public function testContextReplacement()
108+
{
109+
$logger = $this->getLogger();
110+
$logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
111+
112+
$expected = array('info {Message {nothing} Bob Bar a}');
113+
$this->assertEquals($expected, $this->getLogs());
114+
}
115+
116+
public function testObjectCastToString()
117+
{
118+
if (method_exists($this, 'createPartialMock')) {
119+
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
120+
} else {
121+
$dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
122+
}
123+
$dummy->expects($this->once())
124+
->method('__toString')
125+
->will($this->returnValue('DUMMY'));
126+
127+
$this->getLogger()->warning($dummy);
128+
129+
$expected = array('warning DUMMY');
130+
$this->assertEquals($expected, $this->getLogs());
131+
}
132+
133+
public function testContextCanContainAnything()
134+
{
135+
$context = array(
136+
'bool' => true,
137+
'null' => null,
138+
'string' => 'Foo',
139+
'int' => 0,
140+
'float' => 0.5,
141+
'nested' => array('with object' => new DummyTest()),
142+
'object' => new \DateTime(),
143+
'resource' => fopen('php://memory', 'r'),
144+
);
145+
146+
$this->getLogger()->warning('Crazy context data', $context);
147+
148+
$expected = array('warning Crazy context data');
149+
$this->assertEquals($expected, $this->getLogs());
150+
}
151+
152+
public function testContextExceptionKeyCanBeExceptionOrOtherValues()
153+
{
154+
$logger = $this->getLogger();
155+
$logger->warning('Random message', array('exception' => 'oops'));< 10000 /div>
156+
$logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
157+
158+
$expected = array(
159+
'warning Random message',
160+
'critical Uncaught Exception!',
161+
);
162+
$this->assertEquals($expected, $this->getLogs());
163+
}
164+
}
165+
166+
class DummyTest
167+
{
168+
public function __toString()
169+
{
170+
}
58171
}

src/Symfony/Component/Form/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
"require": {
1919
"php": ">=5.3.9",
2020
"symfony/event-dispatcher": "~2.1",
21-
"symfony/intl": "~2.4",
21+
"symfony/intl": "~2.7.25|^2.8.18",
2222
"symfony/options-resolver": "~2.6",
2323
"symfony/property-access": "~2.3"
2424
},
2525
"require-dev": {
2626
"doctrine/collections": "~1.0",
27-
"symfony/validator": "^2.6.8",
27+
"symfony/validator": "~2.7.25|^2.8.18",
2828
"symfony/http-foundation": "~2.2",
2929
"symfony/http-kernel": "~2.4",
3030
"symfony/security-csrf": "~2.4",

src/Symfony/Component/Locale/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.3.9",
20-
"symfony/intl": "~2.7"
20+
"symfony/intl": "~2.7.25|^2.8.18"
2121
},
2222
"autoload": {
2323
"psr-4": { "Symfony\\Component\\Locale\\": "" },

src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class TranslationFilesTest extends TestCase
2020
*/
2121
public function testTranslationFileIsValid($filePath)
2222
{
23-
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
23+
if (class_exists('PHPUnit_Util_XML')) {
24+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
25+
} else {
26+
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
27+
}
2428
}
2529

2630
public function provideTranslationFiles()

src/Symfony/Component/Security/Core/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/event-dispatcher": "~2.1",
2424
"symfony/expression-language": "~2.6",
2525
"symfony/http-foundation": "~2.4",
26-
"symfony/validator": "^2.5.9",
26+
"symfony/validator": "~2.7.25|^2.8.18",
2727
"psr/log": "~1.0",
2828
"ircmaxell/password-compat": "1.0.*"
2929
},

src/Symfony/Component/Security/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"symfony/finder": "~2.3",
3333
"symfony/intl": "~2.3",
3434
"symfony/routing": "~2.2",
35-
"symfony/validator": "^2.5.9",
35+
"symfony/validator": "~2.7.25|^2.8.18",
3636
"doctrine/common": "~2.2",
3737
"doctrine/dbal": "~2.2",
3838
"psr/log": "~1.0",

src/Symfony/Component/Translation/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"require-dev": {
2222
"symfony/config": "~2.7",
23-
"symfony/intl": "~2.4",
23+
"symfony/intl": "~2.7.25|^2.8.18",
2424
"symfony/yaml": "~2.2",
2525
"psr/log": "~1.0"
2626
},

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"doctrine/common": "~2.3",
2424
"symfony/http-foundation": "~2.3",
25-
"symfony/intl": "~2.7.4|~2.8",
25+
"symfony/intl": "~2.7.25|^2.8.18",
2626
"symfony/yaml": "^2.0.5",
2727
"symfony/config": "~2.2",
2828
"symfony/property-access": "~2.3",

0 commit comments

Comments
 (0)
0