「with」のパラメーターとしてオブジェクトをモックオブジェクトと比較しようとしています。var_dump
期待値と実際値を比較すると、それらは同等に見えます。私の推測では、->with
パラメーターで何か間違ったことをしているということです。前もって感謝します
私のテストコード
public function testAddEntry()
{
$expected = new Entry();
var_dump($expected);
$dbRef = $this->getMock('EntriesDAO');
$dbRef->expects($this->once())->method('insert')
->with($expected);
$actual = EntryHelper::addEntry($dbRef, $req);
テストする機能コード
static function addEntry($iDao, $req)
{
$actual = new Entry();
var_dump($actual);
$actual->newId = $iDao->insert($actual);
コンソールからの出力
class Entry#212 (4) {
public $id =>
NULL
public $content =>
string(0) ""
public $date =>
string(0) ""
public $userId =>
NULL
}
class Entry#209 (4) {
public $id =>
NULL
public $content =>
string(0) ""
public $date =>
string(0) ""
public $userId =>
NULL
}
Time: 0 seconds, Memory: 2.75Mb
There was 1 failure:
1) EntryHelperTest::testAddEntry
Expectation failed for method name is equal to <string:insert> when invoked 1 time(s).
Parameter 0 for invocation EntriesDAO::insert(Entry Object (...)) does not match expected value.
Failed asserting that two objects are equal.