1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 04:24:42 +01:00
amp/test/FunctionsTest.php
2014-12-04 13:34:42 -05:00

42 lines
1.3 KiB
PHP

<?php
namespace Amp\Test;
class FunctionsTest extends \PHPUnit_Framework_TestCase {
public function testAllResolutionWhenNoPromiseInstancesCombined() {
$promises = [null, 1, 2, true];
\Amp\all($promises)->when(function($e, $r) {
list($a, $b, $c, $d) = $r;
$this->assertNull($a);
$this->assertSame(1, $b);
$this->assertSame(2, $c);
$this->assertSame(true, $d);
});
}
public function testSomeResolutionWhenNoPromiseInstancesCombined() {
$promises = [null, 1, 2, true];
\Amp\some($promises)->when(function($e, $r) {
list($errors, $results) = $r;
list($a, $b, $c, $d) = $results;
$this->assertNull($a);
$this->assertSame(1, $b);
$this->assertSame(2, $c);
$this->assertSame(true, $d);
});
}
public function testAnyResolutionWhenNoPromiseInstancesCombined() {
$promises = [null, 1, 2, true];
\Amp\any($promises)->when(function($e, $r) {
list($errors, $results) = $r;
list($a, $b, $c, $d) = $results;
$this->assertNull($a);
$this->assertSame(1, $b);
$this->assertSame(2, $c);
$this->assertSame(true, $d);
});
}
}