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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"react/promise-timer": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^4.8"
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
}
}
14 changes: 11 additions & 3 deletions tests/FunctionAwaitAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,44 @@ public function testAwaitAllAllResolved()
$this->assertEquals(array('first' => 1, 'second' => 2), Block\awaitAll($all, $this->loop));
}

/**
* @expectedException Exception
* @expectedExceptionMessage test
*/
public function testAwaitAllRejected()
{
$all = array(
$this->createPromiseResolved(1),
$this->createPromiseRejected(new Exception('test'))
);

$this->setExpectedException('Exception', 'test');
Block\awaitAll($all, $this->loop);
}

/**
* @expectedException UnexpectedValueException
*/
public function testAwaitAllRejectedWithFalseWillWrapInUnexpectedValueException()
{
$all = array(
$this->createPromiseResolved(1),
Promise\reject(false)
);

$this->setExpectedException('UnexpectedValueException');
Block\awaitAll($all, $this->loop);
}

/**
* @expectedException Exception
* @expectedExceptionMessage first
*/
public function testAwaitAllOnlyRejected()
{
$all = array(
$this->createPromiseRejected(new Exception('first')),
$this->createPromiseRejected(new Exception('second'))
);

$this->setExpectedException('Exception', 'first');
Block\awaitAll($all, $this->loop);
}

Expand Down
4 changes: 3 additions & 1 deletion tests/FunctionAwaitAnyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ public function testAwaitAnyFirstResolvedConcurrently()
$this->assertEquals(2, Block\awaitAny($all, $this->loop));
}

/**
* @expectedException UnderflowException
*/
public function testAwaitAnyAllRejected()
{
$all = array(
$this->createPromiseRejected(1),
$this->createPromiseRejected(2)
);

$this->setExpectedException('UnderflowException');
Block\awaitAny($all, $this->loop);
}

Expand Down
17 changes: 13 additions & 4 deletions tests/FunctionAwaitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,34 @@

class FunctionAwaitTest extends TestCase
{
/**
* @expectedException Exception
* @expectedExceptionMessage test
*/
public function testAwaitOneRejected()
{
$promise = $this->createPromiseRejected(new Exception('test'));

$this->setExpectedException('Exception', 'test');
Block\await($promise, $this->loop);
}

/**
* @expectedException UnexpectedValueException
*/
public function testAwaitOneRejectedWithFalseWillWrapInUnexpectedValueException()
{
$promise = Promise\reject(false);

$this->setExpectedException('UnexpectedValueException');
Block\await($promise, $this->loop);
}

/**
* @expectedException UnexpectedValueException
*/
public function testAwaitOneRejectedWithNullWillWrapInUnexpectedValueException()
{
$promise = Promise\reject(null);

$this->setExpectedException('UnexpectedValueException');
Block\await($promise, $this->loop);
}

Expand Down Expand Up @@ -61,11 +68,13 @@ public function testAwaitOneInterrupted()
$this->assertEquals(2, Block\await($promise, $this->loop));
}

/**
* @expectedException React\Promise\Timer\TimeoutException
*/
public function testAwaitOncePendingWillThrowOnTimeout()
{
$promise = new Promise\Promise(function () { });

$this->setExpectedException('React\Promise\Timer\TimeoutException');
Block\await($promise, $this->loop, 0.001);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

use PHPUnit\Framework\TestCase as BaseTestCase;
use React\Promise\Deferred;

require_once __DIR__ . '/../vendor/autoload.php';

error_reporting(-1);

class TestCase extends PHPUnit_Framework_TestCase
class TestCase extends BaseTestCase
{
protected $loop;

Expand Down