Skip to content
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

Run tests on PHPUnit 9 and PHP 7.4, clean up test suite and add .gitattributes to exclude dev files from export (promise-1.x) #175

Merged
merged 4 commits into from
Jul 23, 2020
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
30 changes: 19 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
# lock distro so new future defaults will not break the build
dist: trusty

before_install:
- composer self-update
jobs:
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-3.18

install:
- composer install --prefer-source
- composer install

script:
- phpunit -v --coverage-text
- vendor/bin/phpunit --coverage-text
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
},
"autoload": {
"psr-0": {
"React\\Promise": "src/"
"psr-4": {
"React\\Promise\\": "src/React/Promise/"
},
"files": ["src/React/Promise/functions_include.php"]
},
"autoload-dev": {
"psr-4": {
"React\\Tests\\Promise\\": "tests/React/Promise/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
Expand Down
12 changes: 1 addition & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="false"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Promise Test Suite">
<directory>./tests/React/Promise/</directory>
Expand Down
4 changes: 3 additions & 1 deletion tests/React/Promise/DeferredProgressTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;

/**
* @group Deferred
Expand Down
4 changes: 3 additions & 1 deletion tests/React/Promise/DeferredPromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\DeferredPromise;

/**
* @group Promise
Expand Down
6 changes: 5 additions & 1 deletion tests/React/Promise/DeferredRejectTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;
use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;

/**
* @group Deferred
Expand Down
7 changes: 6 additions & 1 deletion tests/React/Promise/DeferredResolveTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;
use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;
use React\Promise\When;

/**
* @group Deferred
Expand Down
4 changes: 3 additions & 1 deletion tests/React/Promise/DeferredResolverTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\DeferredResolver;

/**
* @group Resolver
Expand Down
6 changes: 4 additions & 2 deletions tests/React/Promise/DeferredTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;

/**
* @group Deferred
Expand Down Expand Up @@ -204,10 +206,10 @@ public function shouldInvokeCancellationHandleWhenCancellingAllDerived()

/**
* @test
* @expectedException InvalidArgumentException
*/
public function shouldThrowIfCancellerIsNotACallable()
{
$this->setExpectedException('InvalidArgumentException');
new Deferred(false);
}
}
4 changes: 2 additions & 2 deletions tests/React/Promise/ErrorCollector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

class ErrorCollector
{
Expand Down Expand Up @@ -33,6 +33,6 @@ public function assertCollectedError($errstr, $errno)

$message = 'Error with level ' . $errno . ' and message "' . $errstr . '" not found in ' . var_export($this->errors, true);

throw new \PHPUnit_Framework_AssertionFailedError($message);
throw new \PHPUnit\Framework\AssertionFailedError($message);
}
}
5 changes: 4 additions & 1 deletion tests/React/Promise/FulfilledPromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;

/**
* @group Promise
Expand Down
6 changes: 5 additions & 1 deletion tests/React/Promise/LazyPromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;
use React\Promise\FulfilledPromise;
use React\Promise\LazyPromise;

/**
* @group Promise
Expand Down
8 changes: 5 additions & 3 deletions tests/React/Promise/PromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Promise;

/**
* @group Promise
Expand All @@ -10,7 +12,7 @@ class PromiseTest extends TestCase
/** @test */
public function shouldThrowIfResolverIsNotACallable()
{
$this->setExpectedException('\InvalidArgumentException');
$this->setExpectedException('InvalidArgumentException');

new Promise(null);
}
Expand Down Expand Up @@ -93,10 +95,10 @@ public function shouldInvokeCancellationHandlerAndStayPendingWhenCallingCancel()

/**
* @test
* @expectedException InvalidArgumentException
*/
public function shouldThrowIfCancellerIsNotACallable()
{
$this->setExpectedException('InvalidArgumentException');
new Promise(function () { }, false);
}
}
5 changes: 4 additions & 1 deletion tests/React/Promise/RejectedPromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;

/**
* @group Promise
Expand Down
10 changes: 0 additions & 10 deletions tests/React/Promise/Stub/CallableStub.php

This file was deleted.

31 changes: 26 additions & 5 deletions tests/React/Promise/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

class TestCase extends \PHPUnit_Framework_TestCase
class TestCase extends \PHPUnit\Framework\TestCase
{
public function expectCallableExactly($amount)
{
Expand Down Expand Up @@ -36,9 +36,13 @@ public function expectCallableNever()

public function createCallableMock()
{
return $this
->getMockBuilder('React\\Promise\Stub\CallableStub')
->getMock();
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
// PHPUnit 9+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
} else {
// legacy PHPUnit 4 - PHPUnit 9
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
}
}

public function invalidCallbackDataProvider()
Expand All @@ -52,4 +56,21 @@ public function invalidCallbackDataProvider()
'falsey' => array(0)
);
}

public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
{
if (method_exists($this, 'expectException')) {
// PHPUnit 5+
$this->expectException($exception);
if ($exceptionMessage !== '') {
$this->expectExceptionMessage($exceptionMessage);
}
if ($exceptionCode !== null) {
$this->expectExceptionCode($exceptionCode);
}
} else {
// legacy PHPUnit 4
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
}
}
}
6 changes: 5 additions & 1 deletion tests/React/Promise/UtilPromiseForTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;
use React\Promise\Util;

/**
* @group Util
Expand Down
6 changes: 5 additions & 1 deletion tests/React/Promise/UtilRejectedPromiseForTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;
use React\Promise\Util;

/**
* @group Util
Expand Down
4 changes: 3 additions & 1 deletion tests/React/Promise/WhenAllTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\When;

/**
* @group When
Expand Down
5 changes: 4 additions & 1 deletion tests/React/Promise/WhenAnyTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;
use React\Promise\When;

/**
* @group When
Expand Down
4 changes: 3 additions & 1 deletion tests/React/Promise/WhenLazyTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\When;

/**
* @group When
Expand Down
4 changes: 3 additions & 1 deletion tests/React/Promise/WhenMapTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\When;

/**
* @group When
Expand Down
5 changes: 4 additions & 1 deletion tests/React/Promise/WhenReduceTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;
use React\Promise\When;

/**
* @group When
Expand Down
5 changes: 4 additions & 1 deletion tests/React/Promise/WhenRejectTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace React\Promise;
namespace React\Tests\Promise;

use React\Promise\Deferred;
use React\Promise\When;

/**
* @group When
Expand Down
Loading