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

Skip to content

Commit 398d78d

Browse files
Merge branch '3.2'
* 3.2: [Cache] cache/integration-tests is now compatible with phpunit namespaces [FrameworkBundle] Fix translation dep constraint [Workflow] Added more tests [Cache] Enhance error reporting for FilesystemAdapter
2 parents eb6f3f7 + ce55ce7 commit 398d78d

File tree

9 files changed

+65
-41
lines changed

9 files changed

+65
-41
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"symfony/yaml": "self.version"
8282
},
8383
"require-dev": {
84-
"cache/integration-tests": "^0.15.0",
84+
"cache/integration-tests": "dev-master",
8585
"doctrine/cache": "~1.6",
8686
"doctrine/data-fixtures": "1.0.*",
8787
"doctrine/dbal": "~2.4",

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ public function testGetDefaultLocale()
136136
$this->assertSame('en', $translator->getLocale());
137137
}
138138

139+
/**
140+
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
141+
* @expectedExceptionMessage The Translator does not support the following options: 'foo'
142+
*/
143+
public function testInvalidOptions()
144+
{
145+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
146+
147+
(new Translator($container, new MessageSelector(), array(), array('foo' => 'bar')));
148+
}
149+
139150
protected function getCatalogue($locale, $messages, $resources = array())
140151
{
141152
$catalogue = new MessageCatalogue($locale);

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"symfony/security-core": "~3.2",
4848
"symfony/security-csrf": "~2.8|~3.0",
4949
"symfony/serializer": "~3.3",
50-
"symfony/translation": "~2.8|~3.0",
50+
"symfony/translation": "~3.2",
5151
"symfony/templating": "~2.8|~3.0",
5252
"symfony/validator": "~3.3",
5353
"symfony/yaml": "~3.2",
@@ -63,9 +63,10 @@
6363
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
6464
"symfony/asset": "<3.3",
6565
"symfony/console": "<3.3",
66-
"symfony/serializer": "<3.3",
6766
"symfony/form": "<3.3",
6867
"symfony/property-info": "<3.3",
68+
"symfony/serializer": "<3.3",
69+
"symfony/translations": "<3.2",
6970
"symfony/validator": "<3.3"
7071
},
7172
"suggest": {

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
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-
2816
abstract class AdapterTestCase extends CachePoolTest
2917
{
3018
protected function setUp()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PredisClusterAdapterTest extends AbstractRedisAdapterTest
1616
public static function setupBeforeClass()
1717
{
1818
parent::setupBeforeClass();
19-
self::$redis = new \Predis\Client(array(getenv('REDIS_HOST')));
19+
self::$redis = new \Predis\Client(array(array('host' => getenv('REDIS_HOST'))));
2020
}
2121

2222
public static function tearDownAfterClass()

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
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-
}
27-
2816
abstract class CacheTestCase extends SimpleCacheTest
2917
{
3018
public function testDefaultLifeTime()

src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ private function init($namespace, $directory)
4747
}
4848

4949
$this->directory = $dir;
50-
$this->tmp = $this->directory.uniqid('', true);
5150
}
5251

5352
/**
@@ -81,19 +80,21 @@ protected function doDelete(array $ids)
8180

8281
private function write($file, $data, $expiresAt = null)
8382
{
84-
if (false === @file_put_contents($this->tmp, $data)) {
85-
return false;
86-
}
87-
if (null !== $expiresAt) {
88-
@touch($this->tmp, $expiresAt);
89-
}
83+
set_error_handler(__CLASS__.'::throwError');
84+
try {
85+
if (null === $this->tmp) {
86+
$this->tmp = $this->directory.uniqid('', true);
87+
}
88+
file_put_contents($this->tmp, $data);
9089

91-
if (@rename($this->tmp, $file)) {
92-
return true;
93-
}
94-
@unlink($this->tmp);
90+
if (null !== $expiresAt) {
91+
touch($this->tmp, $expiresAt);
92+
}
9593

96-
return false;
94+
return rename($this->tmp, $file);
95+
} finally {
96+
restore_error_handler();
97+
}
9798
}
9899

99100
private function getFile($id, $mkdir = false)
@@ -107,4 +108,22 @@ private function getFile($id, $mkdir = false)
107108

108109
return $dir.substr($hash, 2, 20);
109110
}
111+
112+
/**
113+
* @internal
114+
*/
115+
public static function throwError($type, $message, $file, $line)
116+
{
117+
throw new \ErrorException($message, 0, $type, $file, $line);
118+
}
119+
120+
public function __destruct()
121+
{
122+
if (method_exists(parent::class, '__destruct')) {
123+
parent::__destruct();
124+
}
125+
if (null !== $this->tmp && file_exists($this->tmp)) {
126+
unlink($this->tmp);
127+
}
128+
}
110129
}

src/Symfony/Component/Cache/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"psr/simple-cache": "^1.0"
2727
},
2828
"require-dev": {
29-
"cache/integration-tests": "^0.15.0",
29+
"cache/integration-tests": "dev-master",
3030
"doctrine/cache": "~1.6",
3131
"doctrine/dbal": "~2.4",
3232
"predis/predis": "~1.0"

src/Symfony/Component/Workflow/Tests/WorkflowTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ public function testCan()
104104

105105
$this->assertTrue($workflow->can($subject, 't1'));
106106
$this->assertFalse($workflow->can($subject, 't2'));
107+
108+
$subject->marking = array('b' => 1);
109+
110+
$this->assertFalse($workflow->can($subject, 't1'));
111+
// In a workflow net, all "from" places should contain a token to enable
112+
// the transition.
113+
$this->assertFalse($workflow->can($subject, 't2'));
114+
115+
$subject->marking = array('b' => 1, 'c' => 1);
116+
117+
$this->assertFalse($workflow->can($subject, 't1'));
118+
$this->assertTrue($workflow->can($subject, 't2'));
119+
120+
$subject->marking = array('f' => 1);
121+
122+
$this->assertFalse($workflow->can($subject, 't5'));
123+
$this->assertTrue($workflow->can($subject, 't6'));
107124
}
108125

109126
public function testCanWithGuard()

0 commit comments

Comments
 (0)
0