diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ea8ffb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +vendor +phpunit.xml +composer.json diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f5c3d1a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + +matrix: + allow_failures: + - php: 5.5 + +before_script: + - "pecl install inotify" + - "mkdir ~/.composer" + - "echo '{\"config\":{\"github-oauth\": {\"github.com\":\"fa354b2f030836334eac842f8fd69a03e353d247\"}}}' > ~/.composer/config.json" + - "composer install --dev --no-progress" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a369d6b --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Konstantin Kudryashov & Henrik Bjornskov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..dda03cb --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +Luker +===== + +This is a continuation of Konstantin Kudryashov's ResourceWatcher for Symfony2. It have been moved +from his fork and renamed Lurker to allow a wider adoption. + +Still working on rename. + +Getting Started +--------------- + +This should be written + +Special Thanks +-------------- + +* [Konstantin Kudryashov](http://twitter.com/everzet) for the orignal code. diff --git a/composer.json b/composer.json index 3d9cbab..b7b5fd9 100644 --- a/composer.json +++ b/composer.json @@ -1,43 +1,42 @@ { - "name": "symfony/resource-watcher", - "type": "library", - "description": "Symfony ResourceWatcher Component", - "keywords": ["resource", "filesystem", "watching"], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ + "name" : "henrikbjorn/lurker", + "type" : "library", + "description" : "Resource Watcher.", + "keywords" : ["resource", "filesystem", "watching"], + "license" : "MIT", + + "authors" : [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name" : "Konstantin Kudryashov", + "email" : "ever.zet@gmail.com" }, { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com" + "name" : "Yaroslav Kiliba", + "email" : "om.dattaya@gmail.com" }, { - "name": "Yaroslav Kiliba", - "email": "om.dattaya@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name" : "Henrik Bjrnskov", + "email" : "henrik@bjrnskov.dk" } ], - "require": { - "php": ">=5.3.3", - "symfony/config": "self.version", - "symfony/event-dispatcher": "self.version" + + "require" : { + "php" : ">=5.3.3", + "symfony/config" : "~2.2", + "symfony/event-dispatcher" : "~2.2" }, - "autoload": { - "psr-0": { "Symfony\\Component\\ResourceWatcher": "" } + + "autoload" : { + "psr-0" : { "Lurker": "src" } }, - "suggest": { + + "suggest" : { "ext-inotify": ">=0.1.6" }, - "target-dir": "Symfony/Component/ResourceWatcher", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" + + "extra" : { + "branch-alias" : { + "dev-master" : "1.0.x" } } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..118d378 --- /dev/null +++ b/composer.lock @@ -0,0 +1,126 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "1bc33f5702ffb0f0ac043cd9560fd390", + "packages": [ + { + "name": "symfony/config", + "version": "v2.2.1", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "v2.2.1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/v2.2.1", + "reference": "v2.2.1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com", + "time": "2013-03-01 10:42:10" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.2.1", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "v2.2.1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", + "reference": "v2.2.1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": ">=2.0,<3.0" + }, + "suggest": { + "symfony/dependency-injection": "2.2.*", + "symfony/http-kernel": "2.2.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2013-02-11 11:26:43" + } + ], + "packages-dev": [ + + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.3.3" + }, + "platform-dev": [ + + ] +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..a8f3b81 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + ./tests/ + + + + + + src + + + diff --git a/Event/FilesystemEvent.php b/src/Lurker/Event/FilesystemEvent.php similarity index 87% rename from Event/FilesystemEvent.php rename to src/Lurker/Event/FilesystemEvent.php index 6769014..005d9cd 100644 --- a/Event/FilesystemEvent.php +++ b/src/Lurker/Event/FilesystemEvent.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Event; +namespace Lurker\Event; -use Symfony\Component\ResourceWatcher\Resource\TrackedResource; -use Symfony\Component\ResourceWatcher\Exception\InvalidArgumentException; -use Symfony\Component\Config\Resource\ResourceInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Resource\DirectoryResource; +use Lurker\Resource\TrackedResource; +use Lurker\Exception\InvalidArgumentException; +use Lurker\Resource\ResourceInterface; +use Lurker\Resource\FileResource; +use Lurker\Resource\DirectoryResource; use Symfony\Component\EventDispatcher\Event; /** diff --git a/Exception/ExceptionInterface.php b/src/Lurker/Exception/ExceptionInterface.php similarity index 87% rename from Exception/ExceptionInterface.php rename to src/Lurker/Exception/ExceptionInterface.php index 620cc43..1559a15 100644 --- a/Exception/ExceptionInterface.php +++ b/src/Lurker/Exception/ExceptionInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Exception; +namespace Lurker\Exception; /** * Exception interface for all exceptions thrown by the component. diff --git a/Exception/InvalidArgumentException.php b/src/Lurker/Exception/InvalidArgumentException.php similarity index 89% rename from Exception/InvalidArgumentException.php rename to src/Lurker/Exception/InvalidArgumentException.php index 8e4575e..e3c546f 100644 --- a/Exception/InvalidArgumentException.php +++ b/src/Lurker/Exception/InvalidArgumentException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Exception; +namespace Lurker\Exception; use \InvalidArgumentException as BaseInvalidArgumentException; diff --git a/Exception/RuntimeException.php b/src/Lurker/Exception/RuntimeException.php similarity index 89% rename from Exception/RuntimeException.php rename to src/Lurker/Exception/RuntimeException.php index f464350..8988f3e 100644 --- a/Exception/RuntimeException.php +++ b/src/Lurker/Exception/RuntimeException.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Exception; +namespace Lurker\Exception; use \RuntimeException as BaseRuntimeException; diff --git a/src/Lurker/Resource/DirectoryResource.php b/src/Lurker/Resource/DirectoryResource.php new file mode 100644 index 0000000..230c3e7 --- /dev/null +++ b/src/Lurker/Resource/DirectoryResource.php @@ -0,0 +1,138 @@ +exists()) { + return -1; + } + + $resource = $this->getResource(); + clearstatcache(true, $resource); + $newestMTime = filemtime($resource); + + foreach ($this->getFilteredChilds() as $file) { + clearstatcache(true, (string) $file); + $newestMTime = max($file->getMTime(), $newestMTime); + } + + return $newestMTime; + } + + /** + * Returns the list of filtered file and directory childs of directory resource. + * + * @return array An array of files + */ + public function getFilteredChilds() + { + if (!$this->exists()) { + return array(); + } + + $resource = $this->getResource(); + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($resource, \FilesystemIterator::SKIP_DOTS), + \RecursiveIteratorIterator::SELF_FIRST + ); + + $childs = array(); + foreach ($iterator as $file) { + // if regex filtering is enabled only return matching files + if ($file->isFile() && !$this->hasFile($file)) { + continue; + } + + // always monitor directories for changes, except the .. entries + // (otherwise deleted files wouldn't get detected) + if ($file->isDir() && '/..' === substr($file, -3)) { + continue; + } + + $childs[] = $file; + } + + return $childs; + } + + public function isFresh($timestamp) + { + if (!$this->exists()) { + return false; + } + + return $this->getModificationTime() < $timestamp; + } + + public function getId() + { + return md5('d' . $this . $this->getPattern()); + } + + public function hasFile($file) + { + if (!$file instanceof \SplFileInfo) { + $file = new \SplFileInfo($file); + } + + if (0 !== strpos($file->getRealPath(), realpath($this->getResource()))) { + return false; + } + + if ($this->getPattern()) { + return (bool) preg_match($this->getPattern(), $file->getBasename()); + } + + return true; + } + + public function getFilteredResources() + { + if (!$this->exists()) { + return array(); + } + + $iterator = new \DirectoryIterator($this->getResource()); + + $resources = array(); + foreach ($iterator as $file) { + // if regex filtering is enabled only return matching files + if ($file->isFile() && !$this->hasFile($file)) { + continue; + } + + // always monitor directories for changes, except the .. entries + // (otherwise deleted files wouldn't get detected) + if ($file->isDir() && '/..' === substr($file, -3)) { + continue; + } + + // if file is dot - continue + if ($file->isDot()) { + continue; + } + + if ($file->isFile()) { + $resources[] = new FileResource($file->getRealPath()); + } elseif ($file->isDir()) { + $resources[] = new DirectoryResource($file->getRealPath()); + } + } + + return $resources; + } +} diff --git a/src/Lurker/Resource/FileResource.php b/src/Lurker/Resource/FileResource.php new file mode 100644 index 0000000..0636883 --- /dev/null +++ b/src/Lurker/Resource/FileResource.php @@ -0,0 +1,44 @@ +exists()) { + return -1; + } + + $resource = $this->getResource(); + + clearstatcache(true, $resource); + + return filemtime($resource); + } + + public function getId() + { + return md5('f' . $this); + } + + public function isFresh($timestamp) + { + if (!$this->exists()) { + return false; + } + + return $this->getModificationTime() < $timestamp; + } + + public function exists() + { + return is_file($this); + } + +} diff --git a/src/Lurker/Resource/ResourceInterface.php b/src/Lurker/Resource/ResourceInterface.php new file mode 100644 index 0000000..fe0a888 --- /dev/null +++ b/src/Lurker/Resource/ResourceInterface.php @@ -0,0 +1,26 @@ +tracker = $this - ->getMockBuilder('Symfony\\Component\\ResourceWatcher\\Tracker\\TrackerInterface') + ->getMockBuilder('Lurker\\Tracker\\TrackerInterface') ->getMock(); $this->dispatcher = $this @@ -47,12 +47,12 @@ public function testConstructorDefaults() if (function_exists('inotify_init')) { $this->assertInstanceOf( - 'Symfony\\Component\\ResourceWatcher\\Tracker\\InotifyTracker', + 'Lurker\\Tracker\\InotifyTracker', $watcher->getTracker() ); } else { $this->assertInstanceOf( - 'Symfony\\Component\\ResourceWatcher\\Tracker\\RecursiveIteratorTracker', + 'Lurker\\Tracker\\RecursiveIteratorTracker', $watcher->getTracker() ); } @@ -109,7 +109,7 @@ public function testTrackDirpath() } /** - * @expectedException Symfony\Component\ResourceWatcher\Exception\InvalidArgumentException + * @expectedException Lurker\Exception\InvalidArgumentException * @expectedExceptionMessage First argument to track() should be either file or directory * resource, but got "unexisting_something" */ @@ -120,7 +120,7 @@ public function testTrackUnexistingResource() } /** - * @expectedException Symfony\Component\ResourceWatcher\Exception\InvalidArgumentException + * @expectedException Lurker\Exception\InvalidArgumentException * @expectedExceptionMessage "all" is a reserved keyword and can not be used as tracking id */ public function testTrackReservedKeyword() @@ -144,7 +144,7 @@ public function testListenWithCallback() } /** - * @expectedException Symfony\Component\ResourceWatcher\Exception\InvalidArgumentException + * @expectedException Lurker\Exception\InvalidArgumentException * @expectedExceptionMessage Second argument to listen() should be callable, but got string */ public function testListenWithWrongCallback() @@ -158,7 +158,7 @@ public function testTrackBy() $callback = function() {}; $watcher = $this - ->getMockBuilder('Symfony\\Component\\ResourceWatcher\\ResourceWatcher') + ->getMockBuilder('Lurker\\ResourceWatcher') ->disableOriginalConstructor() ->setMethods(array('track', 'addListener')) ->getMock(); @@ -240,9 +240,7 @@ public function testTrackingFunctionally() protected function getResourceMock() { - $resource = $this - ->getMockBuilder('Symfony\\Component\\Config\\Resource\\ResourceInterface') - ->getMock(); + $resource = $this->getMock('Lurker\\Resource\\ResourceInterface'); $resource ->expects($this->any()) @@ -255,7 +253,7 @@ protected function getResourceMock() protected function getFSEventMock() { return $this - ->getMockBuilder('Symfony\\Component\\ResourceWatcher\\Event\\FilesystemEvent') + ->getMockBuilder('Lurker\\Event\\FilesystemEvent') ->disableOriginalConstructor() ->getMock(); } @@ -263,7 +261,7 @@ protected function getFSEventMock() public function getTrackedResourceMock($trackingId = null) { $resource = $this - ->getMockBuilder('Symfony\\Component\\ResourceWatcher\\Resource\\TrackedResource') + ->getMockBuilder('Lurker\\Resource\\TrackedResource') ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/StateChecker/DirectoryStateCheckerTest.php b/tests/Lurker/Tests/StateChecker/DirectoryStateCheckerTest.php similarity index 91% rename from Tests/StateChecker/DirectoryStateCheckerTest.php rename to tests/Lurker/Tests/StateChecker/DirectoryStateCheckerTest.php index f4999b9..8afda94 100644 --- a/Tests/StateChecker/DirectoryStateCheckerTest.php +++ b/tests/Lurker/Tests/StateChecker/DirectoryStateCheckerTest.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker; +namespace Lurker\Tests\StateChecker; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; -use Symfony\Component\ResourceWatcher\StateChecker\DirectoryStateChecker; -use Symfony\Component\Config\Resource\ResourceInterface; -use Symfony\Component\Config\Resource\DirectoryResource; -use Symfony\Component\Config\Resource\FileResource; +use Lurker\Event\FilesystemEvent; +use Lurker\StateChecker\DirectoryStateChecker; +use Lurker\Resource\ResourceInterface; +use Lurker\Resource\DirectoryResource; +use Lurker\Resource\FileResource; class DirectoryStateCheckerTest extends \PHPUnit_Framework_TestCase { @@ -156,7 +156,7 @@ protected function touchResource(ResourceInterface $resource, $exists = true, $f protected function createDirectoryResourceMock($exists = true) { - $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\DirectoryResource') + $resource = $this->getMockBuilder('Lurker\Resource\DirectoryResource') ->disableOriginalConstructor() ->getMock(); @@ -167,7 +167,7 @@ protected function createDirectoryResourceMock($exists = true) protected function createFileResourceMock($exists = true) { - $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\FileResource') + $resource = $this->getMockBuilder('Lurker\Resource\FileResource') ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/StateChecker/FileStateCheckerTest.php b/tests/Lurker/Tests/StateChecker/FileStateCheckerTest.php similarity index 92% rename from Tests/StateChecker/FileStateCheckerTest.php rename to tests/Lurker/Tests/StateChecker/FileStateCheckerTest.php index 2446d68..94951f2 100644 --- a/Tests/StateChecker/FileStateCheckerTest.php +++ b/tests/Lurker/Tests/StateChecker/FileStateCheckerTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker; +namespace Lurker\Tests\StateChecker; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; -use Symfony\Component\ResourceWatcher\StateChecker\FileStateChecker; +use Lurker\Event\FilesystemEvent; +use Lurker\StateChecker\FileStateChecker; class FileStateCheckerTest extends \PHPUnit_Framework_TestCase { @@ -102,7 +102,7 @@ public function testConsecutiveChecks() protected function createResource($exists = true) { $resource = $this - ->getMockBuilder('Symfony\Component\Config\Resource\FileResource') + ->getMockBuilder('Lurker\Resource\FileResource') ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/StateChecker/Inotify/DirectoryStateCheckerTest.php b/tests/Lurker/Tests/StateChecker/Inotify/DirectoryStateCheckerTest.php similarity index 85% rename from Tests/StateChecker/Inotify/DirectoryStateCheckerTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/DirectoryStateCheckerTest.php index e6ac766..c070912 100644 --- a/Tests/StateChecker/Inotify/DirectoryStateCheckerTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/DirectoryStateCheckerTest.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify; +namespace Lurker\Tests\StateChecker\Inotify; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; -use Symfony\Component\ResourceWatcher\StateChecker\Inotify\CheckerBag; -use Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify\Fixtures\DirectoryStateCheckerForTest; -use Symfony\Component\Config\Resource\ResourceInterface; +use Lurker\Event\FilesystemEvent; +use Lurker\StateChecker\Inotify\CheckerBag; +use Lurker\Tests\StateChecker\Inotify\Fixtures\DirectoryStateCheckerForTest; +use Lurker\Resource\ResourceInterface; class DirectoryStateCheckerTest extends \PHPUnit_Framework_TestCase { @@ -73,7 +73,7 @@ protected function assertHasEvent(ResourceInterface $resource, $event, $events) protected function getResource() { $resource = $this - ->getMockBuilder('Symfony\Component\Config\Resource\DirectoryResource') + ->getMockBuilder('Lurker\Resource\DirectoryResource') ->disableOriginalConstructor() ->getMock(); $resource diff --git a/Tests/StateChecker/Inotify/FileStateCheckerTest.php b/tests/Lurker/Tests/StateChecker/Inotify/FileStateCheckerTest.php similarity index 81% rename from Tests/StateChecker/Inotify/FileStateCheckerTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/FileStateCheckerTest.php index 44cb678..9520d89 100644 --- a/Tests/StateChecker/Inotify/FileStateCheckerTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/FileStateCheckerTest.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify; +namespace Lurker\Tests\StateChecker\Inotify; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; -use Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify\Fixtures\FileStateCheckerForTest; +use Lurker\Event\FilesystemEvent; +use Lurker\Tests\StateChecker\Inotify\Fixtures\FileStateCheckerForTest; class FileStateCheckerTest extends StateCheckerTest { @@ -44,7 +44,7 @@ protected function getChecker() protected function getResource() { $resource = $this - ->getMockBuilder('Symfony\Component\Config\Resource\FileResource') + ->getMockBuilder('Lurker\Resource\FileResource') ->disableOriginalConstructor() ->getMock(); $resource diff --git a/Tests/StateChecker/Inotify/Fixtures/DirectoryStateCheckerForTest.php b/tests/Lurker/Tests/StateChecker/Inotify/Fixtures/DirectoryStateCheckerForTest.php similarity index 77% rename from Tests/StateChecker/Inotify/Fixtures/DirectoryStateCheckerForTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/Fixtures/DirectoryStateCheckerForTest.php index 54ba1b1..e3f0df6 100644 --- a/Tests/StateChecker/Inotify/Fixtures/DirectoryStateCheckerForTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/Fixtures/DirectoryStateCheckerForTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify\Fixtures; +namespace Lurker\Tests\StateChecker\Inotify\Fixtures; -use Symfony\Component\ResourceWatcher\StateChecker\Inotify\DirectoryStateChecker; +use Lurker\StateChecker\Inotify\DirectoryStateChecker; class DirectoryStateCheckerForTest extends DirectoryStateChecker { diff --git a/Tests/StateChecker/Inotify/Fixtures/FileStateCheckerForTest.php b/tests/Lurker/Tests/StateChecker/Inotify/Fixtures/FileStateCheckerForTest.php similarity index 77% rename from Tests/StateChecker/Inotify/Fixtures/FileStateCheckerForTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/Fixtures/FileStateCheckerForTest.php index 221eb5e..aca3895 100644 --- a/Tests/StateChecker/Inotify/Fixtures/FileStateCheckerForTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/Fixtures/FileStateCheckerForTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify\Fixtures; +namespace Lurker\Tests\StateChecker\Inotify\Fixtures; -use Symfony\Component\ResourceWatcher\StateChecker\Inotify\FileStateChecker; +use Lurker\StateChecker\Inotify\FileStateChecker; class FileStateCheckerForTest extends FileStateChecker { diff --git a/Tests/StateChecker/Inotify/Fixtures/TopDirectoryStateCheckerForTest.php b/tests/Lurker/Tests/StateChecker/Inotify/Fixtures/TopDirectoryStateCheckerForTest.php similarity index 77% rename from Tests/StateChecker/Inotify/Fixtures/TopDirectoryStateCheckerForTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/Fixtures/TopDirectoryStateCheckerForTest.php index 71fb502..fac5aae 100644 --- a/Tests/StateChecker/Inotify/Fixtures/TopDirectoryStateCheckerForTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/Fixtures/TopDirectoryStateCheckerForTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify\Fixtures; +namespace Lurker\Tests\StateChecker\Inotify\Fixtures; -use Symfony\Component\ResourceWatcher\StateChecker\Inotify\TopDirectoryStateChecker; +use Lurker\StateChecker\Inotify\TopDirectoryStateChecker; class TopDirectoryStateCheckerForTest extends TopDirectoryStateChecker { diff --git a/Tests/StateChecker/Inotify/StateCheckerTest.php b/tests/Lurker/Tests/StateChecker/Inotify/StateCheckerTest.php similarity index 93% rename from Tests/StateChecker/Inotify/StateCheckerTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/StateCheckerTest.php index 215e678..0c34886 100644 --- a/Tests/StateChecker/Inotify/StateCheckerTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/StateCheckerTest.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify; +namespace Lurker\Tests\StateChecker\Inotify; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; -use Symfony\Component\Config\Resource\ResourceInterface; -use Symfony\Component\ResourceWatcher\StateChecker\Inotify\CheckerBag; +use Lurker\Event\FilesystemEvent; +use Lurker\Resource\ResourceInterface; +use Lurker\StateChecker\Inotify\CheckerBag; abstract class StateCheckerTest extends \PHPUnit_Framework_TestCase { diff --git a/Tests/StateChecker/Inotify/TopDirectoryStateCheckerTest.php b/tests/Lurker/Tests/StateChecker/Inotify/TopDirectoryStateCheckerTest.php similarity index 85% rename from Tests/StateChecker/Inotify/TopDirectoryStateCheckerTest.php rename to tests/Lurker/Tests/StateChecker/Inotify/TopDirectoryStateCheckerTest.php index 53aef4f..3ec9a20 100644 --- a/Tests/StateChecker/Inotify/TopDirectoryStateCheckerTest.php +++ b/tests/Lurker/Tests/StateChecker/Inotify/TopDirectoryStateCheckerTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify; +namespace Lurker\Tests\StateChecker\Inotify; -use Symfony\Component\ResourceWatcher\Tests\StateChecker\Inotify\Fixtures\TopDirectoryStateCheckerForTest; +use Lurker\Tests\StateChecker\Inotify\Fixtures\TopDirectoryStateCheckerForTest; class TopDirectoryStateCheckerTest extends StateCheckerTest { @@ -43,7 +43,7 @@ protected function getChecker() protected function getResource() { $resource = $this - ->getMockBuilder('Symfony\Component\Config\Resource\DirectoryResource') + ->getMockBuilder('Lurker\Resource\DirectoryResource') ->disableOriginalConstructor() ->getMock(); $resource diff --git a/Tests/Tracker/InotifyTrackerTest.php b/tests/Lurker/Tests/Tracker/InotifyTrackerTest.php similarity index 95% rename from Tests/Tracker/InotifyTrackerTest.php rename to tests/Lurker/Tests/Tracker/InotifyTrackerTest.php index 1b32e37..cd2325a 100644 --- a/Tests/Tracker/InotifyTrackerTest.php +++ b/tests/Lurker/Tests/Tracker/InotifyTrackerTest.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\Tracker; +namespace Lurker\Tests\Tracker; -use Symfony\Component\ResourceWatcher\Tracker\InotifyTracker; -use Symfony\Component\ResourceWatcher\Resource\TrackedResource; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Config\Resource\DirectoryResource; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; +use Lurker\Tracker\InotifyTracker; +use Lurker\Resource\TrackedResource; +use Lurker\Resource\FileResource; +use Lurker\Resource\DirectoryResource; +use Lurker\Event\FilesystemEvent; class InotifyTrackerTest extends TrackerTest { @@ -42,11 +42,11 @@ protected function getMinimumInterval() } /** - * @expectedException Symfony\Component\ResourceWatcher\Exception\RuntimeException + * @expectedException Lurker\Exception\RuntimeException */ public function testEventOverflow() { - $tracker = $this->getMockBuilder('Symfony\Component\ResourceWatcher\Tracker\InotifyTracker') + $tracker = $this->getMockBuilder('Lurker\Tracker\InotifyTracker') ->disableOriginalConstructor() ->setMethods(array('readEvents', '__destruct')) ->getMock(); diff --git a/Tests/Tracker/RecursiveIteratorTrackerTest.php b/tests/Lurker/Tests/Tracker/RecursiveIteratorTrackerTest.php similarity index 79% rename from Tests/Tracker/RecursiveIteratorTrackerTest.php rename to tests/Lurker/Tests/Tracker/RecursiveIteratorTrackerTest.php index ecdb01c..dc49bad 100644 --- a/Tests/Tracker/RecursiveIteratorTrackerTest.php +++ b/tests/Lurker/Tests/Tracker/RecursiveIteratorTrackerTest.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\Tracker; +namespace Lurker\Tests\Tracker; -use Symfony\Component\ResourceWatcher\Tracker\RecursiveIteratorTracker; +use Lurker\Tracker\RecursiveIteratorTracker; class RecursiveIteratorTrackerTest extends TrackerTest { diff --git a/Tests/Tracker/TrackerTest.php b/tests/Lurker/Tests/Tracker/TrackerTest.php similarity index 94% rename from Tests/Tracker/TrackerTest.php rename to tests/Lurker/Tests/Tracker/TrackerTest.php index 2005ec2..04a2bfa 100644 --- a/Tests/Tracker/TrackerTest.php +++ b/tests/Lurker/Tests/Tracker/TrackerTest.php @@ -9,13 +9,13 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\ResourceWatcher\Tests\Tracker; +namespace Lurker\Tests\Tracker; -use Symfony\Component\ResourceWatcher\Event\FilesystemEvent; -use Symfony\Component\ResourceWatcher\Resource\TrackedResource; -use Symfony\Component\ResourceWatcher\Tracker\TrackerInterface; -use Symfony\Component\Config\Resource\DirectoryResource; -use Symfony\Component\Config\Resource\FileResource; +use Lurker\Event\FilesystemEvent; +use Lurker\Resource\TrackedResource; +use Lurker\Tracker\TrackerInterface; +use Lurker\Resource\DirectoryResource; +use Lurker\Resource\FileResource; abstract class TrackerTest extends \PHPUnit_Framework_TestCase { @@ -39,7 +39,7 @@ public function tearDown() } /** - * @expectedException Symfony\Component\ResourceWatcher\Exception\InvalidArgumentException + * @expectedException Lurker\Exception\InvalidArgumentException */ public function testDoesNotTrackMissingFiles() { @@ -49,7 +49,7 @@ public function testDoesNotTrackMissingFiles() } /** - * @expectedException Symfony\Component\ResourceWatcher\Exception\InvalidArgumentException + * @expectedException Lurker\Exception\InvalidArgumentException */ public function testDoesNotTrackMissingDirectories() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..75baf2a --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,5 @@ +add('Lurker\\Tests\\', __DIR__); +$loader->register();