8000 Merge branch '3.2' · symfony/symfony@4c95d19 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c95d19

Browse files
Merge branch '3.2'
* 3.2: Use PHPUnit 6.0 on PHP 7.* test lines
2 parents 3064fac + 442cf59 commit 4c95d19

File tree

16 files changed

+183
-18
lines changed

16 files changed

+183
-18
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
@@ -23,14 +23,14 @@
2323
"require-dev": {
2424
"symfony/stopwatch": "~2.8|~3.0",
2525
"symfony/dependency-injection": "~3.3",
26-
"symfony/form": "^3.0.5",
26+
"symfony/form": "^3.2.5",
2727
"symfony/http-kernel": "~2.8|~3.0",
2828
"symfony/property-access": "~2.8|~3.0",
2929
"symfony/property-info": "~2.8|3.0",
3030
"symfony/proxy-manager-bridge": "~2.8|~3.0",
3131
"symfony/security": "~2.8|~3.0",
3232
"symfony/expression-language": "~2.8|~3.0",
33-
"symfony/validator": "~2.8|~3.0",
33+
"symfony/validator": "^2.8.18|^3.2.5",
3434
"symfony/translation": "~2.8|~3.0",
3535
"doctrine/data-fixtures": "1.0.*",
3636
"doctrine/dbal": "~2.4",

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ class Test
3131
EOPHP
3232
);
3333

