|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Licensed to CRATE Technology GmbH("Crate") under one or more contributor |
|
4
|
|
|
* license agreements. See the NOTICE file distributed with this work for |
|
5
|
|
|
* additional information regarding copyright ownership. Crate licenses |
|
6
|
|
|
* this file to you under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. You may |
|
8
|
|
|
* obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
14
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
15
|
|
|
* License for the specific language governing permissions and limitations |
|
16
|
|
|
* under the License. |
|
17
|
|
|
* |
|
18
|
|
|
* However, if you have executed another commercial license agreement |
|
19
|
|
|
* with Crate these terms will supersede the license and you may use the |
|
20
|
|
|
* software solely pursuant to the terms of the relevant commercial agreement. |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace CrateIntegrationTest\PDO; |
|
24
|
|
|
|
|
25
|
|
|
use Crate\Stdlib\CrateConst; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Integration tests for {@see \Crate\PDO\PDO} |
|
29
|
|
|
* |
|
30
|
|
|
* @coversNothing |
|
31
|
|
|
* |
|
32
|
|
|
* @group integration |
|
33
|
|
|
*/ |
|
34
|
|
|
class PDOTest extends AbstractIntegrationTest |
|
35
|
|
|
{ |
|
36
|
|
|
public function testWithInvalidSQL() |
|
37
|
|
|
{ |
|
38
|
|
|
$statement = $this->pdo->prepare('bogus sql'); |
|
39
|
|
|
$statement->execute(); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertEquals(4000, $statement->errorCode()); |
|
42
|
|
|
|
|
43
|
|
|
list ($ansiSQLError, $driverError, $driverMessage) = $statement->errorInfo(); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertEquals(42000, $ansiSQLError); |
|
46
|
|
|
$this->assertEquals(CrateConst::ERR_INVALID_SQL, $driverError); |
|
47
|
|
|
$this->assertContains('no viable alternative at input \'bogus\']', $driverMessage); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testDelete() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->insertRows(1); |
|
53
|
|
|
|
|
54
|
|
|
$statement = $this->pdo->prepare('DELETE FROM test_table WHERE id = 1'); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertTrue($statement->execute()); |
|
57
|
|
|
$this->assertEquals(1, $statement->rowCount()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testDeleteWithMultipleAffectedRows() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->insertRows(5); |
|
63
|
|
|
|
|
64
|
|
|
$statement = $this->pdo->prepare('DELETE FROM test_table WHERE id > 1'); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertTrue($statement->execute()); |
|
67
|
|
|
$this->assertEquals(4, $statement->rowCount()); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function testGetServerVersion() |
|
71
|
|
|
{ |
|
72
|
|
|
$result = $this->pdo->getServerVersion(); |
|
73
|
|
|
$this->assertEquals("0.56.3", $result); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|