mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
42 lines
1.3 KiB
PHP
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);
|
|
});
|
|
}
|
|
}
|