Skip to content

Commit ec5b137

Browse files
Merge branch '11.5' into 12.5
* 11.5: Document the behaviour discovered in #6504
2 parents fdccb2d + 1d34e5d commit ec5b137

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
@@ -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
*/

0 commit comments

Comments
 (0)