Skip to content

Commit aaf88e3

Browse files
authored
Merge pull request #31 from SimonFrings/tests
Clean up test suite, add .gitattributes to exclude dev files from exports and run tests on PHP 7.4 and simplify test matrix
2 parents a73982f + 39031e4 commit aaf88e3

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.travis.yml export-ignore
4+
/examples/ export-ignore
5+
/phpunit.xml.dist export-ignore
6+
/tests/ export-ignore

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
language: php
22

3-
php:
4-
# - 5.3 # requires old distro, see below
5-
- 5.4
6-
- 5.5
7-
- 5.6
8-
- 7
9-
- hhvm # ignore errors, see below
10-
113
# lock distro so new future defaults will not break the build
124
dist: trusty
135

146
matrix:
157
include:
168
- php: 5.3
179
dist: precise
10+
- php: 5.4
11+
- php: 5.5
12+
- php: 5.6
13+
- php: 7.0
14+
- php: 7.1
15+
- php: 7.2
16+
- php: 7.3
17+
- php: 7.4
18+
- php: hhvm-3.18
1819
allow_failures:
19-
- php: hhvm
20+
- php: hhvm-3.18
2021

2122
sudo: false
2223

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"psr-4": { "Clue\\React\\HttpProxy\\": "src/" }
1515
},
1616
"autoload-dev": {
17-
"psr-4": { "Tests\\Clue\\React\\HttpProxy\\": "tests/" }
17+
"psr-4": { "Clue\\Tests\\React\\HttpProxy\\": "tests/" }
1818
},
1919
"require": {
2020
"php": ">=5.3",
@@ -23,7 +23,7 @@
2323
"ringcentral/psr7": "^1.2"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^5.0 || ^4.8",
26+
"phpunit/phpunit": "^7.0 || ^5.0 || ^4.8",
2727
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
2828
"clue/block-react": "^1.1"
2929
}

tests/AbstractTestCase.php

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

3-
namespace Tests\Clue\React\HttpProxy;
3+
namespace Clue\Tests\React\HttpProxy;
44

5-
use PHPUnit_Framework_TestCase;
5+
use PHPUnit\Framework\TestCase;
66

7-
abstract class AbstractTestCase extends PHPUnit_Framework_TestCase
7+
abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase
88
{
99
protected function expectCallableNever()
1010
{
@@ -52,14 +52,7 @@ protected function expectCallableOnceWithException($class, $message, $code)
5252
*/
5353
protected function createCallableMock()
5454
{
55-
return $this->getMockBuilder('Tests\\Clue\\React\\HttpProxy\\CallableStub')->getMock();
56-
}
57-
}
58-
59-
class CallableStub
60-
{
61-
public function __invoke()
62-
{
55+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
6356
}
6457
}
6558

tests/FunctionalTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests\Clue\React\HttpProxy;
3+
namespace Clue\Tests\React\HttpProxy;
44

55
use React\EventLoop\Factory;
66
use Clue\React\HttpProxy\ProxyConnector;
@@ -97,11 +97,25 @@ public function testCancelWhileConnectingShouldNotCreateGarbageCycles()
9797
$proxy = new ProxyConnector('google.com', $this->dnsConnector);
9898

9999
gc_collect_cycles();
100+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
100101

101102
$promise = $proxy->connect('google.com:80');
102103
$promise->cancel();
103104
unset($promise);
104105

105106
$this->assertEquals(0, gc_collect_cycles());
106107
}
108+
109+
public function setExpectedException($exception, $message = '', $code = 0)
110+
{
111+
if (method_exists($this, 'expectException')) {
112+
$this->expectException($exception);
113+
if ($message !== null) {
114+
$this->expectExceptionMessage($message);
115+
}
116+
$this->expectExceptionCode($code);
117+
} else {
118+
parent::setExpectedException($exception, $message, $code);
119+
}
120+
}
107121
}

tests/ProxyConnectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Tests\Clue\React\HttpProxy;
3+
namespace Clue\Tests\React\HttpProxy;
44

55
use Clue\React\HttpProxy\ProxyConnector;
66
use React\Promise\Promise;

0 commit comments

Comments
 (0)