2011-06-10 21:55:32 +00:00
|
|
|
<?php
|
|
|
|
require_once 'PHPUnit/Framework/TestCase.php';
|
|
|
|
require_once 'Menu.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group MsdViewHelper
|
|
|
|
*/
|
|
|
|
class MenuTest extends ControllerTestCase
|
|
|
|
{
|
|
|
|
public function testWontRenderMenuAtLoginAction()
|
|
|
|
{
|
|
|
|
$this->dispatch('/index/login');
|
|
|
|
$this->assertQueryCount('form', 1);
|
|
|
|
$this->assertQueryCount('#user', 1);
|
|
|
|
$this->assertQueryCount('#pass', 1);
|
|
|
|
$this->assertQueryCount('#autologin', 1);
|
|
|
|
$this->assertQueryCount('#send', 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanRenderMenuWithInvalidActualDatabase()
|
|
|
|
{
|
|
|
|
$this->loginUser();
|
2012-08-04 17:09:48 +00:00
|
|
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
|
|
|
$dynamicConfig->setParam('dbActual', -1);
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->dispatch('/');
|
|
|
|
$this->assertQueryContentContains('#selectedDb', 'information_schema');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanFallbackToDefaultDbIfActualDbIsInvalid()
|
|
|
|
{
|
|
|
|
$this->loginUser();
|
2012-08-04 17:09:48 +00:00
|
|
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
|
|
|
$dynamicConfig->setParam('dbActual', 'i_dont_exist');
|
|
|
|
$config = Msd_Registry::getConfig();
|
|
|
|
$config->set('dbuser.defaultDb', 'information_schema');
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->dispatch('/');
|
|
|
|
$this->assertQueryContentContains('#selectedDb', 'information_schema');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanFallbackToFirstDbIfActualAndDefaultDbsAreInvalid()
|
|
|
|
{
|
|
|
|
$this->loginUser();
|
2012-08-04 17:09:48 +00:00
|
|
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
|
|
|
$dynamicConfig->setParam('dbActual', 'i_dont_exist');
|
|
|
|
$config = Msd_Registry::getConfig();
|
|
|
|
$config->setParam('dbuser.defaultDb', 'I_dont_exist');
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->dispatch('/');
|
|
|
|
$this->assertQueryContentContains('#selectedDb', 'information_schema');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|