3 namespace Doctrine\Tests\DBAL;
5 require_once __DIR__ . '/../../../TestInit.php';
7 class OCI8StatementTest extends \Doctrine\Tests\DbalTestCase
9 public function setUp()
11 if (!extension_loaded('oci8')) {
12 $this->markTestSkipped('oci8 is not installed.');
19 * This scenario shows that when the first parameter is not null
20 * it properly sets $hasZeroIndex to 1 and calls bindValue starting at 1.
22 * This also verifies that the statement will check with the connection to
23 * see what the current execution mode is.
25 * The expected exception is due to oci_execute failing due to no valid connection.
27 * @dataProvider executeDataProvider
28 * @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception
30 public function testExecute(array $params)
32 $statement = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Statement',
33 array('bindValue', 'errorInfo'),
36 $statement->expects($this->at(0))
40 $this->equalTo($params[0])
42 $statement->expects($this->at(1))
46 $this->equalTo($params[1])
48 $statement->expects($this->at(2))
52 $this->equalTo($params[2])
55 // can't pass to constructor since we don't have a real database handle,
56 // but execute must check the connection for the executeMode
57 $conn = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Connection', array('getExecuteMode'), array(), '', false);
58 $conn->expects($this->once())
59 ->method('getExecuteMode');
61 $reflProperty = new \ReflectionProperty($statement, '_conn');
62 $reflProperty->setAccessible(true);
63 $reflProperty->setValue($statement, $conn);
65 $statement->execute($params);
68 public static function executeDataProvider()
71 // $hasZeroIndex = isset($params[0]); == true
73 array(0 => 'test', 1 => null, 2 => 'value')
75 // $hasZeroIndex = isset($params[0]); == false
77 array(0 => null, 1 => 'test', 2 => 'value')