PHPUnit and Mock Object Exactly Method


<?php
$mapper
->expects($this->exactly(‘2′))->method(‘delete’);
$mapper->expects($this->exactly(2))->method(‘delete’);

?>


The two above lines of code don’t behave the same. When passing in 2 as a string instead of a number, PHPUnit declares it a failure:

Em_Model_Collection_MapperTest::testDeleteCollectionWithJoinTable
Expectation failed for method name is equal to  when invoked 2 time(s).
Method was expected to be called 2 times, actually called 2 times.

Leave a Reply