|
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
|
|
|
namespace Crate\Test\DBAL\Functional; |
|
23
|
|
|
|
|
24
|
|
|
use Crate\Test\DBAL\DBALFunctionalTestCase; |
|
25
|
|
|
use Crate\PDO\PDO; |
|
26
|
|
|
|
|
27
|
|
|
class ConnectionTestCase extends DBALFunctionalTestCase |
|
28
|
|
|
{ |
|
29
|
|
|
public function setUp() : void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->resetSharedConn(); |
|
32
|
|
|
parent::setUp(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function tearDown() : void |
|
36
|
|
|
{ |
|
37
|
|
|
parent::tearDown(); |
|
38
|
|
|
$this->resetSharedConn(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testBasicAuthConnection() |
|
42
|
|
|
{ |
|
43
|
|
|
$auth = ['crate', 'secret']; |
|
44
|
|
|
$params = array( |
|
45
|
|
|
'driverClass' => 'Crate\DBAL\Driver\PDOCrate\Driver', |
|
46
|
|
|
'host' => 'localhost', |
|
47
|
|
|
'port' => 4200, |
|
48
|
|
|
'user' => $auth[0], |
|
49
|
|
|
'password' => $auth[1], |
|
50
|
|
|
); |
|
51
|
|
|
$conn = \Doctrine\DBAL\DriverManager::getConnection($params); |
|
52
|
|
|
$this->assertEquals($auth[0], $conn->getUsername()); |
|
|
|
|
|
|
53
|
|
|
$this->assertEquals($auth[1], $conn->getPassword()); |
|
|
|
|
|
|
54
|
|
|
$auth_attr = $conn->getWrappedConnection()->getAttribute(PDO::CRATE_ATTR_HTTP_BASIC_AUTH); |
|
|
|
|
|
|
55
|
|
|
$this->assertEquals($auth_attr, $auth); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testGetConnection() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->assertInstanceOf('Doctrine\DBAL\Connection', $this->_conn); |
|
61
|
|
|
$this->assertInstanceOf('Crate\DBAL\Driver\PDOCrate\PDOConnection', $this->_conn->getWrappedConnection()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testGetDriver() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->assertInstanceOf('Crate\DBAL\Driver\PDOCrate\Driver', $this->_conn->getDriver()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testStatement() |
|
70
|
|
|
{ |
|
71
|
|
|
$sql = 'SELECT * FROM sys.cluster'; |
|
72
|
|
|
$stmt = $this->_conn->prepare($sql); |
|
73
|
|
|
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); |
|
74
|
|
|
$this->assertInstanceOf('Crate\PDO\PDOStatement', $stmt->getWrappedStatement()); |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function testConnect() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->assertTrue($this->_conn->connect()); |
|
81
|
|
|
|
|
82
|
|
|
$stmt = $this->_conn->query('select * from sys.cluster'); |
|
83
|
|
|
$this->assertEquals(1, $stmt->rowCount()); |
|
84
|
|
|
|
|
85
|
|
|
$row = $stmt->fetch(); |
|
86
|
|
|
$this->assertEquals('crate', $row['name']); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|