Skip to content

Commit

Permalink
Added more tests (#55)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Nyholm committed Mar 28, 2017
1 parent b76799f commit 7a23f83
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 127 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
@@ -1,11 +1,15 @@
language: php
sudo: false

services:
- redis-server
- memcached

php:
- hhvm
- 7.0
- 5.6
- 5.5
- hhvm

env:
global:
Expand All @@ -15,8 +19,6 @@ env:
matrix:
- SYMFONY_VERSION=2.7.*
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.0.*
- SYMFONY_VERSION=3.1.*
- SYMFONY_VERSION=3.2.*

branches:
Expand All @@ -35,9 +37,9 @@ cache:
- $HOME/.composer/cache

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

install:
Expand Down
4 changes: 4 additions & 0 deletions .travis/phpconfig.ini
@@ -0,0 +1,4 @@
extension = "mongo.so"
extension = "memcache.so"
extension = "memcached.so"
extension = "redis.so"
15 changes: 14 additions & 1 deletion composer.json
Expand Up @@ -28,7 +28,20 @@
"phpunit/phpunit": "5.0.* || ^4.0",
"symfony/symfony": "^2.7 || ^3.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
"cache/array-adapter": "@stable"
"nyholm/symfony-bundle-test": "^1.0.1",
"cache/apc-adapter": "@stable",
"cache/apcu-adapter": "@stable",
"cache/array-adapter": "@stable",
"cache/chain-adapter": "@stable",
"cache/doctrine-adapter": "@stable",
"cache/filesystem-adapter": "@stable",
"cache/memcache-adapter": "@stable",
"cache/memcached-adapter": "@stable",
"cache/predis-adapter": "@stable",
"cache/redis-adapter": "@stable",
"cache/void-adapter": "@stable",
"doctrine/cache": "^1.6",
"predis/predis": "^1.1"
},
"suggest": {
"cache/*-adapter": "A actual implementation of PSR-6 cache",
Expand Down
33 changes: 0 additions & 33 deletions tests/Functional/BaseTestCase.php

This file was deleted.

76 changes: 73 additions & 3 deletions tests/Functional/BundleInitializationTest.php
Expand Up @@ -11,10 +11,80 @@

namespace Cache\AdapterBundle\Tests\Functional;

class BundleInitializationTest extends BaseTestCase
use Cache\Adapter\Apc\ApcCachePool;
use Cache\Adapter\Apcu\ApcuCachePool;
use Cache\Adapter\Chain\CachePoolChain;
use Cache\Adapter\Doctrine\DoctrineCachePool;
use Cache\Adapter\Memcache\MemcacheCachePool;
use Cache\Adapter\Memcached\MemcachedCachePool;
use Cache\Adapter\PHPArray\ArrayCachePool;
use Cache\Adapter\Predis\PredisCachePool;
use Cache\Adapter\Redis\RedisCachePool;
use Cache\Adapter\Void\VoidCachePool;
use Cache\AdapterBundle\CacheAdapterBundle;
use Nyholm\BundleTest\BaseBundleTestCase;

class BundleInitializationTest extends BaseBundleTestCase
{
public function testRegisterBundle()
protected function getBundleClass()
{
return CacheAdapterBundle::class;
}

protected function setUp()
{
parent::setUp();
$kernel = $this->createKernel();
$kernel->addConfigFile(__DIR__.'/config.yml');
}

public function testFactoriesWithWithDefaultConfiguration()
{
$this->bootKernel();
$container = $this->getContainer();
$this->assertInstanceOf(ArrayCachePool::class, $container->get('alias.my_adapter'));
$this->assertInstanceOf(ApcCachePool::class, $container->get('cache.provider.apc'));
$this->assertInstanceOf(ApcuCachePool::class, $container->get('cache.provider.apcu'));
$this->assertInstanceOf(ArrayCachePool::class, $container->get('cache.provider.array'));
$this->assertInstanceOf(CachePoolChain::class, $container->get('cache.provider.chain'));
$this->assertInstanceOf(PredisCachePool::class, $container->get('cache.provider.predis'));
$this->assertInstanceOf(VoidCachePool::class, $container->get('cache.provider.void'));

$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_filesystem'));
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_predis'));
}

public function testMemcachedWithWithDefaultConfiguration()
{
if (!class_exists('Memcached')) {
$this->markTestSkipped('Skipping since Memcached is not installed.');
}
$this->bootKernel();
$container = $this->getContainer();
$this->assertInstanceOf(MemcachedCachePool::class, $container->get('cache.provider.memcached'));
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_memcached'));
}

public function testMemcacheWithWithDefaultConfiguration()
{
static::createClient();
if (!class_exists('Memcache')) {
$this->markTestSkipped('Skipping since Memcache is not installed.');
}
$this->bootKernel();
$container = $this->getContainer();
$this->assertInstanceOf(MemcacheCachePool::class, $container->get('cache.provider.memcache'));
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_memcache'));
}

public function testRedisWithWithDefaultConfiguration()
{
if (!class_exists('Redis')) {
$this->markTestSkipped('Skipping since Memcache is not installed.');
}

$this->bootKernel();
$container = $this->getContainer();
$this->assertInstanceOf(RedisCachePool::class, $container->get('cache.provider.redis'));
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_redis'));
}
}
66 changes: 0 additions & 66 deletions tests/Functional/app/AppKernel.php

This file was deleted.

9 changes: 0 additions & 9 deletions tests/Functional/app/config/default.yml

This file was deleted.

11 changes: 0 additions & 11 deletions tests/Functional/app/config/framework.yml

This file was deleted.

Empty file.
40 changes: 40 additions & 0 deletions tests/Functional/config.yml
@@ -0,0 +1,40 @@
cache_adapter:
providers:
my_adapter:
factory: 'cache.factory.array'
options: []
aliases: ['alias.my_adapter']

apc:
factory: 'cache.factory.apc'
apcu:
factory: 'cache.factory.apcu'
array:
factory: 'cache.factory.array'
chain:
factory: 'cache.factory.chain'
options:
services: ['alias.my_adapter', 'cache.provider.void']
memcache:
factory: 'cache.factory.memcache'
memcached:
factory: 'cache.factory.memcached'
predis:
factory: 'cache.factory.predis'
redis:
factory: 'cache.factory.redis'
void:
factory: 'cache.factory.void'

doctrine_filesystem:
factory: 'cache.factory.doctrine_filesystem'
options:
directory: 'doctrine_file'
doctrine_memcached:
factory: 'cache.factory.doctrine_memcached'
doctrine_memcache:
factory: 'cache.factory.doctrine_memcache'
doctrine_predis:
factory: 'cache.factory.doctrine_predis'
doctrine_redis:
factory: 'cache.factory.doctrine_redis'

0 comments on commit 7a23f83

Please sign in to comment.