本文整理汇总了PHP中PHPUnit_Framework_MockObject_Generator::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_Generator::expects方法的具体用法?PHP PHPUnit_Framework_MockObject_Generator::expects怎么用?PHP PHPUnit_Framework_MockObject_Generator::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_MockObject_Generator
的用法示例。
在下文中一共展示了PHPUnit_Framework_MockObject_Generator::expects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
// mock the adapter, driver, and parts
$mockResult = $this->getMock('Zend\\Db\\Adapter\\Driver\\ResultInterface');
$mockResult->expects($this->any())->method('getAffectedRows')->will($this->returnValue(5));
$mockStatement = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface');
$mockStatement->expects($this->any())->method('execute')->will($this->returnValue($mockResult));
$mockConnection = $this->getMock('Zend\\Db\\Adapter\\Driver\\ConnectionInterface');
$mockConnection->expects($this->any())->method('getLastGeneratedValue')->will($this->returnValue(10));
$mockDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface');
$mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement));
$mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection));
$this->mockAdapter = $this->getMock('Zend\\Db\\Adapter\\Adapter', null, array($mockDriver));
$this->mockSql = $this->getMock('Zend\\Db\\Sql\\Sql', array('select', 'insert', 'update', 'delete'), array($this->mockAdapter, 'foo'));
$this->mockSql->expects($this->any())->method('select')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Select', array('where', 'getRawSate'), array('foo'))));
$this->mockSql->expects($this->any())->method('insert')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Insert', array('prepareStatement', 'values'), array('foo'))));
$this->mockSql->expects($this->any())->method('update')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Update', array('where'), array('foo'))));
$this->mockSql->expects($this->any())->method('delete')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Delete', array('where'), array('foo'))));
$this->table = new TableGateway('foo', $this->mockAdapter, null, $this->mockSql);
}
示例2: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
// mock the adapter, driver, and parts
$mockResult = $this->getMock('Zend\\Db\\Adapter\\Driver\\ResultInterface');
$mockResult->expects($this->any())->method('getAffectedRows')->will($this->returnValue(5));
$mockResult->expects($this->any())->method('current')->will($this->returnValue(5));
$mockStatement = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface');
$mockStatement->expects($this->any())->method('execute')->will($this->returnValue($mockResult));
$mockConnection = $this->getMock('Zend\\Db\\Adapter\\Driver\\ConnectionInterface');
$mockConnection->expects($this->any())->method('getLastGeneratedValue')->will($this->returnValue(10));
$mockDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface');
$mockDriver->expects($this->any())->method('createStatement')->will($this->returnValue($mockStatement));
$mockDriver->expects($this->any())->method('getConnection')->will($this->returnValue($mockConnection));
$this->mockAdapter = $this->getMock('Zend\\Db\\Adapter\\Adapter', null, array($mockDriver));
$this->mockSql = $this->getMock('Zend\\Db\\Sql\\Sql', array('select', 'insert', 'update', 'delete'), array($this->mockAdapter, 'foo'));
$this->mockSql->expects($this->any())->method('select')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Select', array('where', 'getRawSate'), array('foo'))));
$this->mockSql->expects($this->any())->method('insert')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Insert', array('prepareStatement', 'values'), array('foo'))));
$this->mockSql->expects($this->any())->method('update')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Update', array('where'), array('foo'))));
$this->mockSql->expects($this->any())->method('delete')->will($this->returnValue($this->getMock('Zend\\Db\\Sql\\Delete', array('where'), array('foo'))));
$this->table = $this->getMockForAbstractClass('VisioCrudModeler\\Model\\TableGateway\\AbstractTable', array($this->mockAdapter, 'test'));
$tgReflection = new \ReflectionClass('VisioCrudModeler\\Model\\TableGateway\\AbstractTable');
foreach ($tgReflection->getProperties() as $tgPropReflection) {
$tgPropReflection->setAccessible(true);
switch ($tgPropReflection->getName()) {
case 'adapter':
$tgPropReflection->setValue($this->table, $this->mockAdapter);
break;
case 'sql':
$tgPropReflection->setValue($this->table, $this->mockSql);
break;
case 'keyName':
$tgPropReflection->setValue($this->table, 'id');
break;
case 'table':
$tgPropReflection->setValue($this->table, 'foo');
break;
}
}
$this->entity = $this->getMock('VisioCrudModeler\\Model\\TableGateway\\Entity\\AbstractEntity');
$this->entity->expects($this->any())->method('getArrayCopy')->will($this->returnValue(array('id' => 5, 'foo' => 'bar')));
}