Skip to content
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
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/examples/ export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
21 changes: 10 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
language: php

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

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

matrix:
include:
- php: 5.3
dist: precise
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: hhvm-3.18
allow_failures:
- php: hhvm
- php: hhvm-3.18

sudo: false

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
"rize/uri-template": "^0.3"
},
"require-dev": {
"phpunit/phpunit": "^6.0 || ^5.7 || ^4.8.35"
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35"
},
"autoload": {
"psr-4": { "Clue\\React\\Packagist\\Api\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Clue\\Tests\\React\\Api\\": "tests/" }
}
}
9 changes: 2 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Packagist React Test Suite">
<directory>./tests/</directory>
Expand All @@ -16,4 +11,4 @@
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
</phpunit>
6 changes: 4 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Clue\Tests\React\Api;

use Clue\React\Packagist\Api\Client;
use React\Promise\Deferred;
use RingCentral\Psr7\Response;
Expand Down Expand Up @@ -68,7 +70,7 @@ public function testSearchPagination()
public function testSearchRejectsWhenRequestRejects()
{
$this->browser->expects($this->once())->method('get')->willReturn(
$this->createRejectedPromise(new RuntimeException())
$this->createRejectedPromise(new \RuntimeException())
);

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

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

$this->expectPromiseReject($this->client->get('clue/invalid'));
}
Expand Down
36 changes: 17 additions & 19 deletions tests/bootstrap.php → tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<?php

use PHPUnit\Framework\TestCase as BaseTestCase;
namespace Clue\Tests\React\Api;

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

class TestCase extends BaseTestCase
{
protected function expectCallableOnce()
{
$mock = $this->createCallableMock();

$mock
->expects($this->once())
->method('__invoke');

return $mock;
}

protected function expectCallableOnceWith($value)
{
$mock = $this->createCallableMock();

if (func_num_args() > 0) {
$mock
->expects($this->once())
->method('__invoke')
->with($this->equalTo(func_get_arg(0)));
} else {
$mock
->expects($this->once())
->method('__invoke');
}
$mock
->expects($this->once())
->method('__invoke')
->with($value);

return $mock;
}
Expand All @@ -37,13 +41,7 @@ protected function expectCallableNever()

protected function expectCallableOnceParameter($type)
{
$mock = $this->createCallableMock();
$mock
->expects($this->once())
->method('__invoke')
->with($this->isInstanceOf($type));

return $mock;
return $this->expectCallableOnceWith($this->isInstanceOf($type));
}

protected function createCallableMock()
Expand Down