2014-09-22 16:47:48 -04:00
|
|
|
<?php
|
|
|
|
|
2014-09-22 22:38:32 -04:00
|
|
|
namespace Amp\Test;
|
2014-09-22 16:47:48 -04:00
|
|
|
|
2015-05-18 23:57:34 -04:00
|
|
|
use Amp\Promisor;
|
|
|
|
use Amp\Test\PromisorPublicImpl;
|
2014-09-22 16:47:48 -04:00
|
|
|
|
2015-05-18 23:57:34 -04:00
|
|
|
class PromisorPublicTest extends PromisorTest {
|
2015-05-19 18:49:08 -04:00
|
|
|
protected function getPromisor() {
|
|
|
|
return new PromisorPublicImpl;
|
2015-03-16 15:04:01 -04:00
|
|
|
}
|
2015-05-18 23:57:34 -04:00
|
|
|
|
2014-09-22 16:47:48 -04:00
|
|
|
public function testPromiseReturnsSelf() {
|
2015-05-18 23:57:34 -04:00
|
|
|
$promisor = new PromisorPublicImpl;
|
2014-12-01 19:45:57 -05:00
|
|
|
$this->assertSame($promisor, $promisor->promise());
|
2014-09-22 16:47:48 -04:00
|
|
|
}
|
2015-07-21 12:25:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \InvalidArgumentException
|
|
|
|
* @expectedExceptionMessage Throwable Exception instance required to fail a promise
|
|
|
|
* @dataProvider provideBadFailureArguments
|
|
|
|
*/
|
|
|
|
public function testResolvingErrorWithNonExceptionThrows($badArg) {
|
|
|
|
$promisor = $this->getPromisor();
|
|
|
|
$promisor->fail($badArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provideBadFailureArguments() {
|
|
|
|
return [
|
|
|
|
[1],
|
|
|
|
[true],
|
|
|
|
[new \StdClass],
|
|
|
|
];
|
|
|
|
}
|
2014-09-22 16:47:48 -04:00
|
|
|
}
|