File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
tests/unit/Framework/MockObject Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -812,6 +812,27 @@ public function testMethodParametersCanOnlyBeConfiguredOnce(): void
812812 $ this ->fail ();
813813 }
814814
815+ #[DoesNotPerformAssertions]
816+ #[TestDox('with() can be used without expects() and is not verified when the method is not called ' )]
817+ public function testWithCanBeUsedWithoutExpectsAndIsNotVerifiedWhenTheMethodIsNotCalled (): void
818+ {
819+ $ double = $ this ->createTestDouble (InterfaceWithReturnTypeDeclaration::class);
820+
821+ $ double ->method ('doSomethingElse ' )->with (1 )->willReturn (2 );
822+ }
823+
824+ #[TestDox('with() can be used without expects() and is verified when the method is called ' )]
825+ public function testWithCanBeUsedWithoutExpectsAndIsVerifiedWhenTheMethodIsCalled (): void
826+ {
827+ $ double = $ this ->createTestDouble (InterfaceWithReturnTypeDeclaration::class);
828+
829+ $ double ->method ('doSomethingElse ' )->with (1 )->willReturn (2 );
830+
831+ $ this ->expectException (ExpectationFailedException::class);
832+
833+ $ double ->doSomethingElse (0 );
834+ }
835+
815836 /**
816837 * @param class-string $type
817838 */
You can’t perform that action at this time.
0 commit comments