Skip to content

Commit 3fac606

Browse files
authored
Added functional tests to make sure the bundle work on different sf versions (#59)
* Added functional tests to make sure the bundle work on different symfony versions * Do not run travis on Style CI branches * Applied fixes from StyleCI (#60) * Bugfix
1 parent 7ecb7b4 commit 3fac606

14 files changed

+162
-29
lines changed

Diff for: .travis.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ env:
1313
- TEST_COMMAND="php vendor/bin/phpunit"
1414
- COVERAGE=false
1515
matrix:
16-
- SYMFONY_VERSION=2.7.*
17-
- SYMFONY_VERSION=2.8.*
18-
- SYMFONY_VERSION=3.0.*
16+
- SYMFONY_VERSION=2.7.*
17+
- SYMFONY_VERSION=2.8.*
18+
- SYMFONY_VERSION=3.0.*
19+
20+
branches:
21+
except:
22+
- /^analysis-.*$/
1923

2024
matrix:
2125
fast_finish: true

Diff for: composer.json

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"name": "cache/cache-bundle",
3-
"type": "library",
4-
"description": "Symfony 2 bundle providing integration between PSR-6 compliant cache services and the framework. It supports cache for sessions, routing and Doctrine",
5-
"keywords": [
2+
"name": "cache/cache-bundle",
3+
"type": "library",
4+
"description": "Symfony 2 bundle providing integration between PSR-6 compliant cache services and the framework. It supports cache for sessions, routing and Doctrine",
5+
"keywords": [
66
"cache",
77
"psr6",
88
"doctrine",
99
"router",
1010
"session"
1111
],
12-
"homepage": "http://www.php-cache.com/en/latest/",
13-
"license": "MIT",
14-
"authors": [
12+
"homepage": "http://www.php-cache.com/en/latest/",
13+
"license": "MIT",
14+
"authors": [
1515
{
1616
"name": "Aaron Scherer",
1717
"email": "[email protected]",
@@ -23,22 +23,23 @@
2323
"homepage": "https://github.com/nyholm"
2424
}
2525
],
26-
"require": {
27-
"php": "^5.5|^7.0",
28-
"symfony/framework-bundle": "^2.7|^3.0",
29-
"cache/taggable-cache": "^0.4",
30-
"cache/session-handler": "^0.1"
26+
"require": {
27+
"php": "^5.5 || ^7.0",
28+
"symfony/framework-bundle": "^2.7 || ^3.0",
29+
"cache/taggable-cache": "^0.4",
30+
"cache/session-handler": "^0.1"
3131
},
3232
"require-dev": {
33-
"phpunit/phpunit": "^5.1|^4.0",
33+
"phpunit/phpunit": "^5.1 || ^4.0",
34+
"symfony/symfony": "^2.7 || ^3.0",
3435
"cache/psr-6-doctrine-bridge": "^2.0",
35-
"cache/array-adapter": "^0.4"
36+
"cache/array-adapter": "^0.4"
3637
},
37-
"suggest": {
38+
"suggest": {
3839
"cache/adapter-bundle": "To register PSR-6 compliant cache implementations as services.",
3940
"cache/psr-6-doctrine-bridge": "To be able to use Doctrine query, result and metadata cache."
4041
},
41-
"autoload": {
42+
"autoload": {
4243
"psr-4": {
4344
"Cache\\CacheBundle\\": "src/"
4445
}

Diff for: phpunit.xml.dist

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212
bootstrap="vendor/autoload.php"
1313
>
1414
<testsuites>
15-
<testsuite name="CacheBundle for the Symfony2 Framework">
15+
<testsuite name="Main testsuite for CacheBundle">
1616
<directory>./tests/</directory>
1717
</testsuite>
1818
</testsuites>
1919

20-
<logging>
21-
<log type="coverage-text" target="php://stdout"/>
22-
</logging>
23-
2420
<groups>
2521
<exclude>
2622
<group>benchmark</group>

Diff for: tests/Functional/BaseTestCase.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-cache\cache-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Cache\CacheBundle\Tests\Functional;
13+
14+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
15+
16+
class BaseTestCase extends WebTestCase
17+
{
18+
protected static function getKernelClass()
19+
{
20+
require_once __DIR__.'/app/AppKernel.php';
21+
22+
return 'Cache\CacheBundle\Tests\Functional\app\AppKernel';
23+
}
24+
25+
protected static function createKernel(array $options = [])
26+
{
27+
$class = self::getKernelClass();
28+
29+
return new $class(
30+
isset($options['config']) ? $options['config'] : 'default.yml'
31+
);
32+
}
33+
}

Diff for: tests/Functional/BundleInitializationTest.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-cache\cache-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Cache\CacheBundle\Tests\Functional;
13+
14+
class BundleInitializationTest extends BaseTestCase
15+
{
16+
public function testRegisterBundle()
17+
{
18+
static::createClient();
19+
}
20+
}

Diff for: tests/Functional/app/AppKernel.php

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-cache\cache-bundle package.
5+
*
6+
* (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Cache\CacheBundle\Tests\Functional\app;
13+
14+
use Symfony\Component\Config\Loader\LoaderInterface;
15+
use Symfony\Component\Filesystem\Filesystem;
16+
use Symfony\Component\HttpKernel\Kernel;
17+
18+
class AppKernel extends Kernel
19+
{
20+
private $config;
21+
22+
public function __construct($config)
23+
{
24+
parent::__construct('test', true);
25+
26+
$fs = new Filesystem();
27+
28+
if (!$fs->isAbsolutePath($config)) {
29+
$config = __DIR__.'/config/'.$config;
30+
}
31+
32+
if (!file_exists($config)) {
33+
throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config));
34+
}
35+
36+
$this->config = $config;
37+
}
38+
39+
public function registerBundles()
40+
{
41+
return [
42+
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
43+
new \Cache\CacheBundle\CacheBundle(),
44+
];
45+
}
46+
47+
public function registerContainerConfiguration(LoaderInterface $loader)
48+
{
49+
$loader->load($this->config);
50+
}
51+
52+
public function getCacheDir()
53+
{
54+
return sys_get_temp_dir().'/TestBundle';
55+
}
56+
57+
public function serialize()
58+
{
59+
return $this->config;
60+
}
61+
62+
public function unserialize($config)
63+
{
64+
$this->__construct($config);
65+
}
66+
}

Diff for: tests/Functional/app/config/default.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports:
2+
- { resource: framework.yml }

Diff for: tests/Functional/app/config/framework.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
framework:
2+
secret: test
3+
test: ~
4+
session:
5+
storage_id: session.storage.mock_file
6+
form: false
7+
csrf_protection: false
8+
validation:
9+
enabled: false
10+
router:
11+
resource: "%kernel.root_dir%/config/routing.yml"

Diff for: tests/Functional/app/config/routing.yml

Whitespace-only changes.

Diff for: tests/ContainerTest.php renamed to tests/Unit/ContainerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* with this source code in the file LICENSE.
1010
*/
1111

12-
namespace Cache\CacheBundle\Tests;
12+
namespace Cache\CacheBundle\Tests\Unit;
1313

1414
/**
1515
* Class ContainerTest.

Diff for: tests/DependencyInjection/CacheExtensionTest.php renamed to tests/Unit/DependencyInjection/CacheExtensionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* with this source code in the file LICENSE.
1010
*/
1111

12-
namespace Cache\CacheBundle\Tests\DependencyInjection;
12+
namespace Cache\CacheBundle\Tests\Unit\DependencyInjection;
1313

14-
use Cache\CacheBundle\Tests\TestCase;
14+
use Cache\CacheBundle\Tests\Unit\TestCase;
1515

1616
/**
1717
* Class CacheExtensionTest.
File renamed without changes.

Diff for: tests/KeyNormalizerTest.php renamed to tests/Unit/KeyNormalizerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* with this source code in the file LICENSE.
1010
*/
1111

12-
namespace Cache\CacheBundle\Tests;
12+
namespace Cache\CacheBundle\Tests\Unit;
1313

1414
use Cache\CacheBundle\KeyNormalizer;
1515

Diff for: tests/TestCase.php renamed to tests/Unit/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* with this source code in the file LICENSE.
1010
*/
1111

12-
namespace Cache\CacheBundle\Tests;
12+
namespace Cache\CacheBundle\Tests\Unit;
1313

1414
use Cache\CacheBundle\DependencyInjection\CacheExtension;
1515
use Symfony\Component\Config\FileLocator;

0 commit comments

Comments
 (0)