diff --git a/.travis.yml b/.travis.yml index 0ddaf9a..7b98679 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,9 @@ services: sudo: false +env: + - REDIS_URI=localhost + install: - composer install --no-interaction diff --git a/README.md b/README.md index 2041da0..8acbb4e 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,16 @@ To run the test suite, go to the project root and run: $ php vendor/bin/phpunit ``` +The test suite contains both unit tests and functional integration tests. +The functional tests require access to a running Redis server instance +and will be skipped by default. +If you want to also run the functional tests, you need to supply *your* login +details in an environment variable like this: + +```bash +$ REDIS_URI=localhost:6379 php vendor/bin/phpunit +``` + ## License MIT diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index bf03b94..b7beb6f 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -14,9 +14,14 @@ class FunctionalTest extends TestCase public function setUp() { + $uri = getenv('REDIS_URI'); + if ($uri === false) { + $this->markTestSkipped('No REDIS_URI environment variable given'); + } + $this->loop = new React\EventLoop\StreamSelectLoop(); $this->factory = new Factory($this->loop); - $this->client = $this->createClient(); + $this->client = $this->createClient($uri); } public function testPing() @@ -104,7 +109,7 @@ public function testMonitorPing() public function testPubSub() { $consumer = $this->client; - $producer = $this->createClient(); + $producer = $this->createClient(getenv('REDIS_URI')); $channel = 'channel:test:' . mt_rand(); @@ -157,11 +162,12 @@ public function testInvalidServerRepliesWithDuplicateMessages() } /** + * @param string $uri * @return Client */ - protected function createClient() + protected function createClient($uri) { - return Block\await($this->factory->createClient(), $this->loop); + return Block\await($this->factory->createClient($uri), $this->loop); } protected function createClientResponse($response)