1
0
Fork 0

Added test for SQLController

Dieser Commit ist enthalten in:
DSB 2011-06-16 17:42:53 +00:00
Ursprung 2bbe324c63
Commit 74568da450

Datei anzeigen

@ -14,7 +14,7 @@ class Msd_Application_Controller_SqlControllerTest
$this->assertQueryContentContains('h2', $expected); $this->assertQueryContentContains('h2', $expected);
// make sure we see the "show tables" link for db information_schema // make sure we see the "show tables" link for db information_schema
$expected = base64_encode("information_schema"); $expected = base64_encode("information_schema");
$this->assertXpath("//a[contains(@href, '" . $expected ."')]"); $this->assertXpath("//a[contains(@href, '" . $expected . "')]");
} }
public function testCanShowTableList() public function testCanShowTableList()
@ -43,6 +43,21 @@ class Msd_Application_Controller_SqlControllerTest
$this->assertQueryContentContains('table > tr > td', $expected); $this->assertQueryContentContains('table > tr > td', $expected);
} }
public function testShowTableDataCanDetectEmptyDatabase()
{
//create empty testDb
$db = Msd_Db::getAdapter();
$db->query('DROP DATABASE IF EXISTS `testDb`');
$sql = 'CREATE DATABASE `testDb` DEFAULT CHARSET utf8 DEFAULT COLLATE utf8_general_ci';
$db->query($sql);
$this->dispatch('sql/show.table.data/dbName/' . base64_encode('testDb') . '/tableName/IDontExits');
// make sure we see an error message
$this->assertXpathCount('//p[@class="error"]', 1);
// make sure message is "Database is empty!"
$expected = 'Die Datenbank ist leer!';
$this->assertQueryContentContains('p', $expected);
}
public function testCanFallbackToShowingDataOfFirstTableOnIncorrectTable() public function testCanFallbackToShowingDataOfFirstTableOnIncorrectTable()
{ {
$this->loginUser(); $this->loginUser();
@ -79,10 +94,13 @@ class Msd_Application_Controller_SqlControllerTest
$db->query('DROP DATABASE IF EXISTS `testDb`'); $db->query('DROP DATABASE IF EXISTS `testDb`');
} }
/**
* @depends testCanCreateADatabase
*/
public function testCanDropADatabase() public function testCanDropADatabase()
{ {
$this->loginUser(); $this->loginUser();
//create our testDb if it exists //create our testDb
$db = Msd_Db::getAdapter(); $db = Msd_Db::getAdapter();
$sql = 'CREATE DATABASE `testDb` DEFAULT CHARSET utf8 DEFAULT COLLATE utf8_general_ci'; $sql = 'CREATE DATABASE `testDb` DEFAULT CHARSET utf8 DEFAULT COLLATE utf8_general_ci';
$db->query($sql); $db->query($sql);
@ -109,4 +127,5 @@ class Msd_Application_Controller_SqlControllerTest
$expected = '<option value="aW5mb3JtYXRpb25fc2NoZW1h" selected="selected">information_schema</option>'; $expected = '<option value="aW5mb3JtYXRpb25fc2NoZW1h" selected="selected">information_schema</option>';
$this->assertQueryContentContains('select', $expected); $this->assertQueryContentContains('select', $expected);
} }
} }