本文整理汇总了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
}