Skip to content

Assert that a callable throws an exception#1

Open
Skyree wants to merge 2 commits into
C-Malet:masterfrom
Skyree:add-assert-callable-exception
Open

Assert that a callable throws an exception#1
Skyree wants to merge 2 commits into
C-Malet:masterfrom
Skyree:add-assert-callable-exception

Conversation

@Skyree

@Skyree Skyree commented Sep 12, 2018

Copy link
Copy Markdown
Collaborator
  • Allows multiple exception assertions within one test

Example

public function fooTest()
{
    $foo = new Foo();
    $callableBar = function () use ($foo) {
        $foo->getBar();
    };
    $callableBaz = function () use ($foo) {
        $foo->getBaz();
    };
    $this->assertCallableThrowsException($callableBar, \RuntimeException::class);
    $this->assertCallableThrowsException($callableBaz, \LogicException::class);
}

@Skyree
Skyree requested a review from velkuns February 21, 2020 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant