2014-09-22 22:47:48 +02:00
|
|
|
<?php
|
|
|
|
|
2014-09-23 04:38:32 +02:00
|
|
|
namespace Amp\Test;
|
2014-09-22 22:47:48 +02:00
|
|
|
|
2015-05-19 05:57:34 +02:00
|
|
|
use Amp\Promisor;
|
|
|
|
use Amp\Test\PromisorPublicImpl;
|
2014-09-22 22:47:48 +02:00
|
|
|
|
2015-05-19 05:57:34 +02:00
|
|
|
class PromisorPublicTest extends PromisorTest {
|
2015-05-20 00:49:08 +02:00
|
|
|
protected function getPromisor() {
|
|
|
|
return new PromisorPublicImpl;
|
2015-03-16 20:04:01 +01:00
|
|
|
}
|
2015-05-19 05:57:34 +02:00
|
|
|
|
2014-09-22 22:47:48 +02:00
|
|
|
public function testPromiseReturnsSelf() {
|
2015-05-19 05:57:34 +02:00
|
|
|
$promisor = new PromisorPublicImpl;
|
2014-12-02 01:45:57 +01:00
|
|
|
$this->assertSame($promisor, $promisor->promise());
|
2014-09-22 22:47:48 +02:00
|
|
|
}
|
2015-07-21 18:25:34 +02: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 22:47:48 +02:00
|
|
|
}
|