8000 Merge pull request #15 from SimonFrings/tests · clue/reactphp-packagist-api@518f1d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 518f1d7

Browse files
authored
Merge pull request #15 from SimonFrings/tests
Run tests on PHP 7.4 and simplify test matrix, clean up test suite and add .gitattributes to exclude dev files from exports
2 parents 07ba220 + 948f49d commit 518f1d7

File tree

6 files changed

+43
-40
lines changed

6 files changed

+43
-40
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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
language: php
22

3-
php:
4-
# - 5.3 # requires old distro
5-
- 5.4
6-
- 5.5
7-
- 5.6
8-
- 7.0
9-
- 7.1
10-
- 7.2
11-
- hhvm # ignore errors, see below
12-
133
# lock distro so new future defaults will not break the build
144
dist: trusty
155

166
matrix:
177
include:
188
- php: 5.3
199
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
2019
allow_failures:
21-
- php: hhvm
20+
- php: hhvm-3.18
2221

2322
sudo: false
2423

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
"rize/uri-template": "^0.3"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^6.0 || ^5.7 || ^4.8.35"
20+
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35"
2121
},
2222
"autoload": {
2323
"psr-4": { "Clue\\React\\Packagist\\Api\\": "src/" }
24+
},
25+
"autoload-dev": {
26+
"psr-4": { "Clue\\Tests\\React\\Api\\": "tests/" }
2427
}
2528
}

phpunit.xml.dist

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

3-
<phpunit bootstrap="tests/bootstrap.php"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
>
3+
<phpunit bootstrap="vendor/autoload.php" colors="true">
94
<testsuites>
105
<testsuite name="Packagist React Test Suite">
116
<directory>./tests/</directory>
@@ -16,4 +11,4 @@
1611
<directory>./src/</directory>
1712
</whitelist>
1813
</filter>
19-
</phpunit>
14+
</phpunit>

tests/ClientTest.php

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

3+
namespace Clue\Tests\React\Api;
4+
35
use Clue\React\Packagist\Api\Client;
46
use React\Promise\Deferred;
57
use RingCentral\Psr7\Response;
@@ -68,7 +70,7 @@ public function testSearchPagination()
6870
public function testSearchRejectsWhenRequestRejects()
6971
{
7072
$this->browser->expects($this->once())->method('get')->willReturn(
71-
$this->createRejectedPromise(new RuntimeException())
73+
$this->createRejectedPromise(new \RuntimeException())
7274
);
7375

7476
$promise = $this->client->search('foo');
@@ -103,7 +105,7 @@ public function testSearchCancelPendingPromiseWillCancelNextRequestWhenInitialIs
103105

104106
public function testHttpError()
105107
{
106-
$this->setupBrowser('/packages/clue%2Finvalid.json', $this->createRejectedPromise(new RuntimeException('error')));
108+
$this->setupBrowser('/packages/clue%2Finvalid.json', $this->createRejectedPromise(new \RuntimeException('error')));
107109

108110
$this->expectPromiseReject($this->client->get('clue/invalid'));
109111
}

tests/bootstrap.php renamed to tests/TestCase.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
<?php
22

3-
use PHPUnit\Framework\TestCase as BaseTestCase;
3+
namespace Clue\Tests\React\Api;
44

5-
require_once __DIR__ . '/../vendor/autoload.php';
5+
use PHPUnit\Framework\TestCase as BaseTestCase;
66

77
class TestCase extends BaseTestCase
88
{
99
protected function expectCallableOnce()
1010
{
1111
$mock = $this->createCallableMock();
1212

13+
$mock
14+
->expects($this->once())
15+
->method('__invoke');
16+
17+
return $mock;
18+
}
19+
20+
protected function expectCallableOnceWith($value)
21+
{
22+
$mock = $this->createCallableMock();
1323

14-
if (func_num_args() > 0) {
15-
$mock
16-
->expects($this->once())
17-
->method('__invoke')
18-
->with($this->equalTo(func_get_arg(0)));
19-
} else {
20-
$mock
21-
->expects($this->once())
22-
->method('__invoke');
23-
}
24+
$mock
25+
->expects($this->once())
26+
->method('__invoke')
27+
->with($value);
2428

2529
return $mock;
2630
}
@@ -37,13 +41,7 @@ protected function expectCallableNever()
3741

3842
protected function expectCallableOnceParameter($type)
3943
{
40-
$mock = $this->createCallableMock();
41-
$mock
42-
->expects($this->once())
43-
->method('__invoke')
44-
->with($this->isInstanceOf($type));
45-
46-
return $mock;
44+
return $this->expectCallableOnceWith($this->isInstanceOf($type));
4745
}
4846

4947
protected function createCallableMock()

0 commit comments

Comments
 (0)
0