[TYPO3-mvc] Testing entity equality with PHPUNIT
Henrik Møller Rasmussen
info at hmrdesign.dk
Tue Mar 13 11:18:09 CET 2012
And 1 min after writing here I found a solution :)
Fx
$this->account =
$this->getAccessibleMock('Tx_ExtensionName_Domain_Model_Account',
array('dummy'));
$this->account->_set('uid', 1);
echo $this->account->getUid();
Hint: The array('dummy') paramter makes the difference.
From PHPUNIT docs:
When the second (optional) parameter is provided, only the methods whose
names are in the array are replaced with a configurable test double. The
behavior of the other methods is not changed.
Henrik
Den 13/03/12 11.00, Henrik Møller Rasmussen skrev:
> Hi,
>
> I've just started using the PHPUNIT extension to test some Extbase
> models and I have a question regarding entity equality testing.
>
> Lets say I have a service that takes in two entities of the same type
> and returns something based on their equality.
>
> Normally I would in the service use:
> $entity1->getUid() === $entity2->getUid()
>
> to test the equality.
>
> How would you go about mocking the two entities to be different? I have
> mocked all the connections to the repositories, so the entities have no
> uid.
>
> Best regards
>
> Henrik Rasmussen
More information about the TYPO3-project-typo3v4mvc
mailing list