Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Added additional test cases on how #100 affects the mock comparator a…
Browse files Browse the repository at this point in the history
…nd a failing test in that regard

Changing Framework/MockObject/Generator/mocked_clone.tpl.dist to:

    public function __clone()
    {
        if ($this->__phpunit_invocationMocker !== NULL) {
            $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker;
        }
    }

maybe helps but the test still doesn't pass.
  • Loading branch information
edorian committed Oct 15, 2012
1 parent be7772f commit b167e11
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Tests/MockObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,26 @@ public function testMockObjectsConstructedIndepentantlyShouldNotEqual()
$this->assertNotEquals($a,$b);
}

public function testClonedMockObjectCanBeUsedInPlaceOfOriginalOne()
{
$x = $this->getMock('stdClass');
$y = clone $x;

$mock = $this->getMock('stdClass', array('foo'));
$mock->expects($this->once())->method('foo')->with($this->equalTo($x));
$mock->foo($y);
}

public function testClonedMockObjectIsNotIdenticalToOriginalOne()
{
$x = $this->getMock('stdClass');
$y = clone $x;

$mock = $this->getMock('stdClass', array('foo'));
$mock->expects($this->once())->method('foo')->with($this->logicalNot($this->identicalTo($x)));
$mock->foo($y);
}

public function testStaticMethodCallWithArgumentCloningEnabled()
{
$expectedObject = new StdClass;
Expand Down

1 comment on commit b167e11

@edorian
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastianbergmann During fixing the issue in #100 that actually impacted a couple of real life projects I expanded on the test cases and ran into another issue.

I couldn't find any real world case where there was a problem but I've committed it for now as I'd say it's the expected behavior.

All in all it should improve the state of afairs without breaking things. I'll asks for pointers if I'll see you tomorrow

Please sign in to comment.