Skip to content

Commit 2fed201

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: [DomCrawler] Invalid uri created from forms if base tag present [Console] update param type phpdoc for StreamOutput [Console] fix typo in OutputInterface [HttpKernel] fix broken multiline <esi:remove> [DoctrineBridge] Fixed #14840 [FrameworkBundle] add a suggest for the serializer component [Yaml] Fix the parsing of float keys [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors Improve exception messages. Fix that two DirectoryResources with different patterns would be deduplicated Tests fix clockmock [WebProfilerBundle] Added tabindex="-1" to not interfer with normal UX missing "YAML" in the exception message. [framework-bundle] Add Test for TranslationUpdateCommand Use ObjectManager interface instead of EntityManager
2 parents 2b1e4d6 + 29438d7 commit 2fed201

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Resource/DirectoryResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($resource, $pattern = null)
3838
*/
3939
public function __toString()
4040
{
41-
return (string) $this->resource;
41+
return md5(serialize(array($this->resource, $this->pattern)));
4242
}
4343

4444
/**

Tests/Resource/DirectoryResourceTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public function testGetResource()
5454
{
5555
$resource = new DirectoryResource($this->directory);
5656
$this->assertSame($this->directory, $resource->getResource(), '->getResource() returns the path to the resource');
57-
$this->assertSame($this->directory, (string) $resource, '->__toString() returns the path to the resource');
5857
}
5958

6059
public function testGetPattern()
@@ -87,6 +86,13 @@ public function testIsFreshNewFile()
8786
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added');
8887
}
8988

89+
public function testIsFreshNewFileWithDifferentPattern()
90+
{
91+
$resource = new DirectoryResource($this->directory, '/.xml$/');
92+
touch($this->directory.'/new.yaml', time() + 20);
93+
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file with a non-matching pattern is added');
94+
}
95+
9096
public function testIsFreshDeleteFile()
9197
{
9298
$resource = new DirectoryResource($this->directory);
@@ -149,4 +155,12 @@ public function testSerializeUnserialize()
149155
$this->assertSame($this->directory, $resource->getResource());
150156
$this->assertSame('/\.(foo|xml)$/', $resource->getPattern());
151157
}
158+
159+
public function testResourcesWithDifferentPatternsAreDifferent()
160+
{
161+
$resourceA = new DirectoryResource($this->directory, '/.xml$/');
162+
$resourceB = new DirectoryResource($this->directory, '/.yaml$/');
163+
164+
$this->assertEquals(2, count(array_unique(array($resourceA, $resourceB))));
165+
}
152166
}

0 commit comments

Comments
 (0)