Skip to content

Commit d06726c

Browse files
ZegnatNyholm
authored andcommitted
Split of tests requiring live internet connection (#28)
* Split of tests requiring live internet connection Split of tests requiring live internet connection You may not always have a live internet connection available during testing. By moving all tests that require a live connection into a specific group, they can easily be toggled with `--exclude-group`. This moves some Stream tests into a group called internet. This group name reflects the one used by Guzzle: https://guzzle3.readthedocs.io/testing/unit-testing.html#group-internet-annotation * Add example of running tests without internet
1 parent ff6e248 commit d06726c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Please see the [official documentation](http://docs.php-http.org/en/latest).
3535
$ composer test
3636
```
3737

38+
It is also possible to exclude tests that require a live internet connection:
39+
40+
``` bash
41+
$ composer test -- --exclude-group internet
42+
```
3843

3944
## Contributing
4045

src/StreamIntegrationTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ public function testIsSeekable()
137137
fwrite($resource, 'abcdef');
138138
$stream = $this->createStream($resource);
139139
$this->assertTrue($stream->isSeekable());
140+
}
141+
142+
/**
143+
* @group internet
144+
*/
145+
public function testIsNotSeekable()
146+
{
147+
if (isset($this->skippedTests[__FUNCTION__])) {
148+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
149+
}
140150

141151
$url = 'https://raw.githubusercontent.com/php-http/multipart-stream-builder/master/tests/Resources/httplug.png';
142152
$resource = fopen($url, 'r');
@@ -154,6 +164,16 @@ public function testIsWritable()
154164
fwrite($resource, 'abcdef');
155165
$stream = $this->createStream($resource);
156166
$this->assertTrue($stream->isWritable());
167+
}
168+
169+
/**
170+
* @group internet
171+
*/
172+
public function testIsNotWritable()
173+
{
174+
if (isset($this->skippedTests[__FUNCTION__])) {
175+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
176+
}
157177

158178
$url = 'https://raw.githubusercontent.com/php-http/multipart-stream-builder/master/tests/Resources/httplug.png';
159179
$resource = fopen($url, 'r');
@@ -171,6 +191,16 @@ public function testIsReadable()
171191
fwrite($resource, 'abcdef');
172192
$stream = $this->createStream($resource);
173193
$this->assertTrue($stream->isReadable());
194+
}
195+
196+
/**
197+
* @group internet
198+
*/
199+
public function testIsNotReadable()
200+
{
201+
if (isset($this->skippedTests[__FUNCTION__])) {
202+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
203+
}
174204

175205
$url = 'https://raw.githubusercontent.com/php-http/multipart-stream-builder/master/tests/Resources/httplug.png';
176206
$resource = fopen($url, 'r');
@@ -207,6 +237,7 @@ public function testRewind()
207237
}
208238

209239
/**
240+
* @group internet
210241
* @expectedException \RuntimeException
211242
*/
212243
public function testRewindNotSeekable()

0 commit comments

Comments
 (0)