Skip to content

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 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
language: php

php:
- 5.3
# - 5.3 # requires old distro, see below
- 5.4
- 5.5
- 5.6
- hhvm
- 7.0
- 7.1
- 7.2
- 7.3

# lock distro so future defaults will not break the build
dist: trusty

matrix:
include:
- php: 5.3
dist: precise

install:
- composer install --prefer-source --no-interaction
- composer install --no-interaction

script:
- phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Implements UStar (Uniform Standard Tape ARchive) format, introduced by the POSIX

* [Quickstart example](#quickstart-example)
* [Install](#install)
* [Tests](#tests)
* [License](#license)
* [More](#more)

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

This project aims to run on any platform and thus does not require any PHP
extensions and supports running on legacy PHP 5.3 through current PHP 7+.
It's *highly recommended to use PHP 7+* for this project.

## Tests

To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org):

```bash
$ composer install
```

To run the test suite, go to the project root and run:

```bash
$ php vendor/bin/phpunit
```

## License

MIT
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
"react/stream": "~0.4.0|~0.3.0"
},
"require-dev": {
"clue/hexdump": "~0.2.0",
"react/event-loop": "~0.4.0|~0.3.0",
"react/promise": "~2.0|~1.0",
"clue/hexdump": "~0.2.0"
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
},
"autoload": {
"psr-4": { "Clue\\React\\Tar\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Clue\\Tests\\React\\Tar\\": "tests/" }
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php"
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
5 changes: 5 additions & 0 deletions tests/DecoderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Clue\Tests\React\Tar;

use Clue\React\Tar\Decoder;

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

/**
* @doesNotPerformAssertions
*/
public function testWritingToClosedDecoderDoesNothing()
{
$this->decoder->close();
Expand Down
8 changes: 8 additions & 0 deletions tests/FunctionalDecoderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Clue\Tests\React\Tar;

use Clue\React\Tar\Decoder;
use React\EventLoop\StreamSelectLoop;
use React\Stream\Stream;
Expand All @@ -14,6 +16,9 @@ public function setUp()
$this->loop = new StreamSelectLoop();
}

/**
* @doesNotPerformAssertions
*/
public function testAliceBob()
{
$stream = $this->createStream('alice-bob.tar');
Expand All @@ -23,6 +28,9 @@ public function testAliceBob()
$this->loop->run();
}

/**
* @doesNotPerformAssertions
*/
public function testAliceBobWithSmallBufferSize()
{
$stream = $this->createStream('alice-bob.tar');
Expand Down
31 changes: 31 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Clue\Tests\React\Tar;

class TestCase extends \PHPUnit\Framework\TestCase
{
protected function expectCallableOnce()
{
$mock = $this->createCallableMock();
$mock
->expects($this->once())
->method('__invoke');

return $mock;
}

protected function expectCallableNever()
{
$mock = $this->createCallableMock();
$mock
->expects($this->never())
->method('__invoke');

return $mock;
}

protected function createCallableMock()
{
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
}
}
84 changes: 0 additions & 84 deletions tests/bootstrap.php

This file was deleted.