Skip to content

Commit 7a23f83

Browse files
authored
Added more tests (#55)
* Added more tests * cs * Added more tests and travis config * Bugfixes * Separating tests * syntax error * style fix * Removed redis installation * Added redis server service * Do not add extra config under hhvm * Require doctrine 1.6 * Added memcache server * Do not update composer * Minor * Bugfix
1 parent b76799f commit 7a23f83

File tree

10 files changed

+137
-127
lines changed

10 files changed

+137
-127
lines changed

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
language: php
22
sudo: false
33

4+
services:
5+
- redis-server
6+
- memcached
7+
48
php:
5-
- hhvm
69
- 7.0
710
- 5.6
811
- 5.5
12+
- hhvm
913

1014
env:
1115
global:
@@ -15,8 +19,6 @@ env:
1519
matrix:
1620
- SYMFONY_VERSION=2.7.*
1721
- SYMFONY_VERSION=2.8.*
18-
- SYMFONY_VERSION=3.0.*
19-
- SYMFONY_VERSION=3.1.*
2022
- SYMFONY_VERSION=3.2.*
2123

2224
branches:
@@ -35,9 +37,9 @@ cache:
3537
- $HOME/.composer/cache
3638

3739
before_install:
40+
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-add .travis/phpconfig.ini; fi;
3841
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi;
3942
- pip install --user codecov
40-
- composer self-update
4143
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
4244

4345
install:

.travis/phpconfig.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extension = "mongo.so"
2+
extension = "memcache.so"
3+
extension = "memcached.so"
4+
extension = "redis.so"

composer.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,20 @@
2828
"phpunit/phpunit": "5.0.* || ^4.0",
2929
"symfony/symfony": "^2.7 || ^3.0",
3030
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
31-
"cache/array-adapter": "@stable"
31+
"nyholm/symfony-bundle-test": "^1.0.1",
32+
"cache/apc-adapter": "@stable",
33+
"cache/apcu-adapter": "@stable",
34+
"cache/array-adapter": "@stable",
35+
"cache/chain-adapter": "@stable",
36+
"cache/doctrine-adapter": "@stable",
37+
"cache/filesystem-adapter": "@stable",
38+
"cache/memcache-adapter": "@stable",
39+
"cache/memcached-adapter": "@stable",
40+
"cache/predis-adapter": "@stable",
41+
"cache/redis-adapter": "@stable",
42+
"cache/void-adapter": "@stable",
43+
"doctrine/cache": "^1.6",
44+
"predis/predis": "^1.1"
3245
},
3346
"suggest": {
3447
"cache/*-adapter": "A actual implementation of PSR-6 cache",

tests/Functional/BaseTestCase.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/Functional/BundleInitializationTest.php

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,80 @@
1111

1212
namespace Cache\AdapterBundle\Tests\Functional;
1313

14-
class BundleInitializationTest extends BaseTestCase
14+
use Cache\Adapter\Apc\ApcCachePool;
15+
use Cache\Adapter\Apcu\ApcuCachePool;
16+
use Cache\Adapter\Chain\CachePoolChain;
17+
use Cache\Adapter\Doctrine\DoctrineCachePool;
18+
use Cache\Adapter\Memcache\MemcacheCachePool;
19+
use Cache\Adapter\Memcached\MemcachedCachePool;
20+
use Cache\Adapter\PHPArray\ArrayCachePool;
21+
use Cache\Adapter\Predis\PredisCachePool;
22+
use Cache\Adapter\Redis\RedisCachePool;
23+
use Cache\Adapter\Void\VoidCachePool;
24+
use Cache\AdapterBundle\CacheAdapterBundle;
25+
use Nyholm\BundleTest\BaseBundleTestCase;
26+
27+
class BundleInitializationTest extends BaseBundleTestCase
1528
{
16-
public function testRegisterBundle()
29+
protected function getBundleClass()
30+
{
31+
return CacheAdapterBundle::class;
32+
}
33+
34+
protected function setUp()
35+
{
36+
parent::setUp();
37+
$kernel = $this->createKernel();
38+
$kernel->addConfigFile(__DIR__.'/config.yml');
39+
}
40+
41+
public function testFactoriesWithWithDefaultConfiguration()
42+
{
43+
$this->bootKernel();
44+
$container = $this->getContainer();
45+
$this->assertInstanceOf(ArrayCachePool::class, $container->get('alias.my_adapter'));
46+
$this->assertInstanceOf(ApcCachePool::class, $container->get('cache.provider.apc'));
47+
$this->assertInstanceOf(ApcuCachePool::class, $container->get('cache.provider.apcu'));
48+
$this->assertInstanceOf(ArrayCachePool::class, $container->get('cache.provider.array'));
49+
$this->assertInstanceOf(CachePoolChain::class, $container->get('cache.provider.chain'));
50+
$this->assertInstanceOf(PredisCachePool::class, $container->get('cache.provider.predis'));
51+
$this->assertInstanceOf(VoidCachePool::class, $container->get('cache.provider.void'));
52+
53+
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_filesystem'));
54+
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_predis'));
55+
}
56+
57+
public function testMemcachedWithWithDefaultConfiguration()
58+
{
59+
if (!class_exists('Memcached')) {
60+
$this->markTestSkipped('Skipping since Memcached is not installed.');
61+
}
62+
$this->bootKernel();
63+
$container = $this->getContainer();
64+
$this->assertInstanceOf(MemcachedCachePool::class, $container->get('cache.provider.memcached'));
65+
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_memcached'));
66+
}
67+
68+
public function testMemcacheWithWithDefaultConfiguration()
1769
{
18-
static::createClient();
70+
if (!class_exists('Memcache')) {
71+
$this->markTestSkipped('Skipping since Memcache is not installed.');
72+
}
73+
$this->bootKernel();
74+
$container = $this->getContainer();
75+
$this->assertInstanceOf(MemcacheCachePool::class, $container->get('cache.provider.memcache'));
76+
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_memcache'));
77+
}
78+
79+
public function testRedisWithWithDefaultConfiguration()
80+
{
81+
if (!class_exists('Redis')) {
82+
$this->markTestSkipped('Skipping since Memcache is not installed.');
83+
}
84+
85+
$this->bootKernel();
86+
$container = $this->getContainer();
87+
$this->assertInstanceOf(RedisCachePool::class, $container->get('cache.provider.redis'));
88+
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_redis'));
1989
}
2090
}

tests/Functional/app/AppKernel.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

tests/Functional/app/config/default.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/Functional/app/config/framework.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/Functional/app/config/routing.yml

Whitespace-only changes.

tests/Functional/config.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cache_adapter:
2+
providers:
3+
my_adapter:
4+
factory: 'cache.factory.array'
5+
options: []
6+
aliases: ['alias.my_adapter']
7+
8+
apc:
9+
factory: 'cache.factory.apc'
10+
apcu:
11+
factory: 'cache.factory.apcu'
12+
array:
13+
factory: 'cache.factory.array'
14+
chain:
15+
factory: 'cache.factory.chain'
16+
options:
17+
services: ['alias.my_adapter', 'cache.provider.void']
18+
memcache:
19+
factory: 'cache.factory.memcache'
20+
memcached:
21+
factory: 'cache.factory.memcached'
22+
predis:
23+
factory: 'cache.factory.predis'
24+
redis:
25+
factory: 'cache.factory.redis'
26+
void:
27+
factory: 'cache.factory.void'
28+
29+
doctrine_filesystem:
30+
factory: 'cache.factory.doctrine_filesystem'
31+
options:
32+
directory: 'doctrine_file'
33+
doctrine_memcached:
34+
factory: 'cache.factory.doctrine_memcached'
35+
doctrine_memcache:
36+
factory: 'cache.factory.doctrine_memcache'
37+
doctrine_predis:
38+
factory: 'cache.factory.doctrine_predis'
39+
doctrine_redis:
40+
factory: 'cache.factory.doctrine_redis'

0 commit comments

Comments
 (0)