Skip to content

Commit 4112a59

Browse files
committed
Skip functional integration tests by default
1 parent e4a02fa commit 4112a59

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ services:
2020

2121
sudo: false
2222

23+
env:
24+
- REDIS_URI=localhost
25+
2326
install:
2427
- composer install --no-interaction
2528

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ To run the test suite, go to the project root and run:
264264
$ php vendor/bin/phpunit
265265
```
266266

267+
The test suite contains both unit tests and functional integration tests.
268+
The functional tests require access to a running Redis server instance
269+
and will be skipped by default.
270+
If you want to also run the functional tests, you need to supply *your* login
271+
details in an environment variable like this:
272+
273+
```bash
274+
$ REDIS_URI=localhost:6379 php vendor/bin/phpunit
275+
```
276+
267277
## License
268278

269279
MIT

tests/FunctionalTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ class FunctionalTest extends TestCase
1414

1515
public function setUp()
1616
{
17+
$uri = getenv('REDIS_URI');
18+
if ($uri === false) {
19+
$this->markTestSkipped('No REDIS_URI environment variable given');
20+
}
21+
1722
$this->loop = new React\EventLoop\StreamSelectLoop();
1823
$this->factory = new Factory($this->loop);
19-
$this->client = $this->createClient();
24+
$this->client = $this->createClient($uri);
2025
}
2126

2227
public function testPing()
@@ -104,7 +109,7 @@ public function testMonitorPing()
104109
public function testPubSub()
105110
{
106111
$consumer = $this->client;
107-
$producer = $this->createClient();
112+
$producer = $this->createClient(getenv('REDIS_URI'));
108113

109114
$channel = 'channel:test:' . mt_rand();
110115

@@ -157,11 +162,12 @@ public function testInvalidServerRepliesWithDuplicateMessages()
157162
}
158163

159164
/**
165+
* @param string $uri
160166
* @return Client
161167
*/
162-
protected function createClient()
168+
protected function createClient($uri)
163169
{
164-
return Block\await($this->factory->createClient(), $this->loop);
170+
return Block\await($this->factory->createClient($uri), $this->loop);
165171
}
166172

167173
protected function createClientResponse($response)

0 commit comments

Comments
 (0)