diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03936cb..affe50a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,23 +5,17 @@ services: test:7: before_script: - sh build/docker_install.sh > /dev/null - #- apk add --no-cache php7-apcu php7-memcached php7-phpdbg - #- echo '\nextension=apcu.so\nextension=memcached.so' >> /etc/php7/php.ini - curl -sS https://getcomposer.org/installer | php - php composer.phar install --ignore-platform-reqs - #image: php:7-alpine image: php:7 script: - - phpdbg -qrr -- ./vendor/bin/phpunit -c build + - phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never test:7.1: before_script: - sh build/docker_install.sh > /dev/null - #- apk add --no-cache php7.1-apcu php7.1-memcached php7.1-phpdbg - #- echo '\nextension=apcu.so\nextension=memcached.so' >> /etc/php7.1/php.ini - curl -sS https://getcomposer.org/installer | php - php composer.phar install --ignore-platform-reqs - #image: php:7.1-alpine image: php:7.1 script: - - phpdbg -qrr -- ./vendor/bin/phpunit -c build + - phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never diff --git a/src/Driver/MemcachedDriver.php b/src/Driver/MemcachedDriver.php index 8776030..40d92d1 100644 --- a/src/Driver/MemcachedDriver.php +++ b/src/Driver/MemcachedDriver.php @@ -33,14 +33,15 @@ class MemcachedDriver extends AbstractDriver { * @param array $options * @throws CacheException */ - public function __construct(array $config = [], array $options = []) + public function __construct( + array $config = ['host' => '127.0.0.1', 'port' => '11211'], + array $options = [] + ) { - // @codeCoverageIgnoreStart if ( ! class_exists('Memcached')) { throw new CacheException("Memcached driver requires memcached extensions"); } - // @codeCoverageIgnoreEnd try { @@ -48,7 +49,6 @@ class MemcachedDriver extends AbstractDriver { $this->conn->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $this->conn->addServer($config['host'], (int) $config['port']); - // @codeCoverageIgnoreStart if ( ! empty($options)) { $this->conn->setOptions($options); @@ -60,7 +60,6 @@ class MemcachedDriver extends AbstractDriver { // match the requirements of the interface throw new CacheException($e->getMessage(), $e->getCode(), $e); } - // @codeCoverageIgnoreEnd } /** diff --git a/tests/Driver/MemcachedDriverTest.php b/tests/Driver/MemcachedDriverTest.php index b8b2ab1..14bfe61 100644 --- a/tests/Driver/MemcachedDriverTest.php +++ b/tests/Driver/MemcachedDriverTest.php @@ -22,10 +22,16 @@ class MemcachedDriverTest extends DriverTestBase { public function setUp() { - $this->driver = new MemcachedDriver([ - 'host' => 'localhost', - 'port' => '11211', - ]); + $config = [ + 'host' => '127.0.0.1', + 'port' => 11211 + ]; + if (array_key_exists('MEMCACHED_HOST', $_ENV)) + { + $config['host'] = $_ENV['MEMCACHED_HOST']; + } + + $this->driver = new MemcachedDriver($config); $this->driver->flush(); } } \ No newline at end of file diff --git a/tests/PoolTest.php b/tests/PoolTest.php index 3403ee2..3f540aa 100644 --- a/tests/PoolTest.php +++ b/tests/PoolTest.php @@ -16,15 +16,12 @@ namespace Aviat\Banker\Tests; -use Aviat\Banker\Pool; -use Aviat\Banker\Item; -use Aviat\Banker\ItemCollection; +use Aviat\Banker\{Item, ItemCollection, Pool}; use Aviat\Banker\Exception\InvalidArgumentException; use Monolog\Logger; use Monolog\Handler\SyslogHandler; use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; +use Psr\Log\{LoggerInterface, NullLogger}; class PoolTest extends TestCase {