Skip to content

Commit 1d34e5d

Browse files
Document the behaviour discovered in #6504
1 parent 666b33c commit 1d34e5d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/unit/Framework/MockObject/MockObjectTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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
*/

0 commit comments

Comments
 (0)