diff options
Diffstat (limited to 'tests/unit/Data/TableGateway')
-rw-r--r-- | tests/unit/Data/TableGateway/BaseGateway.php (renamed from tests/unit/Data/TableGateway/BaseGatewayTest.php) | 10 | ||||
-rw-r--r-- | tests/unit/Data/TableGateway/CountTest.php | 8 | ||||
-rw-r--r-- | tests/unit/Data/TableGateway/MagicCallTest.php | 10 | ||||
-rw-r--r-- | tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php | 12 | ||||
-rw-r--r-- | tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php | 20 | ||||
-rw-r--r-- | tests/unit/Data/TableGateway/TableInfoGatewayTest.php | 6 | ||||
-rw-r--r-- | tests/unit/Data/TableGateway/TestFindByPk.php | 10 |
7 files changed, 42 insertions, 34 deletions
diff --git a/tests/unit/Data/TableGateway/BaseGatewayTest.php b/tests/unit/Data/TableGateway/BaseGateway.php index b97ef4a0..3ab23b19 100644 --- a/tests/unit/Data/TableGateway/BaseGatewayTest.php +++ b/tests/unit/Data/TableGateway/BaseGateway.php @@ -5,7 +5,7 @@ Prado::using('System.Data.DataGateway.TTableGateway'); /** * @package System.Data.TableGateway */ -class BaseGatewayTest extends PHPUnit_Framework_TestCase +class BaseGateway extends PHPUnit_Framework_TestCase { protected $gateway1; protected $gateway2; @@ -17,7 +17,7 @@ class BaseGatewayTest extends PHPUnit_Framework_TestCase { if($this->gateway1===null) { - $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + $conn = new TDbConnection('mysql:host=localhost;dbname=prado_unitest', 'prado_unitest','prado_unitest'); $this->gateway1 = new TTableGateway('address', $conn); } return $this->gateway1; @@ -30,7 +30,7 @@ class BaseGatewayTest extends PHPUnit_Framework_TestCase { if($this->gateway2===null) { - $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + $conn = new TDbConnection('mysql:host=localhost;dbname=prado_unitest', 'prado_unitest','prado_unitest'); $this->gateway2 = new TTableGateway('department_sections', $conn); } return $this->gateway2; @@ -63,7 +63,7 @@ class BaseGatewayTest extends PHPUnit_Framework_TestCase 'field5_text' => 'asdasd', 'field6_time' => '12:40:00', 'field7_timestamp' => 'NOW', - 'field8_money' => '$121.12', + 'field8_money' => '121.12', 'field9_numeric' => 98.2232, 'int_fk1'=>1, 'int_fk2'=>1, @@ -83,7 +83,7 @@ class BaseGatewayTest extends PHPUnit_Framework_TestCase 'field5_text' => 'hello world', 'field6_time' => '22:40:00', 'field7_timestamp' => 'NOW', - 'field8_money' => '$1121.12', + 'field8_money' => '1121.12', 'field9_numeric' => 8.2213, 'int_fk1'=>1, 'int_fk2'=>1, diff --git a/tests/unit/Data/TableGateway/CountTest.php b/tests/unit/Data/TableGateway/CountTest.php index 074d935b..1d3b60ee 100644 --- a/tests/unit/Data/TableGateway/CountTest.php +++ b/tests/unit/Data/TableGateway/CountTest.php @@ -1,18 +1,18 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php'); +require_once(dirname(__FILE__).'/BaseGateway.php'); /** * @package System.Data.TableGateway */ -class CountTest extends BaseGatewayTest +class CountTest extends BaseGateway { function test_simple_count() { $result = $this->getGateway2()->count(); - $this->assertEqual(44,$result); + $this->assertEquals(5,$result); $result = $this->getGateway2()->count('department_id = ?', 1); - $this->assertEqual(4, $result); + $this->assertEquals(2, $result); } }
\ No newline at end of file diff --git a/tests/unit/Data/TableGateway/MagicCallTest.php b/tests/unit/Data/TableGateway/MagicCallTest.php index 56cc85b3..caf10019 100644 --- a/tests/unit/Data/TableGateway/MagicCallTest.php +++ b/tests/unit/Data/TableGateway/MagicCallTest.php @@ -1,18 +1,18 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php'); +require_once(dirname(__FILE__).'/BaseGateway.php'); /** * @package System.Data.TableGateway */ -class MagicCallTest extends BaseGatewayTest +class MagicCallTest extends BaseGateway { function test_magic_call() { $this->add_record1(); $this->add_record2(); $result = $this->getGateway()->findByUsername("record2"); - $this->assertEqual($result['username'], 'record2'); + $this->assertEquals($result['username'], 'record2'); } function test_combined_and_or() @@ -20,7 +20,7 @@ class MagicCallTest extends BaseGatewayTest $this->add_record1(); $this->add_record2(); $result = $this->getGateway()->findAllByUsername_OR_phone('Username', '45233')->readAll(); - $this->assertEqual(2, count($result)); + $this->assertEquals(2, count($result)); } function test_no_result() @@ -28,6 +28,6 @@ class MagicCallTest extends BaseGatewayTest $this->add_record1(); $this->add_record2(); $result = $this->getGateway()->findAllByUsername_and_phone('Username', '45233')->readAll(); - $this->assertEqual(0, count($result)); + $this->assertEquals(0, count($result)); } }
\ No newline at end of file diff --git a/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php b/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php index 6bcaeb91..36d1be11 100644 --- a/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php +++ b/tests/unit/Data/TableGateway/TableGatewayDeleteByPkTest.php @@ -1,11 +1,11 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php'); +require_once(dirname(__FILE__).'/BaseGateway.php'); /** * @package System.Data.TableGateway */ -class TableGatewayDeleteByPkTest extends BaseGatewayTest +class TableGatewayDeleteByPkTest extends BaseGateway { function test_delete_by_1_pk() { @@ -13,7 +13,7 @@ class TableGatewayDeleteByPkTest extends BaseGatewayTest $id = $this->getGateway()->getLastInsertId(); $deleted = $this->getGateway()->deleteByPk($id); - $this->assertEqual(1, $deleted); + $this->assertEquals(1, $deleted); } function test_delete_by_multiple_pk() @@ -25,7 +25,7 @@ class TableGatewayDeleteByPkTest extends BaseGatewayTest $deleted = $this->getGateway()->deleteByPk($id1, $id2); - $this->assertEqual(2, $deleted); + $this->assertEquals(2, $deleted); } function test_delete_by_multiple_pk2() @@ -37,7 +37,7 @@ class TableGatewayDeleteByPkTest extends BaseGatewayTest $deleted = $this->getGateway()->deleteByPk(array($id1, $id2)); - $this->assertEqual(2, $deleted); + $this->assertEquals(2, $deleted); } function test_delete_by_multiple_pk3() @@ -49,6 +49,6 @@ class TableGatewayDeleteByPkTest extends BaseGatewayTest $deleted = $this->getGateway()->deleteByPk(array(array($id1), array($id2))); - $this->assertEqual(2, $deleted); + $this->assertEquals(2, $deleted); } }
\ No newline at end of file diff --git a/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php b/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php index 234f70bd..fae1f394 100644 --- a/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php +++ b/tests/unit/Data/TableGateway/TableGatewayPgsqlTest.php @@ -1,11 +1,19 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php'); +require_once(dirname(__FILE__).'/BaseGateway.php'); /** * @package System.Data.TableGateway */ -class TableGatewayPgsqlTest extends BaseGatewayTest +class TableGatewayPgsqlTest extends BaseGateway { + public function setUp() + { + if (!extension_loaded('pgsql')) { + $this->markTestSkipped( + 'The pgsql extension is not available.' + ); + } + } function test_update() { @@ -20,7 +28,7 @@ class TableGatewayPgsqlTest extends BaseGatewayTest $expect['username'] = 'tester 1'; $expect['field5_text'] = null; unset($expect['field7_timestamp']); unset($test['field7_timestamp']); - $this->assertEqual($expect, $test); + $this->assertEquals($expect, $test); $this->assertTrue($this->getGateway()->deleteAll('username = ?', 'tester 1')); } @@ -38,7 +46,7 @@ class TableGatewayPgsqlTest extends BaseGatewayTest $expect['username'] = 'tester 1'; $expect['field5_text'] = null; unset($expect['field7_timestamp']); unset($test['field7_timestamp']); - $this->assertEqual($expect, $test); + $this->assertEquals($expect, $test); $this->assertTrue($this->getGateway()->deleteAll('username = :name', array(':name'=>'tester 1'))); } @@ -49,10 +57,10 @@ class TableGatewayPgsqlTest extends BaseGatewayTest $this->add_record2(); $results = $this->getGateway()->findAll('true')->readAll(); - $this->assertEqual(count($results), 2); + $this->assertEquals(count($results), 2); $result = $this->getGateway()->findAllBySql('SELECT username FROM address WHERE phone = ?', '45233')->read(); - $this->assertEqual($result['username'], 'record2'); + $this->assertEquals($result['username'], 'record2'); } }
\ No newline at end of file diff --git a/tests/unit/Data/TableGateway/TableInfoGatewayTest.php b/tests/unit/Data/TableGateway/TableInfoGatewayTest.php index 24b94690..9d4c2a49 100644 --- a/tests/unit/Data/TableGateway/TableInfoGatewayTest.php +++ b/tests/unit/Data/TableGateway/TableInfoGatewayTest.php @@ -1,11 +1,11 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php'); +require_once(dirname(__FILE__).'/BaseGateway.php'); /** * @package System.Data.TableGateway */ -class TableInfoGatewayTest extends BaseGatewayTest +class TableInfoGatewayTest extends BaseGateway { function test_table_info() { @@ -14,6 +14,6 @@ class TableInfoGatewayTest extends BaseGatewayTest $this->add_record2(); $info = TDbMetaData::getInstance($conn)->getTableInfo('address'); $table = new TTableGateway($info, $conn); - $this->assertEqual(count($table->findAll()->readAll()), 2); + $this->assertEquals(count($table->findAll()->readAll()), 2); } }
\ No newline at end of file diff --git a/tests/unit/Data/TableGateway/TestFindByPk.php b/tests/unit/Data/TableGateway/TestFindByPk.php index f23fafa7..264231e6 100644 --- a/tests/unit/Data/TableGateway/TestFindByPk.php +++ b/tests/unit/Data/TableGateway/TestFindByPk.php @@ -1,11 +1,11 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php'); +require_once(dirname(__FILE__).'/BaseGateway.php'); /** * @package System.Data.TableGateway */ -class TestFindByPk extends BaseGatewayTest +class TestFindByPk extends BaseGateway { function test_one_key() { @@ -22,7 +22,7 @@ class TestFindByPk extends BaseGatewayTest $result['phone'] = intval($result['phone']); $result['field9_numeric'] = floatval($result['field9_numeric']); - $this->assertEqual($record1, $result); + $this->assertEquals($record1, $result); } function test_composite_key() @@ -31,7 +31,7 @@ class TestFindByPk extends BaseGatewayTest $result = $gateway->findByPk(1,1); $expect = array("department_id" => 1, "section_id" => 1, "order" => 0); - $this->assertEqual($expect, $result); + $this->assertEquals($expect, $result); } function test_find_all_keys() @@ -44,7 +44,7 @@ class TestFindByPk extends BaseGatewayTest array("department_id" => 1, "section_id" => 1, "order" => 0), array("department_id" => 3, "section_id" => 13, "order" => 0)); - $this->assertEqual($expect, $result); + $this->assertEquals($expect, $result); } }
\ No newline at end of file |