diff --git a/composer.json b/composer.json index 48a8c4f..122e2d2 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "symfony/expression-language": "^2.7" }, "require-dev": { - "phpunit/phpunit": "4.8.*" + "phpunit/phpunit": "4.8.*", + "mikey179/vfsStream": "^1.0" }, "bin": ["bin/deprecation-detector"], "autoload": { diff --git a/composer.lock b/composer.lock index 47f7c65..3124a7c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,55 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9e6c3b0f18e1265f8887eac427da82fc", - "content-hash": "13a91fb9ffa68f2ba28c400a08e6baed", + "hash": "2fd97b5f4aab66649dd2d818e5d51a5b", + "content-hash": "6e15ef62add11bbfee0cbe056d7f67f0", "packages": [ + { + "name": "mikey179/vfsStream", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/mikey179/vfsStream.git", + "reference": "73bcb605b741a7d5044b47592338c633788b0eb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/73bcb605b741a7d5044b47592338c633788b0eb7", + "reference": "73bcb605b741a7d5044b47592338c633788b0eb7", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "org\\bovigo\\vfs\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Frank Kleine", + "homepage": "http://frankkleine.de/", + "role": "Developer" + } + ], + "description": "Virtual file system to mock the real file system in unit tests.", + "homepage": "http://vfs.bovigo.org/", + "time": "2015-10-06 16:59:57" + }, { "name": "nikic/php-parser", "version": "v1.4.1", diff --git a/tests/RuleSet/Loader/DirectoryLoaderTest.php b/tests/RuleSet/Loader/DirectoryLoaderTest.php new file mode 100644 index 0000000..7a26295 --- /dev/null +++ b/tests/RuleSet/Loader/DirectoryLoaderTest.php @@ -0,0 +1,52 @@ +prophesize('\SensioLabs\DeprecationDetector\RuleSet\Traverser'); + $cache = $this->prophesize('\SensioLabs\DeprecationDetector\RuleSet\Cache'); + + $loader = new DirectoryLoader($traverser->reveal(), $cache->reveal()); + + $this->assertInstanceOf('\SensioLabs\DeprecationDetector\RuleSet\Loader\DirectoryLoader', $loader); + } + + public function testLoadRuleSetUncached() + { + $traverser = $this->prophesize('\SensioLabs\DeprecationDetector\RuleSet\Traverser'); + $traverser->traverse(Argument::any()) + ->willReturn(new RuleSet()); + + $cache = $this->prophesize('\SensioLabs\DeprecationDetector\RuleSet\Cache'); + + $loader = new DirectoryLoader($traverser->reveal(), $cache->reveal()); + + $actualRuleSet = $loader->loadRuleSet('any'); + + $this->assertInstanceOf('\SensioLabs\DeprecationDetector\RuleSet\RuleSet', $actualRuleSet); + } + + public function testLoadRuleSetCached() + { + $traverser = $this->prophesize('\SensioLabs\DeprecationDetector\RuleSet\Traverser'); + + $cache = $this->prophesize('\SensioLabs\DeprecationDetector\RuleSet\Cache'); + $cache->has(Argument::any()) + ->willReturn(true); + $cache->getCachedRuleSet(Argument::any()) + ->willReturn(new RuleSet()); + + $loader = new DirectoryLoader($traverser->reveal(), $cache->reveal()); + + $actualRuleSet = $loader->loadRuleSet('any'); + + $this->assertInstanceOf('\SensioLabs\DeprecationDetector\RuleSet\RuleSet', $actualRuleSet); + } +}