Skip to content

Commit 4a2feb7

Browse files
authored
Merge pull request #9 from clue-labs/tests
Improve test suite by adding PHPUnit to `require-dev`, support PHPUnit 7 - legacy PHPUnit 4 and test against legacy PHP 5.3 through PHP 7.3
2 parents 4fd011f + 3668d25 commit 4a2feb7

File tree

8 files changed

+90
-90
lines changed

8 files changed

+90
-90
lines changed

.travis.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
language: php
2+
23
php:
3-
- 5.3
4+
# - 5.3 # requires old distro, see below
5+
- 5.4
6+
- 5.5
47
- 5.6
5-
- hhvm
8+
- 7.0
9+
- 7.1
10+
- 7.2
11+
- 7.3
12+
13+
# lock distro so future defaults will not break the build
14+
dist: trusty
15+
16+
matrix:
17+
include:
18+
- php: 5.3
19+
dist: precise
20+
621
install:
7-
- composer install --prefer-source --no-interaction
22+
- composer install --no-interaction
23+
824
script:
9-
- phpunit --coverage-text
25+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Implements UStar (Uniform Standard Tape ARchive) format, introduced by the POSIX
99

1010
* [Quickstart example](#quickstart-example)
1111
* [Install](#install)
12+
* [Tests](#tests)
1213
* [License](#license)
1314
* [More](#more)
1415

@@ -54,6 +55,25 @@ The recommended way to install this library is [through composer](https://getcom
5455
}
5556
```
5657

58+
This project aims to run on any platform and thus does not require any PHP
59+
extensions and supports running on legacy PHP 5.3 through current PHP 7+.
60+
It's *highly recommended to use PHP 7+* for this project.
61+
62+
## Tests
63+
64+
To run the test suite, you first need to clone this repo and then install all
65+
dependencies [through Composer](https://getcomposer.org):
66+
67+
```bash
68+
$ composer install
69+
```
70+
71+
To run the test suite, go to the project root and run:
72+
73+
```bash
74+
$ php vendor/bin/phpunit
75+
```
76+
5777
## License
5878

5979
MIT

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
"react/stream": "~0.4.0|~0.3.0"
1616
},
1717
"require-dev": {
18+
"clue/hexdump": "~0.2.0",
1819
"react/event-loop": "~0.4.0|~0.3.0",
1920
"react/promise": "~2.0|~1.0",
20-
"clue/hexdump": "~0.2.0"
21+
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
2122
},
2223
"autoload": {
2324
"psr-4": { "Clue\\React\\Tar\\": "src/" }
25+
},
26+
"autoload-dev": {
27+
"psr-4": { "Clue\\Tests\\React\\Tar\\": "tests/" }
2428
}
2529
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit bootstrap="tests/bootstrap.php"
3+
<phpunit bootstrap="vendor/autoload.php"
44
colors="true"
55
convertErrorsToExceptions="true"
66
convertNoticesToExceptions="true"

tests/DecoderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Clue\Tests\React\Tar;
4+
35
use Clue\React\Tar\Decoder;
46

57
class DecoderTest extends TestCase
@@ -27,6 +29,9 @@ public function testWritingInvalidDataWillEmitError()
2729
$this->decoder->write(str_repeat('2', 1024));
2830
}
2931

32+
/**
33+
* @doesNotPerformAssertions
34+
*/
3035
public function testWritingToClosedDecoderDoesNothing()
3136
{
3237
$this->decoder->close();

tests/FunctionalDecoderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Clue\Tests\React\Tar;
4+
35
use Clue\React\Tar\Decoder;
46
use React\EventLoop\StreamSelectLoop;
57
use React\Stream\Stream;
@@ -14,6 +16,9 @@ public function setUp()
1416
$this->loop = new StreamSelectLoop();
1517
}
1618

19+
/**
20+
* @doesNotPerformAssertions
21+
*/
1722
public function testAliceBob()
1823
{
1924
$stream = $this->createStream('alice-bob.tar');
@@ -23,6 +28,9 @@ public function testAliceBob()
2328
$this->loop->run();
2429
}
2530

31+
/**
32+
* @doesNotPerformAssertions
33+
*/
2634
public function testAliceBobWithSmallBufferSize()
2735
{
2836
$stream = $this->createStream('alice-bob.tar');

tests/TestCase.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Clue\Tests\React\Tar;
4+
5+
class TestCase extends \PHPUnit\Framework\TestCase
6+
{
7+
protected function expectCallableOnce()
8+
{
9+
$mock = $this->createCallableMock();
10+
$mock
11+
->expects($this->once())
12+
->method('__invoke');
13+
14+
return $mock;
15+
}
16+
17+
protected function expectCallableNever()
18+
{
19+
$mock = $this->createCallableMock();
20+
$mock
21+
->expects($this->never())
22+
->method('__invoke');
23+
24+
return $mock;
25+
}
26+
27+
protected function createCallableMock()
28+
{
29+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
30+
}
31+
}

tests/bootstrap.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)