This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
/
ConnectionIntegrationTest.php
executable file
·190 lines (168 loc) · 5.51 KB
/
ConnectionIntegrationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace ZendTest\Db\Adapter\Driver\Sqlsrv;
use Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv;
use Zend\Db\Adapter\Driver\Sqlsrv\Connection;
/**
* @group integration
* @group integration-sqlserver
*/
class ConnectionIntegrationTest extends AbstractIntegrationTest
{
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::getCurrentSchema
*/
public function testGetCurrentSchema()
{
$connection = new Connection($this->variables);
$this->assertInternalType('string', $connection->getCurrentSchema());
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::setResource
*/
public function testSetResource()
{
$resource = sqlsrv_connect(
$this->variables['hostname'], array(
'UID' => $this->variables['username'],
'PWD' => $this->variables['password']
)
);
$connection = new Connection(array());
$this->assertSame($connection, $connection->setResource($resource));
$connection->disconnect();
unset($connection);
unset($resource);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::getResource
*/
public function testGetResource()
{
$connection = new Connection($this->variables);
$connection->connect();
$this->assertInternalType('resource', $connection->getResource());
$connection->disconnect();
unset($connection);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::connect
*/
public function testConnect()
{
$connection = new Connection($this->variables);
$this->assertSame($connection, $connection->connect());
$this->assertTrue($connection->isConnected());
$connection->disconnect();
unset($connection);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::isConnected
*/
public function testIsConnected()
{
$connection = new Connection($this->variables);
$this->assertFalse($connection->isConnected());
$this->assertSame($connection, $connection->connect());
$this->assertTrue($connection->isConnected());
$connection->disconnect();
unset($connection);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::disconnect
*/
public function testDisconnect()
{
$connection = new Connection($this->variables);
$connection->connect();
$this->assertTrue($connection->isConnected());
$connection->disconnect();
$this->assertFalse($connection->isConnected());
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::beginTransaction
* @todo Implement testBeginTransaction().
*/
public function testBeginTransaction()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::commit
* @todo Implement testCommit().
*/
public function testCommit()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::rollback
* @todo Implement testRollback().
*/
public function testRollback()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::execute
*/
public function testExecute()
{
$sqlsrv = new Sqlsrv($this->variables);
$connection = $sqlsrv->getConnection();
$result = $connection->execute('SELECT \'foo\'');
$this->assertInstanceOf('Zend\Db\Adapter\Driver\Sqlsrv\Result', $result);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::prepare
*/
public function testPrepare()
{
$sqlsrv = new Sqlsrv($this->variables);
$connection = $sqlsrv->getConnection();
$statement = $connection->prepare('SELECT \'foo\'');
$this->assertInstanceOf('Zend\Db\Adapter\Driver\Sqlsrv\Statement', $statement);
}
/**
* @covers Zend\Db\Adapter\Driver\Sqlsrv\Connection::getLastGeneratedValue
*/
public function testGetLastGeneratedValue()
{
$this->markTestIncomplete('Need to create a temporary sequence.');
$connection = new Connection($this->variables);
$connection->getLastGeneratedValue();
}
/**
* @group zf3469
*/
public function testConnectReturnsConnectionWhenResourceSet()
{
$resource = sqlsrv_connect(
$this->variables['hostname'], array(
'UID' => $this->variables['username'],
'PWD' => $this->variables['password']
)
);
$connection = new Connection(array());
$connection->setResource($resource);
$this->assertSame($connection, $connection->connect());
$connection->disconnect();
unset($connection);
unset($resource);
}
}