mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-15 08:26:25 +00:00
![pies](/assets/img/avatar_default.png)
- Dispatcher sets a Controller::here variable with the real URL used to access the page, so that tag generators can that use an url (linkTo and formTag for example) use the real url, not guess it from the controller and action names which often fails - Log class works more reliably and a LogError() shortcut function was added - Nstring class added, to store string-related functions (there are just four yet, including a random password generator and an string-to-array splitter - SimpleTest library (with Rephlux) included in /vendors; I've tweaked SimpleScorer::inCli() function, because it didn't work on my setup, it should work everywhere now (it checks for empty REQUEST_METHOD, which should only be empty in CLI) git-svn-id: https://svn.cakephp.org/repo/trunk/cake@248 3807eeeb-6ff5-0310-8944-8be069107fe0
101 lines
No EOL
1.8 KiB
PHP
101 lines
No EOL
1.8 KiB
PHP
<?php
|
|
|
|
uses('dbo_factory');
|
|
|
|
class DboTest extends UnitTestCase
|
|
{
|
|
var $dbo;
|
|
|
|
// constructor of the test suite
|
|
function DboTest()
|
|
{
|
|
$this->UnitTestCase('DBO test');
|
|
}
|
|
|
|
// called before the test functions will be executed
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
// here
|
|
function setUp()
|
|
{
|
|
$this->dbo = DboFactory::make('test');
|
|
|
|
$this->createTemporaryTable();
|
|
}
|
|
|
|
// called after the test functions are executed
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
// here
|
|
function tearDown()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
$this->dropTemporaryTable();
|
|
}
|
|
|
|
function createTemporaryTable()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
if($this->dbo->config['driver'] == 'postgres')
|
|
$sql = 'CREATE TABLE __test(id serial NOT NULL, body CHARACTER VARYING(255))';
|
|
else
|
|
$sql = 'CREATE TABLE __test(id INT UNSIGNED PRIMARY KEY, body VARCHAR(255))';
|
|
|
|
return $this->dbo->query($sql);
|
|
}
|
|
|
|
function dropTemporaryTable()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
return $this->dbo->query("DROP TABLE __test");
|
|
}
|
|
|
|
function testHasImplementation()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
$functions = array(
|
|
'connect',
|
|
'disconnect',
|
|
'execute',
|
|
'fetchRow',
|
|
'tables',
|
|
'fields',
|
|
'prepare',
|
|
'lastError',
|
|
'lastAffected',
|
|
'lastNumRows',
|
|
'lastInsertId'
|
|
);
|
|
|
|
foreach($functions as $function)
|
|
{
|
|
$this->assertTrue(method_exists($this->dbo, $function));
|
|
}
|
|
}
|
|
|
|
function testConnectivity()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
$this->assertTrue($this->dbo->connected);
|
|
}
|
|
|
|
function testFields()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
$fields = $this->dbo->fields('__test');
|
|
$this->assertEqual(count($fields), 2, 'equals');
|
|
}
|
|
|
|
function testTables()
|
|
{
|
|
if(!$this->dbo) return false;
|
|
|
|
$this->assertTrue(in_array('__test', $this->dbo->tables()));
|
|
}
|
|
}
|
|
|
|
?>
|