Skip to content

Commit

Permalink
added catch test
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-yulin committed Apr 26, 2020
1 parent ad82a41 commit 457b34c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/ExtSwoolePromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,20 @@ public function testPromiseAllException(): void
$this->assertInstanceOf(RuntimeException::class, $value);
});
}

/**
* Test promise catch
*
*
* @return void
*/
public function testPromiseCatch(): void
{
$promise = ExtSwoolePromise::create(function ($resolver) {
throw new RuntimeException();
});
$promise->catch(function ($value) {
$this->assertInstanceOf(RuntimeException::class, $value);
});
}
}
18 changes: 18 additions & 0 deletions test/PromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,22 @@ public function testPromiseAllException(): void
});
$promise->wait();
}

/**
* Test promise catch
*
*
* @return void
*/
public function testPromiseCatch(): void
{
/** @var Promise $promise */
$promise = Promise::create(function ($resolver) {
throw new RuntimeException();
});
$promise->catch(function ($value) {
$this->assertInstanceOf(RuntimeException::class, $value);
});
$promise->wait();
}
}

0 comments on commit 457b34c

Please sign in to comment.