Skip to content

Commit

Permalink
Use semver for PHP version at composer.json, added support for PHP …
Browse files Browse the repository at this point in the history
…7.3 at Travis
  • Loading branch information
phansys committed Mar 15, 2019
1 parent 1a0c122 commit a2fec55
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ matrix:
env: SYMFONY_VERSION="4.1.*"
- php: 7.2
env: SYMFONY_VERSION="4.2.*" SYMFONY_DEPRECATIONS_HELPER="weak" STABILITY="dev"
- php: 7.3
- php: nightly
allow_failures:
- php: hhvm
Expand All @@ -47,6 +48,7 @@ env:
before_install:
- phpenv config-rm xdebug.ini || true
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- php -i | grep -i --color=never "Redis Version"
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv rehash; fi;
- composer self-update
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
Expand Down
63 changes: 63 additions & 0 deletions Tests/Factory/PhpredisClientFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Snc\RedisBundle\Tests\Factory;

use PHPUnit\Framework\TestCase;
use Snc\RedisBundle\Factory\PhpredisClientFactory;
use Snc\RedisBundle\Logger\RedisLogger;

class PhpredisClientFactoryTest extends TestCase
{
protected function setUp()
{
if (!class_exists('\Redis')) {
$this->markTestSkipped(sprintf('The %s requires phpredis extension.', __CLASS__));
}

if (!@fsockopen('127.0.0.1', 6379)) {
$this->markTestSkipped(sprintf('The %s requires a redis instance listening on 127.0.0.1:6379.', __CLASS__));
}

$this->logger = $this->getMockBuilder('Symfony\Component\HttpKernel\Log\LoggerInterface')->getMock();
$this->redisLogger = new RedisLogger($this->logger);
}

public function testCreateMinimalConfig()
{
$factory = new PhpredisClientFactory();

$client = $factory->create('\Redis', 'redis://localhost:6379', array(), 'default');

$this->assertInstanceOf('\Redis', $client);
$this->assertNull($client->getOption(\Redis::OPT_PREFIX));
$this->assertSame(0, $client->getOption(\Redis::OPT_SERIALIZER));
}

/**
* @group redis4
*/
public function testCreateFullConfig()
{
$logger = $this->getMockBuilder('Snc\RedisBundle\Logger\RedisLogger')->getMock();
$factory = new PhpredisClientFactory($logger);

$client = $factory->create(
'\Snc\RedisBundle\Client\Phpredis\Client',
'redis://localhost:6379',
array(
'connection_timeout' => 10,
'connection_persistent' => true,
'prefix' => 'toto',
'serialization' => 'php',
'read_write_timeout' => 4,
),
'alias_test'
);

$this->assertInstanceOf('\Snc\RedisBundle\Client\Phpredis\Client', $client);
$this->assertSame('toto', $client->getOption(\Redis::OPT_PREFIX));
$this->assertSame(1, $client->getOption(\Redis::OPT_SERIALIZER));
$this->assertSame(4., $client->getOption(\Redis::OPT_READ_TIMEOUT));
$this->assertAttributeSame($logger, 'logger', $client);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "https://github.com/snc/SncRedisBundle/contributors"
}],
"require": {
"php": ">=5.3.3",
"php": "^5.3.3 || ^7.0",
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0",
"symfony/yaml": "^2.7 || ^3.0 || ^4.0"
},
Expand Down

0 comments on commit a2fec55

Please sign in to comment.