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 @@ -531,6 +531,26 @@ public function testOriginalCloneMethodCanOptionallyBeCalledWhenTestDoubleObject
531531 clone $ double ;
532532 }
533533
534+ #[DoesNotPerformAssertions]
535+ #[TestDox('with() can be used without expects() and is not verified when the method is not called ' )]
536+ public function testWithCanBeUsedWithoutExpectsAndIsNotVerifiedWhenTheMethodIsNotCalled (): void
537+ {
538+ $ double = $ this ->createTestDouble (InterfaceWithReturnTypeDeclaration::class);
539+
540+ $ double ->method ('doSomethingElse ' )->with (1 )->willReturn (2 );
541+ }
542+
543+ public function testWithCanBeUsedWithoutExpectsAndIsVerifiedWhenTheMethodIsCalled (): void
544+ {
545+ $ double = $ this ->createTestDouble (InterfaceWithReturnTypeDeclaration::class);
546+
547+ $ double ->method ('doSomethingElse ' )->with (1 )->willReturn (2 );
548+
549+ $ this ->expectException (ExpectationFailedException::class);
550+
551+ $ double ->doSomethingElse (0 );
552+ }
553+
534554 /**
535555 * @param class-string $type
536556 */
You can’t perform that action at this time.
0 commit comments