1111use Patchlevel \EventSourcing \PhpUnit \Test \NoAggregateCreated ;
1212use Patchlevel \EventSourcing \PhpUnit \Test \NoWhenProvided ;
1313use Patchlevel \EventSourcing \PhpUnit \Tests \Unit \Fixture \CreateProfile ;
14+ use Patchlevel \EventSourcing \PhpUnit \Tests \Unit \Fixture \CreateProfileWithFailure ;
1415use Patchlevel \EventSourcing \PhpUnit \Tests \Unit \Fixture \Email ;
1516use Patchlevel \EventSourcing \PhpUnit \Tests \Unit \Fixture \Profile ;
1617use Patchlevel \EventSourcing \PhpUnit \Tests \Unit \Fixture \ProfileCreated ;
@@ -40,7 +41,7 @@ public function testException(): void
4041 ->expectsException (ProfileError::class);
4142
4243 $ test ->assert ();
43- self ::assertSame (2 , $ test ::getCount ());
44+ self ::assertSame (1 , $ test ::getCount ());
4445 }
4546
4647 public function testExceptionMessage (): void
@@ -60,7 +61,7 @@ public function testExceptionMessage(): void
6061 ->expectsExceptionMessage ('throwing so that you can catch it! ' );
6162
6263 $ test ->assert ();
63- self ::assertSame (2 , $ test ::getCount ());
64+ self ::assertSame (1 , $ test ::getCount ());
6465 }
6566
6667 public function testExceptionAndMessage (): void
@@ -81,7 +82,7 @@ public function testExceptionAndMessage(): void
8182 ->expectsExceptionMessage ('throwing so that you can catch it! ' );
8283
8384 $ test ->assert ();
84- self ::assertSame (3 , $ test ::getCount ());
85+ self ::assertSame (2 , $ test ::getCount ());
8586 }
8687
8788 public function testExceptionUncatched (): void
@@ -100,6 +101,24 @@ public function testExceptionUncatched(): void
100101 );
101102
102103 $ this ->expectException (ProfileError::class);
104+ $ test ->assert ();
105+ self ::assertSame (1 , $ test ::getCount ());
106+ }
107+
108+ public function testExceptionWhenCreating (): void
109+ {
110+ $ test = $ this ->getTester ();
111+
112+ $ test
113+ ->when (
114+ new CreateProfileWithFailure (
115+ ProfileId::fromString ('1 ' ),
116+ Email::fromString ('hq@patchlevel.de ' ),
117+ ),
118+ )
119+ ->expectsException (ProfileError::class)
120+ ->expectsExceptionMessage ('throwing so that you can catch it! ' );
121+
103122 $ test ->assert ();
104123 self ::assertSame (2 , $ test ::getCount ());
105124 }
0 commit comments