diff --git a/.travis.yml b/.travis.yml index 07a03ff..621368e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,13 @@ env: - TEST_COMMAND="php vendor/bin/phpunit" - COVERAGE=false matrix: - - SYMFONY_VERSION=2.7.* - - SYMFONY_VERSION=2.8.* - - SYMFONY_VERSION=3.0.* + - SYMFONY_VERSION=2.7.* + - SYMFONY_VERSION=2.8.* + - SYMFONY_VERSION=3.0.* + +branches: + except: + - /^analysis-.*$/ matrix: fast_finish: true diff --git a/composer.json b/composer.json index b24a80a..fa08547 100644 --- a/composer.json +++ b/composer.json @@ -1,17 +1,17 @@ { - "name": "cache/cache-bundle", - "type": "library", - "description": "Symfony 2 bundle providing integration between PSR-6 compliant cache services and the framework. It supports cache for sessions, routing and Doctrine", - "keywords": [ + "name": "cache/cache-bundle", + "type": "library", + "description": "Symfony 2 bundle providing integration between PSR-6 compliant cache services and the framework. It supports cache for sessions, routing and Doctrine", + "keywords": [ "cache", "psr6", "doctrine", "router", "session" ], - "homepage": "http://www.php-cache.com/en/latest/", - "license": "MIT", - "authors": [ + "homepage": "http://www.php-cache.com/en/latest/", + "license": "MIT", + "authors": [ { "name": "Aaron Scherer", "email": "aequasi@gmail.com", @@ -23,22 +23,23 @@ "homepage": "https://github.com/nyholm" } ], - "require": { - "php": "^5.5|^7.0", - "symfony/framework-bundle": "^2.7|^3.0", - "cache/taggable-cache": "^0.4", - "cache/session-handler": "^0.1" + "require": { + "php": "^5.5 || ^7.0", + "symfony/framework-bundle": "^2.7 || ^3.0", + "cache/taggable-cache": "^0.4", + "cache/session-handler": "^0.1" }, "require-dev": { - "phpunit/phpunit": "^5.1|^4.0", + "phpunit/phpunit": "^5.1 || ^4.0", + "symfony/symfony": "^2.7 || ^3.0", "cache/psr-6-doctrine-bridge": "^2.0", - "cache/array-adapter": "^0.4" + "cache/array-adapter": "^0.4" }, - "suggest": { + "suggest": { "cache/adapter-bundle": "To register PSR-6 compliant cache implementations as services.", "cache/psr-6-doctrine-bridge": "To be able to use Doctrine query, result and metadata cache." }, - "autoload": { + "autoload": { "psr-4": { "Cache\\CacheBundle\\": "src/" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a253ad3..8d8982a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,15 +12,11 @@ bootstrap="vendor/autoload.php" > - + ./tests/ - - - - benchmark diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/BaseTestCase.php new file mode 100644 index 0000000..bb5a121 --- /dev/null +++ b/tests/Functional/BaseTestCase.php @@ -0,0 +1,33 @@ +, Tobias Nyholm + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Cache\CacheBundle\Tests\Functional; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +class BaseTestCase extends WebTestCase +{ + protected static function getKernelClass() + { + require_once __DIR__.'/app/AppKernel.php'; + + return 'Cache\CacheBundle\Tests\Functional\app\AppKernel'; + } + + protected static function createKernel(array $options = []) + { + $class = self::getKernelClass(); + + return new $class( + isset($options['config']) ? $options['config'] : 'default.yml' + ); + } +} diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php new file mode 100644 index 0000000..38006e2 --- /dev/null +++ b/tests/Functional/BundleInitializationTest.php @@ -0,0 +1,20 @@ +, Tobias Nyholm + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Cache\CacheBundle\Tests\Functional; + +class BundleInitializationTest extends BaseTestCase +{ + public function testRegisterBundle() + { + static::createClient(); + } +} diff --git a/tests/Functional/app/AppKernel.php b/tests/Functional/app/AppKernel.php new file mode 100644 index 0000000..6b76758 --- /dev/null +++ b/tests/Functional/app/AppKernel.php @@ -0,0 +1,66 @@ +, Tobias Nyholm + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Cache\CacheBundle\Tests\Functional\app; + +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpKernel\Kernel; + +class AppKernel extends Kernel +{ + private $config; + + public function __construct($config) + { + parent::__construct('test', true); + + $fs = new Filesystem(); + + if (!$fs->isAbsolutePath($config)) { + $config = __DIR__.'/config/'.$config; + } + + if (!file_exists($config)) { + throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config)); + } + + $this->config = $config; + } + + public function registerBundles() + { + return [ + new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), + new \Cache\CacheBundle\CacheBundle(), + ]; + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load($this->config); + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/TestBundle'; + } + + public function serialize() + { + return $this->config; + } + + public function unserialize($config) + { + $this->__construct($config); + } +} diff --git a/tests/Functional/app/config/default.yml b/tests/Functional/app/config/default.yml new file mode 100644 index 0000000..8ddd7ed --- /dev/null +++ b/tests/Functional/app/config/default.yml @@ -0,0 +1,2 @@ +imports: + - { resource: framework.yml } diff --git a/tests/Functional/app/config/framework.yml b/tests/Functional/app/config/framework.yml new file mode 100644 index 0000000..962895c --- /dev/null +++ b/tests/Functional/app/config/framework.yml @@ -0,0 +1,11 @@ +framework: + secret: test + test: ~ + session: + storage_id: session.storage.mock_file + form: false + csrf_protection: false + validation: + enabled: false + router: + resource: "%kernel.root_dir%/config/routing.yml" diff --git a/tests/Functional/app/config/routing.yml b/tests/Functional/app/config/routing.yml new file mode 100644 index 0000000..e69de29 diff --git a/tests/ContainerTest.php b/tests/Unit/ContainerTest.php similarity index 93% rename from tests/ContainerTest.php rename to tests/Unit/ContainerTest.php index f4b3605..9016d09 100755 --- a/tests/ContainerTest.php +++ b/tests/Unit/ContainerTest.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Cache\CacheBundle\Tests; +namespace Cache\CacheBundle\Tests\Unit; /** * Class ContainerTest. diff --git a/tests/DependencyInjection/CacheExtensionTest.php b/tests/Unit/DependencyInjection/CacheExtensionTest.php similarity index 88% rename from tests/DependencyInjection/CacheExtensionTest.php rename to tests/Unit/DependencyInjection/CacheExtensionTest.php index e88aff0..b7259de 100755 --- a/tests/DependencyInjection/CacheExtensionTest.php +++ b/tests/Unit/DependencyInjection/CacheExtensionTest.php @@ -9,9 +9,9 @@ * with this source code in the file LICENSE. */ -namespace Cache\CacheBundle\Tests\DependencyInjection; +namespace Cache\CacheBundle\Tests\Unit\DependencyInjection; -use Cache\CacheBundle\Tests\TestCase; +use Cache\CacheBundle\Tests\Unit\TestCase; /** * Class CacheExtensionTest. diff --git a/tests/Fixtures/router.yml b/tests/Unit/Fixtures/router.yml similarity index 100% rename from tests/Fixtures/router.yml rename to tests/Unit/Fixtures/router.yml diff --git a/tests/KeyNormalizerTest.php b/tests/Unit/KeyNormalizerTest.php similarity index 94% rename from tests/KeyNormalizerTest.php rename to tests/Unit/KeyNormalizerTest.php index e6fd69f..088741b 100644 --- a/tests/KeyNormalizerTest.php +++ b/tests/Unit/KeyNormalizerTest.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Cache\CacheBundle\Tests; +namespace Cache\CacheBundle\Tests\Unit; use Cache\CacheBundle\KeyNormalizer; diff --git a/tests/TestCase.php b/tests/Unit/TestCase.php similarity index 98% rename from tests/TestCase.php rename to tests/Unit/TestCase.php index 996cd42..f79935f 100755 --- a/tests/TestCase.php +++ b/tests/Unit/TestCase.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Cache\CacheBundle\Tests; +namespace Cache\CacheBundle\Tests\Unit; use Cache\CacheBundle\DependencyInjection\CacheExtension; use Symfony\Component\Config\FileLocator;