Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #33 from h4cc/feature/test-on-travis
Browse files Browse the repository at this point in the history
Feature: Testing on travis
  • Loading branch information
Maurits van der Schee committed Sep 9, 2014
2 parents 492a8b6 + 96747e5 commit 147e968
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
vendor
vendor/
composer.lock
phpunit.xml

.idea/

1 change: 1 addition & 0 deletions .travis-php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension = memcached.so
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm

services:
- memcached

env:
- PECL_MEMCACHED=memcached-1.0.2
- PECL_MEMCACHED=memcached-2.0.1
- PECL_MEMCACHED=memcached-2.1.0
- PECL_MEMCACHED=memcached-2.2.0

before_script:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then yes "" | pecl install -f "$PECL_MEMCACHED"; fi;'
# Need to activate memchached extension explictly to work with all versions.
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-add .travis-php.ini; fi;'
- composer self-update || true
# Ensure the memcached extension is available
- composer show --platform ext-memcached
- composer install --no-interaction

script:
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-text
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LswMemcacheBundle
=================
[![Build Status](https://travis-ci.org/LeaseWeb/LswMemcacheBundle.svg)](https://travis-ci.org/LeaseWeb/LswMemcacheBundle)

![screenshot](http://www.leaseweblabs.com/wp-content/uploads/2013/03/memcache_debug.png)

Expand Down
22 changes: 22 additions & 0 deletions Tests/Cache/AntiDogPileMemcacheTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Lsw\MemcacheBundle\Tests\Cache;


use Lsw\MemcacheBundle\Cache\AntiDogPileMemcache;

/**
* Testing the AntiDogPileMemcache Class.
*
* @author Julius Beckmann <github@h4cc.de>
*/
class AntiDogPileMemcacheTest extends \PHPUnit_Framework_TestCase
{
public function testConstructAndInterfaces()
{
$cache = new AntiDogPileMemcache('foo');

$this->assertInstanceOf('\Lsw\MemcacheBundle\Cache\LoggingMemcache', $cache);
}
}

16 changes: 6 additions & 10 deletions Tests/Cache/DogPileTest_.php → Tests/Cache/DogPileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

use Lsw\MemcacheBundle\Cache\AntiDogPileMemcache;

require_once "../../Cache/LoggingMemcacheInterface.php";
require_once "../../Cache/MemcacheInterface.php";
require_once "../../Cache/LoggingMemcache.php";
require_once "../../Cache/AntiDogPileMemcache.php";

class DogPileTest //extends \PHPUnit_Framework_TestCase
class DogPileTest extends \PHPUnit_Framework_TestCase
{
public function testDogPile()
{
$this->assertTrue(true);

// TODO: This test is not yet able to run on travis.
return;

for ($t=1; $t<3; $t++) {
$pid = pcntl_fork();
if ($pid == -1) {
Expand Down Expand Up @@ -43,7 +43,3 @@ public function testDogPile()
sleep(3);
}
}

$t = new DogPileTest();
$t->testDogPile();

22 changes: 19 additions & 3 deletions Tests/Cache/LoggingMemcacheTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<?php

namespace Lsw\MemcacheBundle\Tests\Cache;

use Lsw\MemcacheBundle\Cache\LoggingMemcache;

use Lsw\MemcacheBundle\Cache\LoggingMemcache;

/**
* Testing the LoggingMemcache Class.
*
* @author Julius Beckmann <github@h4cc.de>
*/
class LoggingMemcacheTest extends \PHPUnit_Framework_TestCase
{
public function testConstructAndInterfaces()
{
$cache = new LoggingMemcache('foo');

$this->assertInstanceOf('\Memcached', $cache);
$this->assertInstanceOf('\Lsw\MemcacheBundle\Cache\MemcacheInterface', $cache);
$this->assertInstanceOf('\Lsw\MemcacheBundle\Cache\LoggingMemcacheInterface', $cache);
}

public function testOpenPort()
{
fsockopen('127.0.0.1', 11211, $errno, $errstr, 0.1);
fsockopen('127.0.0.1', 11211, $errno, $errstr, 0.1);
}

public function testGet()
Expand All @@ -18,4 +34,4 @@ public function testGet()
$value = $m->get('key');
$this->assertEquals('value', $value);
}
}
}
70 changes: 70 additions & 0 deletions Tests/Cache/MemcacheInterfaceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Lsw\MemcacheBundle\Tests\Cache;

/**
* Testing the MemcacheInterface Switch.
*
* @author Julius Beckmann <github@h4cc.de>
*/
class MemcacheInterfaceTest extends \PHPUnit_Framework_TestCase
{
public function testInterfaceWorks()
{
$class = new \ReflectionClass('\Lsw\MemcacheBundle\Cache\MemcacheInterface');

$methods = array_map(
function (\ReflectionMethod $method) {
return $method->getName();
},
$class->getMethods()
);

foreach ($this->getDefaultMethods() as $method) {
$this->assertContains($method, $methods);
}
}

private function getDefaultMethods()
{
return array(
'get',
'getByKey',
'getMulti',
'getMultiByKey',
'getDelayed',
'getDelayedByKey',
'fetch',
'fetchAll',
'set',
'setByKey',
'setMulti',
'setMultiByKey',
'cas',
'casByKey',
'add',
'addByKey',
'append',
'appendByKey',
'prepend',
'prependByKey',
'replace',
'replaceByKey',
'delete',
'deleteByKey',
'increment',
'decrement',
'getOption',
'setOption',
'addServer',
'addServers',
'getServerList',
'getServerByKey',
'flush',
'getStats',
'getResultCode',
'getResultMessage',
);
}
}

17 changes: 2 additions & 15 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,7 @@
/*
* This file bootstraps the test environment.
*/
namespace Lsw\MemcacheBundle\Tests;

error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);

// register silently failing autoloader
spl_autoload_register(function($class)
{
if (0 === strpos($class, 'Lsw\\MemcacheBundle\\')) {
$path = __DIR__.'/../../../'.strtr($class, '\\', '/').'.php';

if (is_file($path) && is_readable($path)) {
require_once $path;

return true;
}
}
});
require __DIR__.'/../vendor/autoload.php';
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"email": "m.vanderschee@leaseweb.com"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": ">=2.1",
"ext-memcached": ">=1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"autoload": {
"psr-0": { "Lsw\\MemcacheBundle": "" }
},
Expand Down
22 changes: 0 additions & 22 deletions phpunit.xml

This file was deleted.

33 changes: 33 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "vendor/autoload.php"
forceCoversAnnotation = "true"
>

<testsuites>
<testsuite name="LswMemcacheBundleTest Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./vendor</directory>
<directory>./Tests</directory>
<directory>./Resources</directory>
</exclude>
</whitelist>
</filter>

</phpunit>

0 comments on commit 147e968

Please sign in to comment.