|
@@ -15,7 +15,6 @@ use Symfony\Component\Config\Resource\DirectoryResource;
|
|
|
|
|
|
class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
- protected $resource;
|
|
|
protected $directory;
|
|
|
|
|
|
protected function setUp()
|
|
@@ -25,7 +24,6 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
mkdir($this->directory);
|
|
|
}
|
|
|
touch($this->directory.'/tmp.xml');
|
|
|
- $this->resource = new DirectoryResource($this->directory);
|
|
|
}
|
|
|
|
|
|
protected function tearDown()
|
|
@@ -56,7 +54,8 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testGetResource()
|
|
|
{
|
|
|
- $this->assertEquals($this->directory, $this->resource->getResource(), '->getResource() returns the path to the resource');
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
+ $this->assertEquals($this->directory, $resource->getResource(), '->getResource() returns the path to the resource');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -64,8 +63,9 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testIsFresh()
|
|
|
{
|
|
|
- $this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
|
|
|
- $this->assertFalse($this->resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
+ $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
|
|
|
+ $this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
|
|
|
|
|
|
$resource = new DirectoryResource('/____foo/foobar'.rand(1, 999999));
|
|
|
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
|
|
@@ -76,8 +76,9 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testIsFreshUpdateFile()
|
|
|
{
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
touch($this->directory.'/tmp.xml', time() + 20);
|
|
|
- $this->assertFalse($this->resource->isFresh(time() + 10), '->isFresh() returns false if an existing file is modified');
|
|
|
+ $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an existing file is modified');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -85,8 +86,9 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testIsFreshNewFile()
|
|
|
{
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
touch($this->directory.'/new.xml', time() + 20);
|
|
|
- $this->assertFalse($this->resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added');
|
|
|
+ $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -94,8 +96,9 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testIsFreshDeleteFile()
|
|
|
{
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
unlink($this->directory.'/tmp.xml');
|
|
|
- $this->assertFalse($this->resource->isFresh(time()), '->isFresh() returns false if an existing file is removed');
|
|
|
+ $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if an existing file is removed');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -103,8 +106,9 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testIsFreshDeleteDirectory()
|
|
|
{
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
$this->removeDirectory($this->directory);
|
|
|
- $this->assertFalse($this->resource->isFresh(time()), '->isFresh() returns false if the whole resource is removed');
|
|
|
+ $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the whole resource is removed');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -115,10 +119,11 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
$subdirectory = $this->directory.'/subdirectory';
|
|
|
mkdir($subdirectory);
|
|
|
|
|
|
- $this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if an unmodified subdirectory exists');
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
+ $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if an unmodified subdirectory exists');
|
|
|
|
|
|
touch($subdirectory.'/newfile.xml', time() + 20);
|
|
|
- $this->assertFalse($this->resource->isFresh(time() + 10), '->isFresh() returns false if a new file in a subdirectory is added');
|
|
|
+ $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file in a subdirectory is added');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -126,23 +131,13 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase
|
|
|
*/
|
|
|
public function testIsFreshModifySubdirectory()
|
|
|
{
|
|
|
+ $resource = new DirectoryResource($this->directory);
|
|
|
+
|
|
|
$subdirectory = $this->directory.'/subdirectory';
|
|
|
mkdir($subdirectory);
|
|
|
-
|
|
|
touch($subdirectory, time() + 20);
|
|
|
- $this->assertFalse($this->resource->isFresh(time() + 10), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)');
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * @covers Symfony\Component\Config\Resource\DirectoryResource::setFilterRegexList
|
|
|
- * @covers Symfony\Component\Config\Resource\DirectoryResource::getFilterRegexList
|
|
|
- */
|
|
|
-public function testSetFilterRegexList()
|
|
|
- {
|
|
|
- $regexes = array('#\.foo$#', '#\.xml$#');
|
|
|
- $this->resource->setFilterRegexList($regexes);
|
|
|
-
|
|
|
- $this->assertEquals($regexes, $this->resource->getFilterRegexList(), '->getFilterRegexList() returns the previously defined list of filter regexes');
|
|
|
+ $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -150,11 +145,10 @@ public function testSetFilterRegexList()
|
|
|
*/
|
|
|
public function testFilterRegexListNoMatch()
|
|
|
{
|
|
|
- $regexes = array('#\.foo$#', '#\.xml$#');
|
|
|
- $this->resource->setFilterRegexList($regexes);
|
|
|
+ $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
|
|
|
|
|
touch($this->directory.'/new.bar', time() + 20);
|
|
|
- $this->assertTrue($this->resource->isFresh(time() + 10), '->isFresh() returns true if a new file not matching the filter regex is created');
|
|
|
+ $this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file not matching the filter regex is created');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -162,11 +156,9 @@ public function testSetFilterRegexList()
|
|
|
*/
|
|
|
public function testFilterRegexListMatch()
|
|
|
{
|
|
|
- $regexes = array('#\.foo$#', '#\.xml$#');
|
|
|
- $this->resource->setFilterRegexList($regexes);
|
|
|
+ $resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
|
|
|
|
|
touch($this->directory.'/new.xml', time() + 20);
|
|
|
- $this->assertFalse($this->resource->isFresh(time() + 10), '->isFresh() returns false if an new file matching the filter regex is created ');
|
|
|
+ $this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an new file matching the filter regex is created ');
|
|
|
}
|
|
|
-
|
|
|
}
|