Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / tests / Doctrine / Tests / DBAL / Driver / OCI8 / OCI8StatementTest.php
1 <?php
2
3 namespace Doctrine\Tests\DBAL;
4
5 require_once __DIR__ . '/../../../TestInit.php';
6
7 class OCI8StatementTest extends \Doctrine\Tests\DbalTestCase
8 {
9     public function setUp()
10     {
11         if (!extension_loaded('oci8')) {
12             $this->markTestSkipped('oci8 is not installed.');
13         }
14
15         parent::setUp();
16     }
17
18     /**
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.
21      *
22      * This also verifies that the statement will check with the connection to
23      * see what the current execution mode is.
24      *
25      * The expected exception is due to oci_execute failing due to no valid connection.
26      *
27      * @dataProvider executeDataProvider
28      * @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception
29      */
30     public function testExecute(array $params)
31     {
32         $statement = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Statement',
33             array('bindValue', 'errorInfo'),
34             array(), '', false);
35
36         $statement->expects($this->at(0))
37             ->method('bindValue')
38             ->with(
39                 $this->equalTo(1),
40                 $this->equalTo($params[0])
41             );
42         $statement->expects($this->at(1))
43             ->method('bindValue')
44             ->with(
45                 $this->equalTo(2),
46                 $this->equalTo($params[1])
47             );
48         $statement->expects($this->at(2))
49             ->method('bindValue')
50             ->with(
51                 $this->equalTo(3),
52                 $this->equalTo($params[2])
53           );
54
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');
60
61         $reflProperty = new \ReflectionProperty($statement, '_conn');
62         $reflProperty->setAccessible(true);
63         $reflProperty->setValue($statement, $conn);
64
65         $statement->execute($params);
66     }
67
68     public static function executeDataProvider()
69     {
70         return array(
71             // $hasZeroIndex = isset($params[0]); == true
72             array(
73                 array(0 => 'test', 1 => null, 2 => 'value')
74             ),
75             // $hasZeroIndex = isset($params[0]); == false
76             array(
77                 array(0 => null, 1 => 'test', 2 => 'value')
78             )
79         );
80     }
81
82 }