1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00
amp/test/FunctionsTest.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2014-12-04 19:34:42 +01:00
<?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);
});
}
}