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


PHP PDO::expects方法代码示例

本文整理汇总了PHP中PDO::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP PDO::expects方法的具体用法?PHP PDO::expects怎么用?PHP PDO::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PDO的用法示例。


在下文中一共展示了PDO::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: it_should_get_a_game

 /**
  * @test
  */
 public function it_should_get_a_game()
 {
     $game = Game::create();
     $identifier = $game->id();
     $stmt = $this->getMockBuilder('stdClass')->setMethods(['execute', 'rowCount', 'fetchColumn'])->getMock();
     $this->pdo->expects($this->once())->method('prepare')->with($this->equalTo('SELECT data FROM games WHERE id = :id'))->willReturn($stmt);
     $stmt->expects($this->once())->method('execute')->with($this->equalTo([':id' => (string) $identifier]));
     //        $stmt->expects($this->once())
     //            ->method('rowCount')
     //            ->willReturn(1);
     $stmt->expects($this->once())->method('fetchColumn')->willReturn(json_encode($game->toArray()));
     $result = $this->repository->get($identifier);
     $this->assertInstanceOf(Game::class, $result);
     $this->assertEquals($game->toArray(), $result->toArray());
 }
开发者ID:WeCamp,项目名称:flyingliquourice,代码行数:18,代码来源:SqliteGameRepositoryTest.php

示例2: testUnlockNoLock

 public function testUnlockNoLock()
 {
     $this->mutex->expects($this->never())->method('getConnection')->will($this->returnValue($this->pdo));
     $this->pdo->expects($this->never())->method('prepare');
     // The stm should not be executed
     $this->stmtReleaseLock->expects($this->never())->method('execute');
     $result = $this->mutex->unlock();
     $this->assertEquals(false, $result);
 }
开发者ID:phlib,项目名称:mutex,代码行数:9,代码来源:MySQLTest.php

示例3: testFailedAttemptThenSucceeds

 public function testFailedAttemptThenSucceeds()
 {
     $this->factory->expects($this->any())->method('create')->will($this->returnValue($this->pdo));
     $pdoStatement = $this->getMock(\PDOStatement::class);
     $pdoStatement->expects($this->any())->method('execute')->will($this->onConsecutiveCalls($this->throwException(new \PDOException()), $this->returnValue(true)));
     $this->pdo->expects($this->any())->method('prepare')->will($this->returnValue($pdoStatement));
     $this->config->expects($this->any())->method('getMaximumAttempts')->will($this->returnValue(2));
     $this->assertSame($this->pdo, $this->factory->__invoke($this->config));
 }
开发者ID:phlib,项目名称:db,代码行数:9,代码来源:ConnectionFactoryTest.php

示例4: setupDbMultiCall

 public function setupDbMultiCall($calls)
 {
     $stmt = $this->getMock(\PDOStatement::class);
     $stmt->expects($this->any())->method('execute')->will($this->returnValue(true));
     foreach ($calls as $call) {
         $stmt->expects($this->any())->method($call['method'])->will($this->returnValue($call['response']));
     }
     $this->pdo->expects($this->any())->method('prepare')->will($this->returnValue($stmt));
     return $stmt;
 }
开发者ID:phlib,项目名称:flysystem-pdo,代码行数:10,代码来源:PdoAdapterTest.php


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