Skip to content

Commit da12438

Browse files
committed
update/refresh tests to psr-2
1 parent 2462c58 commit da12438

22 files changed

+1315
-1614
lines changed

.gitattributes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/.travis.yml export-ignore
44
/.appveyor.yml export-ignore
55
/.travis.yml export-ignore
6-
#.vscode export-ignore
6+
/.vscode export-ignore
77
/codecov.yml export-ignore
88
/examples export-ignore
9-
#phpunit.xml.dist export-ignore
10-
#tests export-ignore
9+
/phpunit.xml.dist export-ignore
10+
/tests export-ignore
1111
/docs export-ignore
1212
/tmp export-ignore

tests/Bar.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace ezsql\Tests;
44

5-
use ezsql\Tests\ezInterface;
5+
use ezsql\Tests\ezInterface;
66

7-
class Bar implements ezInterface
8-
{
9-
}
10-
7+
class Bar implements ezInterface
8+
{ }

tests/Baz.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ezsql\Tests;
44

5-
use ezsql\Tests\ezInterface;
5+
use ezsql\Tests\ezInterface;
66

77
class Baz
88
{
@@ -12,4 +12,3 @@ public function __construct(ezInterface $foo = null)
1212
$this->foo = $foo;
1313
}
1414
}
15-

tests/ConfigTest.php

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
use ezsql\ConfigInterface;
88
use ezsql\Tests\EZTestCase;
99