34+
class PHPUnit_Util_Test
35+
{
36+
public static function getGroups()
37+
{
38+
return array();
39+
}
40+
}
41+
3442
class FooTestCase
3543
{
3644
public function testLegacyFoo()

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.8|~3.0",
2424
"symfony/finder": "~2.8|~3.0",
25-
"symfony/form": "~3.1.9|^3.2.2",
25+
"symfony/form": "^3.2.5",
2626
"symfony/http-kernel": "~3.2",
2727
"symfony/polyfill-intl-icu": "~1.0",
2828
"symfony/routing": "~2.8|~3.0",

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"symfony/css-selector": "~2.8|~3.0",
3030
"symfony/dom-crawler": "~2.8|~3.0",
3131
"symfony/form": "~2.8|~3.0",
32-
"symfony/framework-bundle": "~3.1",
< EF5E /td>32+
"symfony/framework-bundle": "^3.2.5",
3333
"symfony/http-foundation": "~2.8|~3.0",
3434
"symfony/security-acl": "~2.8|~3.0",
3535
"symfony/twig-bundle": "~2.8|~3.0",

src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313

1414
use Cache\IntegrationTests\CachePoolTest;
1515

16+
if (!class_exists('PHPUnit_Framework_TestCase')) {
17+
abstract class AdapterTestCase
18+
{
19+
public static function setUpBeforeClass()
20+
{
21+
self::markTestSkipped('cache/integration-tests is not yet compatible with namespaced phpunit versions.');
22+
}
23+
}
24+
25+
return;
26+
}
27+
1628
abstract class AdapterTestCase extends CachePoolTest
1729
{
1830
protected function setUp()

src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php

Lines changed: 12 additions & 0 deletions
27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313

1414
use Cache\IntegrationTests\SimpleCacheTest;
1515

16+
if (!class_exists('PHPUnit_Framework_TestCase')) {
17+
abstract class CacheTestCase
18+
{
19+
public static function setUpBeforeClass()
20+
{
21+
self::markTestSkipped('cache/integration-tests is not yet compatible with namespaced phpunit versions.');
22+
}
23+
}
24+
25+
return;
26+
}
+
1628
abstract class CacheTestCase extends SimpleCacheTest
1729
{
1830
public function testDefaultLifeTime()

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\Output\BufferedOutput;
@@ -22,16 +23,17 @@
2223
* Console logger test.
2324
*
2425
* @author Kévin Dunglas <dunglas@gmail.com>
26+
* @author Jordi Boggiano <j.boggiano@seld.be>
2527
*/
26-
class ConsoleLoggerTest extends LoggerInterfaceTest
28+
class ConsoleLoggerTest extends TestCase
2729
{
2830
/**
2931
* @var DummyOutput
3032
*/
3133
protected $output;
3234

3335
/**
34-
* {@inheritdoc}
36+
* @return LoggerInterface
3537
*/
3638
public function getLogger()
3739
{
@@ -50,7 +52,9 @@ public function getLogger()
5052
}
5153

5254
/**
53-
* {@inheritdoc}
55+
* Return the log messages in order.
56+
*
57+
* @return string[]
5458
*/
5559
public function getLogs()
5660
{
@@ -101,4 +105,113 @@ public function testHasErrored()
101105
$logger->error('bar');
102106
$this->assertTrue($logger->hasErrored());
103107
}
108+
109+
public function testImplements()
110+
{
111+
$this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
112+
}
113+
114+
/**
115+
* @dataProvider provideLevelsAndMessages
116+
*/
117+
public function testLogsAtAllLevels($level, $message)
118+
{
119+
$logger = $this->getLogger();
120+
$logger->{$level}($message, array('user' => 'Bob'));
121+
$logger->log($level, $message, array('user' => 'Bob'));
122+
123+
$expected = array(
124+
$level.' message of level '.$level.' with context: Bob',
125+
$level.' message of level '.$level.' with context: Bob',
126+
);
127+
$this->assertEquals($expected, $this->getLogs());
128+
}
129+
130+
public function provideLevelsAndMessages()
131+
{
132+
return array(
133+
LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
134+
LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
135+
LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
136+
LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
137+
LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
138+
LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
139+
LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
140+
LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
141+
);
142+
}
143+
144+
/**
145+
* @expectedException \Psr\Log\InvalidArgumentException
146+
*/
147+
public function testThrowsOnInvalidLevel()
148+
{
149+
$logger = $this->getLogger();
150+
$logger->log('invalid level', 'Foo');
151+
}
152+
153+
public function testContextReplacement()
154+
{
155+
$logger = $this->getLogger();
156+
$logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
157+
158+
$expected = array('info {Message {nothing} Bob Bar a}');
159+
$this->assertEquals($expected, $this->getLogs());
160+
}
161+
162+
public function testObjectCastToString()
163+
{
164+
if (method_exists($this, 'createPartialMock')) {
165+
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
166+
} else {
167+
$dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
168+
}
169+
$dummy->expects($this->once())
170+
->method('__toString')
171+
->will($this->returnValue('DUMMY'));
172+
173+
$this->getLogger()->warning($dummy);
174+
175+
$expected = array('warning DUMMY');
176+
$this->assertEquals($expected, $this->getLogs());
177+
}
178+
179+
public function testContextCanContainAnything()
180+
{
181+
$context = array(
182+
'bool' => true,
183+
'null' => null,
184+
'string' => 'Foo',
185+
'int' =& 10000 gt; 0,
186+
'float' => 0.5,
187+
'nested' => array('with object' => new DummyTest()),
188+
'object' => new \DateTime(),
189+
'resource' => fopen('php://memory', 'r'),
190+
);
191+
192+
$this->getLogger()->warning('Crazy context data', $context);
193+
194+
$expected = array('warning Crazy context data');
195+
$this->assertEquals($expected, $this->getLogs());
196+
}
197+
198+
public function testContextExceptionKeyCanBeExceptionOrOtherValues()
199+
{
200+
$logger = $this->getLogger();
201+
$logger->warning('Random message', array('exception' => 'oops'));
202+
$logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
203+
204+
$expected = array(
205+
'warning Random message',
206+
'critical Uncaught Exception!',
207+
);
208+
$this->assertEquals($expected, $this->getLogs());
209+
}
210+
}
211+
212+
class DummyTest
213+
{
214+
public function __toString()
215+
{
216+
}
104217
}

src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ public function testPrivateTaggedServices($id, $tagName, $expectedExceptionMessa
195195
$container->setDefinition('form.extension', $extDefinition);
196196
$container->register($id, 'stdClass')->setPublic(false)->addTag($tagName);
197197

198-
$this->setExpectedException('\InvalidArgumentException', $expectedExceptionMessage);
198+
if (method_exists($this, 'expectException')) {
199+
$this->expectException('InvalidArgumentException');
200+
$this->expectExceptionMessage($expectedExceptionMessage);
201+
} else {
202+
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
203+
}
199204

200205
$container->compile();
201206
}

src/Symfony/Component/Form/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/event-dispatcher": "~2.8|~3.0",
21-
"symfony/intl": "~2.8|~3.0",
21+
"symfony/intl": "^2.8.18|^3.2.5",
2222
"symfony/options-resolver": "~2.8|~3.0",
2323
"symfony/polyfill-mbstring": "~1.0",
2424
"symfony/property-access": "~2.8|~3.0"
2525
},
2626
"require-dev": {
2727
"doctrine/collections": "~1.0",
28-
"symfony/validator": "~2.8|~3.0",
28+
"symfony/validator": "^2.8.18|^3.2.5",
2929
"symfony/dependency-injection": "~3.2",
3030
"symfony/config": "~2.7|~3.0",
3131
"symfony/http-foundation": "~2.8|~3.0",

0 commit comments

Comments
 (0)
0