File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
tests/unit/Framework/MockObject Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -560,6 +560,26 @@ public function testOriginalCloneMethodCanOptionallyBeCalledWhenTestDoubleObject
560560 clone $ double ;
561561 }
562562
563+ #[DoesNotPerformAssertions]
564+ #[TestDox('with() can be used without expects() and is not verified when the method is not called ' )]
565+ public function testWithCanBeUsedWithoutExpectsAndIsNotVerifiedWhenTheMethodIsNotCalled (): void
566+ {
567+ $ double = $ this ->createTestDouble (InterfaceWithReturnTypeDeclaration::class);
568+
569+ $ double ->method ('doSomethingElse ' )->with (1 )->willReturn (2 );
570+ }
571+
572+ public function testWithCanBeUsedWithoutExpectsAndIsVerifiedWhenTheMethodIsCalled (): void
573+ {
574+ $ double = $ this ->createTestDouble (InterfaceWithReturnTypeDeclaration::class);
575+
576+ $ double ->method ('doSomethingElse ' )->with (1 )->willReturn (2 );
577+
578+ $ this ->expectException (ExpectationFailedException::class);
579+
580+ $ double ->doSomethingElse (0 );
581+ }
582+
563583 /**
564584 * @param class-string $type
565585 */
You can’t perform that action at this time.
0 commit comments