public function testCreateStatement()
 {
     $driver = new IbmDb2(array());
     $resource = db2_connect($this->variables['database'], $this->variables['username'], $this->variables['password']);
     $stmtResource = db2_prepare($resource, 'SELECT 1 FROM SYSIBM.SYSDUMMY1');
     $driver->getConnection()->setResource($resource);
     $stmt = $driver->createStatement('SELECT 1 FROM SYSIBM.SYSDUMMY1');
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Statement', $stmt);
     $stmt = $driver->createStatement($stmtResource);
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Statement', $stmt);
     $stmt = $driver->createStatement();
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Statement', $stmt);
     $this->setExpectedException('Zend\\Db\\Adapter\\Exception\\InvalidArgumentException', 'only accepts an SQL string or a ibm_db2 resource');
     $driver->createStatement(new \stdClass());
 }
示例#2
0
 /**
  * @depends testRegisterConnection
  * @covers Zend\Db\Adapter\Driver\IbmDb2\IbmDb2::getConnection
  */
 public function testGetConnection($mockConnection)
 {
     $conn = new \Zend\Db\Adapter\Driver\IbmDb2\Connection(array());
     $this->ibmdb2->registerConnection($conn);
     $this->assertSame($conn, $this->ibmdb2->getConnection());
 }
 /**
  * @covers Zend\Db\Adapter\Driver\IbmDb2\Connection::execute
  */
 public function testExecute()
 {
     $ibmdb2 = new IbmDb2($this->variables);
     $connection = $ibmdb2->getConnection();
     $result = $connection->execute('SELECT \'foo\' FROM SYSIBM.SYSDUMMY1');
     $this->assertInstanceOf('Zend\\Db\\Adapter\\Driver\\IbmDb2\\Result', $result);
 }