当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Framework_MockObject_Generator::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:rikaix,项目名称:zf2,代码行数:24,代码来源:TableGatewayTest.php

示例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')));
 }
开发者ID:renatosalvatori,项目名称:visio-crud-zf2,代码行数:45,代码来源:AbstractTableTest.php


注:本文中的PHPUnit_Framework_MockObject_Generator::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。