10-
class ConfigTest extends EZTestCase
10+
class ConfigTest extends EZTestCase
1111
{
12-
/**
13-
* @covers ezsql\Config::setupMysqli
14-
*/
1512
public function testSetupMysqli()
1613
{
1714
if (!extension_loaded('mysqli')) {
1815
$this->markTestSkipped(
19-
'The MySQLi extension is not available.'
16+
'The MySQLi extension is not available.'
2017
);
2118
}
2219

@@ -31,7 +28,7 @@ public function testInitializeMysqli()
3128
{
3229
if (!extension_loaded('mysqli')) {
3330
$this->markTestSkipped(
34-
'The MySQLi extension is not available.'
31+
'The MySQLi extension is not available.'
3532
);
3633
}
3734

@@ -43,7 +40,7 @@ public function testErrorMysqli()
4340
{
4441
if (!extension_loaded('mysqli')) {
4542
$this->markTestSkipped(
46-
'The MySQLi extension is not available.'
43+
'The MySQLi extension is not available.'
4744
);
4845
}
4946

@@ -52,31 +49,28 @@ public function testErrorMysqli()
5249
$settings = Config::initialize('mysqli', [self::TEST_DB_USER, self::TEST_DB_PASSWORD]);
5350
}
5451

55-
/**
56-
* @covers ezsql\Config::setupPdo
57-
*/
5852
public function testSetupPdo()
5953
{
60-
if ( ! \class_exists ('PDO') ) {
54+
if (!\class_exists('PDO')) {
6155
$this->markTestSkipped(
62-
'The PDO Lib is not available.'
56+
'The PDO Lib is not available.'
6357
);
6458
}
6559

66-
$dsn = 'mysql:host='.self::TEST_DB_HOST.';dbname='. self::TEST_DB_NAME.';port=3306';
60+
$dsn = 'mysql:host=' . self::TEST_DB_HOST . ';dbname=' . self::TEST_DB_NAME . ';port=3306';
6761
$settings = new Config('pdo', [$dsn, self::TEST_DB_USER, self::TEST_DB_PASSWORD]);
6862
$this->assertTrue($settings instanceof ConfigAbstract);
6963
}
7064

7165
public function testInitializePdo()
7266
{
73-
if ( ! \class_exists ('PDO') ) {
67+
if (!\class_exists('PDO')) {
7468
$this->markTestSkipped(
75-
'The PDO Lib is not available.'
69+
'The PDO Lib is not available.'
7670
);
7771
}
7872

79-
$dsn = 'mysql:host='.self::TEST_DB_HOST.';dbname='. self::TEST_DB_NAME.';port=3306';
73+
$dsn = 'mysql:host=' . self::TEST_DB_HOST . ';dbname=' . self::TEST_DB_NAME . ';port=3306';
8074
$settings = Config::initialize('pdo', [$dsn, self::TEST_DB_USER, self::TEST_DB_PASSWORD]);
8175
$this->assertTrue($settings instanceof ConfigAbstract);
8276
$this->assertEquals($dsn, $settings->getDsn());
@@ -86,41 +80,38 @@ public function testInitializePdo()
8680

8781
public function testErrorPdo()
8882
{
89-
if ( ! \class_exists ('PDO') ) {
83+
if (!\class_exists('PDO')) {
9084
$this->markTestSkipped(
91-
'The PDO Lib is not available.'
85+
'The PDO Lib is not available.'
9286
);
9387
}
9488

95-
$dsn = 'mysql:host='.self::TEST_DB_HOST.';dbname='. self::TEST_DB_NAME.';port=3306';
89+
$dsn = 'mysql:host=' . self::TEST_DB_HOST . ';dbname=' . self::TEST_DB_NAME . ';port=3306';
9690
$this->expectException(\Exception::class);
9791
$this->expectExceptionMessageRegExp('/[Missing configuration details to connect to database]/');
9892
$settings = Config::initialize('pdo', [$dsn]);
9993
}
10094

10195
public function test__callPdo()
10296
{
103-
if ( ! \class_exists ('PDO') ) {
97+
if (!\class_exists('PDO')) {
10498
$this->markTestSkipped(
105-
'The PDO Lib is not available.'
99+
'The PDO Lib is not available.'
106100
);
107101
}
108102

109-
$dsn = 'mysql:host='.self::TEST_DB_HOST.';dbname='. self::TEST_DB_NAME.';port=3306';
103+
$dsn = 'mysql:host=' . self::TEST_DB_HOST . ';dbname=' . self::TEST_DB_NAME . ';port=3306';
110104
$this->expectException(\Exception::class);
111105
$this->expectExceptionMessageRegExp('/[does not exist]/');
112106
$settings = new Config('pdo', [$dsn, self::TEST_DB_USER, self::TEST_DB_PASSWORD]);
113107
$settings->getNotAnProperty();
114108
}
115109

116-
/**
117-
* @covers ezsql\Config::setupPgsql
118-
*/
119110
public function testSetupPgsql()
120111
{
121112
if (!extension_loaded('pgsql')) {
122113
$this->markTestSkipped(
123-
'The PostgreSQL Lib is not available.'
114+
'The PostgreSQL Lib is not available.'
124115
);
125116
}
126117

@@ -137,7 +128,7 @@ public function testInitializePgsql()
137128
{
138129
if (!extension_loaded('pgsql')) {
139130
$this->markTestSkipped(
140-
'The PostgreSQL Lib is not available.'
131+
'The PostgreSQL Lib is not available.'
141132
);
142133
}
143134

@@ -149,7 +140,7 @@ public function testErrorPgsql()
149140
{
150141
if (!extension_loaded('pgsql')) {
151142
$this->markTestSkipped(
152-
'The PostgreSQL Lib is not available.'
143+
'The PostgreSQL Lib is not available.'
153144
);
154145
}
155146

@@ -158,14 +149,11 @@ public function testErrorPgsql()
158149
$settings = Config::initialize('pgsql', [self::TEST_DB_USER, self::TEST_DB_PASSWORD]);
159150
}
160151

161-
/**
162-
* @covers ezsql\Config::setupSqlsrv
163-
*/
164152
public function testSetupSqlsrv()
165153
{
166154
if (!extension_loaded('sqlsrv')) {
167155
$this->markTestSkipped(
168-
'The sqlsrv Lib is not available.'
156+
'The sqlsrv Lib is not available.'
169157
);
170158
}
171159

@@ -180,7 +168,7 @@ public function testInitializeSqlsrv()
180168
{
181169
if (!extension_loaded('sqlsrv')) {
182170
$this->markTestSkipped(
183-
'The sqlsrv Lib is not available.'
171+
'The sqlsrv Lib is not available.'
184172
);
185173
}
186174

@@ -192,7 +180,7 @@ public function testErrorSqlsrv()
192180
{
193181
if (!extension_loaded('sqlsrv')) {
194182
$this->markTestSkipped(
195-
'The sqlsrv Lib is not available.'
183+
'The sqlsrv Lib is not available.'
196184
);
197185
}
198186

@@ -201,31 +189,28 @@ public function testErrorSqlsrv()
201189
$settings = new Config('sqlsrv', [self::TEST_DB_USER, self::TEST_DB_PASSWORD]);
202190
}
203191

204-
/**
205-
* @covers ezsql\Config::setupSqlite3
206-
*/
207192
public function testSetupSqlite3()
208193
{
209194
if (!extension_loaded('sqlite3')) {
210195
$this->markTestSkipped(
211-
'The sqlite3 Lib is not available.'
196+
'The sqlite3 Lib is not available.'
212197
);
213198
}
214-
199+
215200
$settings = new Config('sqlite3', [self::TEST_SQLITE_DB_DIR, self::TEST_SQLITE_DB]);
216201
$this->assertTrue($settings instanceof ConfigInterface);
217202
$this->assertEquals(self::TEST_SQLITE_DB_DIR, $settings->getPath());
218203
$this->assertEquals(self::TEST_SQLITE_DB, $settings->getName());
219204
}
220-
205+
221206
public function testInitializeSqlite3()
222207
{
223208
if (!extension_loaded('sqlite3')) {
224209
$this->markTestSkipped(
225-
'The sqlite3 Lib is not available.'
210+
'The sqlite3 Lib is not available.'
226211
);
227212
}
228-
213+
229214
$settings = Config::initialize('sqlite3', [self::TEST_SQLITE_DB_DIR, self::TEST_SQLITE_DB]);
230215
$this->assertTrue($settings instanceof ConfigInterface);
231216
}
@@ -234,32 +219,26 @@ public function testErrorSqlite3()
234219
{
235220
if (!extension_loaded('sqlite3')) {
236221
$this->markTestSkipped(
237-
'The sqlite3 Lib is not available.'
222+
'The sqlite3 Lib is not available.'
238223
);
239224
}
240-
225+
241226
$this->expectException(\Exception::class);
242227
$this->expectExceptionMessageRegExp('/[Missing configuration details to connect to database]/');
243228
$settings = new Config('sqlite3', [self::TEST_SQLITE_DB_DIR]);
244229
}
245230

246-
/**
247-
* @covers ezsql\Config::__construct
248-
*/
249231
public function test_construct()
250232
{
251233
$this->expectException(\Exception::class);
252234
$this->expectExceptionMessageRegExp('/[Missing configuration details to connect to database]/');
253235
$settings = new Config('', [self::TEST_DB_USER, self::TEST_DB_PASSWORD, self::TEST_DB_NAME]);
254236
}
255237

256-
/**
257-
* @covers ezsql\Config::__construct
258-
*/
259238
public function test_constructArgs()
260239
{
261240
$this->expectException(\Exception::class);
262241
$this->expectExceptionMessageRegExp('/[Missing configuration details to connect to database]/');
263242
$settings = new Config('mysqli');
264243
}
265-
}
244+
}

tests/DInjectorTest.php

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,81 +8,69 @@
88
use ezsql\Exception\ContainerException;
99
use ezsql\Exception\NotFoundException;
1010

11-
use ezsql\Tests\ezInterface;
12-
use ezsql\Tests\Baz;
13-
use ezsql\Tests\Bar;
14-
use ezsql\Tests\Foo;
11+
use ezsql\Tests\ezInterface;
12+
use ezsql\Tests\Baz;
13+
use ezsql\Tests\Bar;
14+
use ezsql\Tests\Foo;
1515

16-
class DInjectorTest extends EZTestCase
17-
{
18-
/**
19-
* @covers ezsql\DInjector::set
20-
*/
16+
class DInjectorTest extends EZTestCase
17+
{
2118
public function testSet()
22-
{
19+
{
2320
$container = new DInjector();
2421
$this->assertTrue($container instanceof ContainerInterface);
2522
$container->set('Baz');
2623
$this->assertTrue($container->has('Baz'));
2724
}
2825

29-
/**
30-
* @covers ezsql\DInjector::has
31-
*/
3226
public function testHas()
33-
{
27+
{
3428
$container = new DInjector();
3529
$container->set('Test', 'Test');
3630
$this->assertTrue($container->has('Test'));
3731
$this->assertFalse($container->has('TestOther'));
3832
}
3933

40-
/**
41-
* @covers ezsql\DInjector::autoWire
42-
*/
4334
public function testAutoWire()
44-
{
35+
{
4536
$container = new DInjector();
4637
$container->set('Baz', 'Baz');
4738
$container->set('ezsql\Tests\ezInterface', 'ezsql\Tests\Foo');
48-
$baz = $container->autoWire('ezsql\Tests\Baz');
39+
$baz = $container->autoWire('ezsql\Tests\Baz');
4940
$this->assertTrue($baz instanceof Baz);
5041
$this->assertTrue($baz->foo instanceof Foo);
5142
}
5243

5344
public function testAutoWire_Exception()
54-
{
45+
{
5546
$container = new DInjector();
5647
$this->expectException(\ReflectionException::class);
5748
$baz = $container->autoWire('Baz');
5849
}
5950

6051
public function testAutoWire_Error()
61-
{
52+
{
6253
$container = new DInjector();
6354
$this->expectException(ContainerException::class);
6455
$this->expectExceptionMessageRegExp('/[is not instantiable]/');
6556
$baz = $container->autoWire('ezsql\Tests\Baz');
6657
}
6758

68-
/**
69-
* @covers ezsql\DInjector::get
70-
*/
7159
public function testGet()
72-
{
60+
{
7361
$container = new DInjector();
7462
$container->set('ezsql\Tests\Baz', 'ezsql\Tests\Baz');
7563
$container->set('ezsql\Tests\ezInterface', 'ezsql\Tests\Bar');
76-
$baz = $container->get('ezsql\Tests\Baz');
64+
$baz = $container->get('ezsql\Tests\Baz');
7765
$this->assertTrue($baz instanceof Baz);
7866
$this->assertTrue($baz->foo instanceof Bar);
7967
}
8068

8169
public function testGet_Error()
82-
{
70+
{
8371
$container = new DInjector();
8472
$this->expectException(NotFoundException::class);
8573
$this->expectExceptionMessageRegExp('/[does not exists]/');
8674
$baz = $container->get('Baz');
8775
}
88-
}
76+
}

0 commit comments

Comments
 (0)