本文整理匯總了PHP中Dao::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dao::expects方法的具體用法?PHP Dao::expects怎麽用?PHP Dao::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dao
的用法示例。
在下文中一共展示了Dao::expects方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGettingReferenceCachesTheReference
/**
* @covers Dao::getReference
*/
public function testGettingReferenceCachesTheReference()
{
$reference = $this->getMockForAbstractClass('BasicDaoReference', array(), '', false);
$this->dao->expects($this->once())->method('getUserReference')->will($this->returnValue($reference));
self::assertEquals($reference, $this->dao->getReference('user'));
self::assertEquals($reference, $this->dao->getReference('user'));
}
示例2: testReferenceGetsByIdIfPresentDataIsInt
/**
* @covers DaoToOneReference::getReferenced
*/
public function testReferenceGetsByIdIfPresentDataIsInt()
{
$this->getMockForAbstractClass('Dao', array('createDao'), 'BBB_NotAbstractDao2', false);
$this->dao = $this->getMock('BBB_NotAbstractDao2', array('getRecordFromData'), array(), '', false);
$this->record->expects($this->once())->method('getDirectly')->with('address')->will($this->returnValue(123));
$this->dao->expects($this->once())->method('getRecordFromData')->with(array('id' => 123), true, false)->will($this->returnValue('RECORD'));
$reference = new DaoToOneReference($this->dao, 'localKey', 'foreignKey');
self::assertSame('RECORD', $reference->getReferenced($this->record, 'address'));
}
示例3: testRecordCallsLoadIfAnAttributeWasNotSetYet
public function testRecordCallsLoadIfAnAttributeWasNotSetYet()
{
$record = new Record(array('id' => 4), $this->dao, TRUE);
$this->dao->expects($this->any())->method('getAttributes')->will($this->returnValue(array('id' => Dao::INT, 'name' => Dao::STRING)));
$this->dao->expects($this->once())->method('getData')->with(array('id' => 4))->will($this->returnValue(array('id' => 4, 'name' => 'Test')));
self::assertEquals('Test', $record->get('name'));
self::assertEquals('Test', $record->get('name'));
// Checking it doesn't load twice
}