Example #1
0
 public function testFetchRow()
 {
     $preparedQuery = $this->getMockBuilder('\\Sindri\\Database\\Query\\PreparedQuery')->disableOriginalConstructor()->getMock();
     $preparedQuery->expects($this->once())->method('fetchRow')->will($this->returnValue(array()));
     $queryMock = $this->getQueryMock();
     $queryMock->expects($this->once())->method('execute')->will($this->returnValue($preparedQuery));
     /** @var $queryMock QueryInterface */
     $proxyQuery = new ProxyQuery($queryMock);
     $queryResult = $proxyQuery->fetchRow();
     $this->assertSame($queryResult, array());
 }
Example #2
0
 /**
  * issue: statement->execute() called twice
  *
  * @see https://github.com/sindriphp/Database/issues/1
  */
 public function testStatementExecuteShouldNotCalledTwice()
 {
     $pdoStatmentMock = $this->getMockBuilder('\\PDOStatement')->getMock();
     $pdoStatmentMock->expects($this->once())->method('execute')->will($this->returnValue(''));
     $pdoMock = $this->getMockBuilder('\\PDO')->setConstructorArgs(array('sqlite::memory:'))->getMock();
     $pdoMock->expects($this->once())->method('prepare')->will($this->returnValue($pdoStatmentMock));
     $actionQueue = new ActionQueue();
     $connectionMock = $this->getMockBuilder('\\Sindri\\Database\\Connection')->setMethods(array('connect'))->setConstructorArgs(array('', '', 'sqlite::memory:', array(), $actionQueue))->getMock();
     $connectionMock->expects($this->any())->method('connect')->will($this->returnValue($pdoMock));
     $openQuery = new OpenQuery(1, $connectionMock, 'SELECT * FROM users', 'Y-m-d H:i:s');
     $query = new ProxyQuery($openQuery);
     $query->fetchAll();
 }