Skip to content

Commit 211801a

Browse files
committed
PSR-4 comliant tests
1 parent cca56e7 commit 211801a

File tree

11 files changed

+58
-21
lines changed

11 files changed

+58
-21
lines changed

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<phpunit>
1+
<phpunit bootstrap="tests/autoload.php">
22
<php>
33
<ini name="display_errors" value="true"/>
44
</php>

tests/Api.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
namespace PhpCrudApi\Tests;
23

34
require_once(__DIR__ . '/../api.php');
45

@@ -12,12 +13,12 @@ class Api
1213
protected $config;
1314

1415
/**
15-
* @var PHP_CRUD_API_Test
16+
* @var PhpCrudApi\Tests\BaseTest
1617
*/
1718
protected $test;
1819

1920
/**
20-
* @var PHP_CRUD_API
21+
* @var \PHP_CRUD_API
2122
*/
2223
protected $api;
2324

@@ -34,7 +35,7 @@ private function action($method,$url,$data='')
3435
$query = isset($url['query'])?$url['query']:'';
3536
parse_str($query,$get);
3637

37-
$this->api = new PHP_CRUD_API(array(
38+
$this->api = new \PHP_CRUD_API(array(
3839
'dbengine'=>$this->config['dbengine'],
3940
'hostname'=>$this->config['hostname'],
4041
'username'=>$this->config['username'],

tests/Config.php.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
namespace PhpCrudApi\Tests;
23

34
class Config
45
{

tests/Config.php.travis

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
namespace PhpCrudApi\Tests;
23

34
class Config
45
{

tests/MysqlTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
require_once(__DIR__ . '/Tests.php');
2+
namespace PhpCrudApi\Tests;
43

54
class MysqlTest extends Tests
65
{

tests/PostgresqlTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
require_once(__DIR__ . '/Tests.php');
2+
namespace PhpCrudApi\Tests;
43

54
class PostgresqlTest extends Tests
65
{

tests/SqlServerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
require_once(__DIR__ . '/Tests.php');
2+
namespace PhpCrudApi\Tests;
43

54
class SqlServerTest extends Tests
65
{

tests/SqliteTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
3-
require_once(__DIR__ . '/Tests.php');
2+
namespace PhpCrudApi\Tests;
43

54
class SqliteTest extends Tests
65
{
@@ -21,10 +20,10 @@ public function getEngineName()
2120
*/
2221
public function connect($config)
2322
{
24-
$db = new SQLite3($config['database']);
23+
$db = new \SQLite3($config['database']);
2524

2625
if (!$db) {
27-
die("Could not open '$database' SQLite database: ".SQLite3::lastErrorMsg().' ('.SQLite3::lastErrorCode().")\n");
26+
die("Could not open '$database' SQLite database: ".\SQLite3::lastErrorMsg().' ('.\SQLite3::lastErrorCode().")\n");
2827
}
2928

3029
return $db;
@@ -49,7 +48,7 @@ public function checkVersion($db)
4948
{
5049
$major = 3;
5150
$minor = 0;
52-
$version = SQLite3::version();
51+
$version = \SQLite3::version();
5352
$v = explode('.',$version['versionString']);
5453
if ($v[0]<$major || ($v[0]==$major && $v[1]<$minor)) {
5554
die("Detected SQLite $v[0].$v[1], but only $major.$minor and up are supported\n");

tests/TestBase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
2+
namespace PhpCrudApi\Tests;
23

3-
require_once(__DIR__ . '/Config.php');
4-
5-
abstract class TestBase extends PHPUnit_Framework_TestCase
4+
abstract class TestBase extends \PHPUnit_Framework_TestCase
65
{
76
public static function setUpBeforeClass()
87
{

tests/Tests.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
2-
3-
require_once(__DIR__ . '/TestBase.php');
4-
require_once(__DIR__ . '/Api.php');
2+
namespace PhpCrudApi\Tests;
53

64
abstract class Tests extends TestBase
75
{

0 commit comments

Comments
 (0)