Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
* use only core classes for testing
Browse files Browse the repository at this point in the history
* with one exception (for now) PHPUnit_Extensions_Database_TestCase
  • Loading branch information
DarkSide666 committed Mar 22, 2018
1 parent 98efbdf commit 4883305
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 61 deletions.
2 changes: 1 addition & 1 deletion phpunit-mysql.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit bootstrap="vendor/autoload.php">
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\PHPUnit_AgileResultPrinter">
<php>
<var name="DB_DSN" value="mysql:dbname=dsql_test;host=localhost" />
<var name="DB_USER" value="travis" />
Expand Down
2 changes: 1 addition & 1 deletion phpunit-pgsql.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit bootstrap="vendor/autoload.php">
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\PHPUnit_AgileResultPrinter">
<php>
<var name="DB_DSN" value="pgsql:dbname=atk4-dsql-test;host=localhost" />
<var name="DB_USER" value="postgres" />
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit bootstrap="vendor/autoload.php">
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\PHPUnit_AgileResultPrinter">
<php>
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="travis" />
Expand Down
2 changes: 1 addition & 1 deletion tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @coversDefaultClass \atk4\dsql\ConnectionTest
*/
class ConnectionTest extends \PHPUnit_Framework_TestCase
class ConnectionTest extends \atk4\core\PHPUnit_AgileTestCase
{
/**
* Test constructor.
Expand Down
2 changes: 1 addition & 1 deletion tests/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @coversDefaultClass \atk4\dsql\Exception
*/
class ExceptionTest extends \PHPUnit_Framework_TestCase
class ExceptionTest extends \atk4\core\PHPUnit_AgileTestCase
{
/**
* Test constructor.
Expand Down
38 changes: 19 additions & 19 deletions tests/ExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @coversDefaultClass \atk4\dsql\Expression
*/
class ExpressionTest extends \PHPUnit_Framework_TestCase
class ExpressionTest extends \atk4\core\PHPUnit_AgileTestCase
{
public function e()
{
Expand Down Expand Up @@ -286,57 +286,57 @@ public function testEscape()
// escaping expressions
$this->assertEquals(
'"first_name"',
PHPUnitUtil::callProtectedMethod($this->e(), '_escape', ['first_name'])
$this->callProtected($this->e(), '_escape', ['first_name'])
);
$this->assertEquals(
'"123"',
PHPUnitUtil::callProtectedMethod($this->e(), '_escape', [123])
$this->callProtected($this->e(), '_escape', [123])
);
$this->assertEquals(
'"he""llo"',
PHPUnitUtil::callProtectedMethod($this->e(), '_escape', ['he"llo'])
$this->callProtected($this->e(), '_escape', ['he"llo'])
);

// should not escape expressions
$this->assertEquals(
'*',
PHPUnitUtil::callProtectedMethod($this->e(), '_escapeSoft', ['*'])
$this->callProtected($this->e(), '_escapeSoft', ['*'])
);
$this->assertEquals(
'"*"',
PHPUnitUtil::callProtectedMethod($this->e(), '_escape', ['*'])
$this->callProtected($this->e(), '_escape', ['*'])
);
$this->assertEquals(
'(2+2) age',
PHPUnitUtil::callProtectedMethod($this->e(), '_escapeSoft', ['(2+2) age'])
$this->callProtected($this->e(), '_escapeSoft', ['(2+2) age'])
);
$this->assertEquals(
'"(2+2) age"',
PHPUnitUtil::callProtectedMethod($this->e(), '_escape', ['(2+2) age'])
$this->callProtected($this->e(), '_escape', ['(2+2) age'])
);
$this->assertEquals(
'"users"."first_name"',
PHPUnitUtil::callProtectedMethod($this->e(), '_escapeSoft', ['users.first_name'])
$this->callProtected($this->e(), '_escapeSoft', ['users.first_name'])
);
$this->assertEquals(
'"users".*',
PHPUnitUtil::callProtectedMethod($this->e(), '_escapeSoft', ['users.*'])
$this->callProtected($this->e(), '_escapeSoft', ['users.*'])
);
$this->assertEquals(
true,
PHPUnitUtil::callProtectedMethod($this->e(), '_escapeSoft', [new \stdClass()]) instanceof \stdClass
$this->callProtected($this->e(), '_escapeSoft', [new \stdClass()]) instanceof \stdClass
);

// escaping array - escapes each of its elements using hard escape
$this->assertEquals(
['"first_name"', '*', '"last_name"'],
PHPUnitUtil::callProtectedMethod($this->e(), '_escapeSoft', [['first_name', '*', 'last_name']])
$this->callProtected($this->e(), '_escapeSoft', [['first_name', '*', 'last_name']])
);

// escaping array - escapes each of its elements using hard escape
$this->assertEquals(
['"first_name"', '"*"', '"last_name"'],
PHPUnitUtil::callProtectedMethod($this->e(), '_escape', [['first_name', '*', 'last_name']])
$this->callProtected($this->e(), '_escape', [['first_name', '*', 'last_name']])
);

$this->assertEquals(
Expand Down Expand Up @@ -392,19 +392,19 @@ public function testConsume()
// few brief tests on _consume
$this->assertEquals(
'"123"',
PHPUnitUtil::callProtectedMethod($this->e(), '_consume', [123, 'escape'])
$this->callProtected($this->e(), '_consume', [123, 'escape'])
);
$this->assertEquals(
':x',
PHPUnitUtil::callProtectedMethod($this->e(['_paramBase' => 'x']), '_consume', [123, 'param'])
$this->callProtected($this->e(['_paramBase' => 'x']), '_consume', [123, 'param'])
);
$this->assertEquals(
123,
PHPUnitUtil::callProtectedMethod($this->e(), '_consume', [123, 'none'])
$this->callProtected($this->e(), '_consume', [123, 'none'])
);
$this->assertEquals(
'(select *)',
PHPUnitUtil::callProtectedMethod($this->e(), '_consume', [new Query()])
$this->callProtected($this->e(), '_consume', [new Query()])
);

$this->assertEquals(
Expand All @@ -421,7 +421,7 @@ public function testConsume()
*/
public function testConsumeException1()
{
PHPUnitUtil::callProtectedMethod($this->e(), '_consume', [123, 'blahblah']);
$this->callProtected($this->e(), '_consume', [123, 'blahblah']);
}

/**
Expand All @@ -432,7 +432,7 @@ public function testConsumeException1()
*/
public function testConsumeException2()
{
PHPUnitUtil::callProtectedMethod($this->e(), '_consume', [new \StdClass()]);
$this->callProtected($this->e(), '_consume', [new \StdClass()]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/OracleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @coversDefaultClass \atk4\dsql\ConnectionTest
*/
class OracleTest extends \PHPUnit_Framework_TestCase
class OracleTest extends \atk4\core\PHPUnit_AgileTestCase
{
/**
* Test constructor.
Expand Down
15 changes: 0 additions & 15 deletions tests/PHPUnitUtil.php

This file was deleted.

38 changes: 19 additions & 19 deletions tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @coversDefaultClass \atk4\dsql\Query
*/
class QueryTest extends \PHPUnit_Framework_TestCase
class QueryTest extends \atk4\core\PHPUnit_AgileTestCase
{
public function q()
{
Expand All @@ -33,7 +33,7 @@ public function testConstruct()
// passing properties in constructor
$this->assertEquals(
'"q"',
PHPUnitUtil::callProtectedMethod($this->q(), '_escape', ['q'])
$this->callProtected($this->q(), '_escape', ['q'])
);
}

Expand Down Expand Up @@ -69,55 +69,55 @@ public function testFieldBasic()
{
$this->assertEquals(
'"first_name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name'), '_render_field')
$this->callProtected($this->q()->field('first_name'), '_render_field')
);
$this->assertEquals(
'"first_name","last_name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name,last_name'), '_render_field')
$this->callProtected($this->q()->field('first_name,last_name'), '_render_field')
);
$this->assertEquals(
'"first_name","last_name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name')->field('last_name'), '_render_field')
$this->callProtected($this->q()->field('first_name')->field('last_name'), '_render_field')
);
$this->assertEquals(
'"last_name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name')->reset('field')->field('last_name'), '_render_field')
$this->callProtected($this->q()->field('first_name')->reset('field')->field('last_name'), '_render_field')
);
$this->assertEquals(
'*',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name')->reset('field'), '_render_field')
$this->callProtected($this->q()->field('first_name')->reset('field'), '_render_field')
);
$this->assertEquals(
'*',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name')->reset(), '_render_field')
$this->callProtected($this->q()->field('first_name')->reset(), '_render_field')
);
$this->assertEquals(
'"employee"."first_name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('employee.first_name'), '_render_field')
$this->callProtected($this->q()->field('employee.first_name'), '_render_field')
);
$this->assertEquals(
'"first_name" "name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('first_name', 'name'), '_render_field')
$this->callProtected($this->q()->field('first_name', 'name'), '_render_field')
);
$this->assertEquals(
'"first_name" "name"',
PHPUnitUtil::callProtectedMethod($this->q()->field(['name' => 'first_name']), '_render_field')
$this->callProtected($this->q()->field(['name' => 'first_name']), '_render_field')
);
$this->assertEquals(
'"name"',
PHPUnitUtil::callProtectedMethod($this->q()->field(['name' => 'name']), '_render_field')
$this->callProtected($this->q()->field(['name' => 'name']), '_render_field')
);
$this->assertEquals(
'"employee"."first_name" "name"',
PHPUnitUtil::callProtectedMethod($this->q()->field(['name' => 'employee.first_name']), '_render_field')
$this->callProtected($this->q()->field(['name' => 'employee.first_name']), '_render_field')
);
$this->assertEquals(
'*',
PHPUnitUtil::callProtectedMethod($this->q()->field('*'), '_render_field')
$this->callProtected($this->q()->field('*'), '_render_field')
);
$this->assertEquals(
'"employee"."first_name"',
PHPUnitUtil::callProtectedMethod($this->q()->field('employee.first_name'), '_render_field')
$this->callProtected($this->q()->field('employee.first_name'), '_render_field')
);
}

Expand All @@ -132,22 +132,22 @@ public function testFieldDefaultField()
// default defaultField
$this->assertEquals(
'*',
PHPUnitUtil::callProtectedMethod($this->q(), '_render_field')
$this->callProtected($this->q(), '_render_field')
);
// defaultField as custom string - not escaped
$this->assertEquals(
'id',
PHPUnitUtil::callProtectedMethod($this->q(['defaultField' => 'id']), '_render_field')
$this->callProtected($this->q(['defaultField' => 'id']), '_render_field')
);
// defaultField as custom string with dot - not escaped
$this->assertEquals(
'all.values',
PHPUnitUtil::callProtectedMethod($this->q(['defaultField' => 'all.values']), '_render_field')
$this->callProtected($this->q(['defaultField' => 'all.values']), '_render_field')
);
// defaultField as Expression object - not escaped
$this->assertEquals(
'values()',
PHPUnitUtil::callProtectedMethod($this->q(['defaultField' => new Expression('values()')]), '_render_field')
$this->callProtected($this->q(['defaultField' => new Expression('values()')]), '_render_field')
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/RandomTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @coversDefaultClass \atk4\dsql\Query
*/
class RandomTests extends \PHPUnit_Framework_TestCase
class RandomTests extends \atk4\core\PHPUnit_AgileTestCase
{
public function q()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/db/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @ coversDefaultClass \atk4\dsql\Query
*/
class dbConnectionTest extends \PHPUnit_Framework_TestCase
class dbConnectionTest extends \atk4\core\PHPUnit_AgileTestCase
{
public function testSQLite()
{
Expand Down

0 comments on commit 4883305

Please sign in to comment.