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

Adding unique ID per mock object so that they aren’t equal (__phpunit_mockObjectId) #85

Merged
merged 1 commit into from
Mar 7, 2012

Conversation

lstrojny
Copy link
Contributor

@lstrojny lstrojny commented Mar 7, 2012

Adds a per mock object unique ID to prevent mock object from begin equal. Otherwise this test case will succeed per default nevertheless it is faulty:

<?php
class Test extends PHPUnit_Framework_TestCase
{
    function testEqual()
    {
        $mock1 = $this->getMock('stdClass');
        $mock2 = $this->getMock('stdClass');

        $sut = $this->getMock('SplFixedArray');
        $sut->expects($this->once())
            ->method('offsetSet')
            ->with(0, $mock1);

        // This should fail
        $sut->offsetSet(0, $mock2);
    }
}

@sebastianbergmann sebastianbergmann merged commit 37bf709 into sebastianbergmann:master Mar 7, 2012
@lstrojny
Copy link
Contributor Author

lstrojny commented Mar 7, 2012

Thanks! That was fast.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants