X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fseekat;a=blobdiff_plain;f=tests%2Fbootstrap.php;h=f25f4ade6f78aa9768691a1fef2300d0ad761950;hp=3d502bee969efba1bc8d3d59b32cd21d6a66891d;hb=d38b3ae03472ba2f9af5009778574b23472bb3f7;hpb=e368287b3cd2dd40945ac8d1a1946bc32268007d diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3d502be..f25f4ad 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -62,11 +62,27 @@ class BaseTest extends \PHPUnit\Framework\TestCase trait ConsumePromise { - function consumePromise(\AsyncInterop\Promise $p, &$errors, &$results) { - $p->when(function($error, $result) use(&$errors, &$results) { - if ($error) $errors[] = $error; - if ($result) $results[] = $result; - }); + function consumePromise($p, &$errors, &$results) { + if (method_exists($p, "done")) { + $p->then(function($result) use(&$results) { + if (isset($result)) { + $results[] = $result; + } + }, function($error) use (&$errors) { + if (isset($error)) { + $errors[] = $error; + } + }); + } else { + $p->onResolve(function($error, $result) use(&$errors, &$results) { + if (isset($error)) { + $errors[] = $error; + } + if (isset($result)) { + $results[] = $result; + } + }); + } } } @@ -93,11 +109,11 @@ trait AssertSuccess trait AssertCancelled { - function assertCancelled(\AsyncInterop\Promise $promise) { + function assertCancelled($promise) { $this->consumePromise($promise, $errors, $results); $this->assertEmpty($results); - $this->assertStringMatchesFormat("%SCancelled%S", $errors[0]->getMessage()); + $this->assertStringMatchesFormat("%SCancelled%S", \seekat\Exception\message($errors[0])); } }