Skip to content

AggregateRootTestCase::expectsException() does not require exception to be thrown #14

@ergosarapu

Description

@ergosarapu

Following test passes, even though notThrowingFunction() does not throw. Could it be a bug?

        $this
        ->given(new SomeEvent())
        ->when(fn (MyAggregate $aggregate) => $aggregate->notThrowingFunction())
        ->then()
        ->expectsException(\LogicException::class);

I noticed that handleException() is only called when exception actually occurs.

if ($this->expectedException) {

Note that using phpunit's TestCase::expectException() properly fails test if exception is not thrown. Maybe I am not understanding the difference between TestCase::expectException() and AggregateRootTestCase::expectsException() properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions