Dieser Commit ist enthalten in:
Ursprung
2b21070b1a
Commit
f7a7c71f86
1583 geänderte Dateien mit 454759 neuen und 0 gelöschten Zeilen
27
tests/functional/application/models/SqlboxTest.php
Normale Datei
27
tests/functional/application/models/SqlboxTest.php
Normale Datei
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once APPLICATION_PATH . DS . implode(DS, array('models', 'Sqlbox.php'));
|
||||
|
||||
/**
|
||||
* @group Models
|
||||
*/
|
||||
|
||||
class SqlboxTest extends ControllerTestCase
|
||||
{
|
||||
public function testCanCreateTableSelectBox()
|
||||
{
|
||||
$model = new Application_Model_Sqlbox();
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$config->set('dynamic.dbActual', 'information_schema');
|
||||
$selectBox = $model->getTableSelectBox();
|
||||
$tables = array('CHARACTER_SETS', 'COLLATIONS', 'COLLATION_CHARACTER_SET_APPLICABILITY',
|
||||
'COLUMNS', 'COLUMN_PRIVILEGES', 'ENGINES'
|
||||
);
|
||||
$pattern = '<option value="%1$s">%1$s</option>';
|
||||
foreach ($tables as $table) {
|
||||
$val = sprintf($pattern, $table);
|
||||
$this->assertTrue(strpos($selectBox, $val) !== false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
tests/functional/application/plugins/DeviceCheckerTest.php
Normale Datei
38
tests/functional/application/plugins/DeviceCheckerTest.php
Normale Datei
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once APPLICATION_PATH . '/plugins/DeviceCheck.php';
|
||||
//'DeviceCheck.php';
|
||||
/**
|
||||
* @group MsdPlugins
|
||||
*/
|
||||
|
||||
class DeviceCheckerTest extends ControllerTestCase
|
||||
{
|
||||
|
||||
protected $_deviceChecker = null;
|
||||
protected $_ZendLayout = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->_deviceChecker = new Application_Plugin_DeviceCheck();
|
||||
$this->_ZendLayout = Zend_Layout::getMvcInstance();
|
||||
}
|
||||
|
||||
public function testDispatchLoopStartupIsMobile()
|
||||
{
|
||||
$userAgentString = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like
|
||||
Mac OS X; en-us) AppleWebKit/528.18
|
||||
(KHTML, like Gecko) Version/4.0 Mobile/7A341
|
||||
Safari/528.16';
|
||||
|
||||
//Mock http_user_agent
|
||||
$request = $this->getRequest()
|
||||
->setHeader('user-agent', $userAgentString);
|
||||
|
||||
$this->_deviceChecker->dispatchLoopStartup($request);
|
||||
$layout = $this->_ZendLayout->getLayout();
|
||||
$expectedLayout = 'mobile';
|
||||
$this->assertSame($layout, $expectedLayout);
|
||||
|
||||
}
|
||||
}
|
||||
24
tests/functional/application/views/helpers/AbsoluteUrlTest.php
Normale Datei
24
tests/functional/application/views/helpers/AbsoluteUrlTest.php
Normale Datei
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'AbsoluteUrl.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class AbsoluteUrlTest extends ControllerTestCase
|
||||
{
|
||||
public function testCanGetAbsoluteUrl()
|
||||
{
|
||||
$_SERVER['HTTP_SCHEME'] = 'http';
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
|
||||
$this->loginUser();
|
||||
$viewHelper = new Msd_View_Helper_AbsoluteUrl();
|
||||
|
||||
$options = array('controller'=>'sql','action'=>'show.databases');
|
||||
$res = $viewHelper->absoluteUrl($options);
|
||||
$expected = 'http://localhost/sql/show.databases';
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
}
|
||||
34
tests/functional/application/views/helpers/AjaxLoadTest.php
Normale Datei
34
tests/functional/application/views/helpers/AjaxLoadTest.php
Normale Datei
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'AjaxLoad.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class AjaxLoadTest extends ControllerTestCase
|
||||
{
|
||||
public function testCanGetAbsoluteUrl()
|
||||
{
|
||||
$this->loginUser();
|
||||
$viewHelper = new Msd_View_Helper_AjaxLoad();
|
||||
|
||||
$ajaxOptions = array('controller' => 'sql', 'action' => 'phpinfo');
|
||||
$viewOptions = array(
|
||||
'loadingMessage' => 'loading...',
|
||||
'showThrober' => true
|
||||
);
|
||||
$res = $viewHelper->ajaxLoad($ajaxOptions, $viewOptions);
|
||||
$this->assertTrue(is_string($res));
|
||||
$checks = array(
|
||||
'<span id="ajax-', // do we have our span?
|
||||
'url: \'/sql/phpinfo', // did we get the correct Url?
|
||||
'loading..', // loading message is in there?
|
||||
);
|
||||
foreach ($checks as $check) {
|
||||
$this->assertTrue(strpos($res, $check) !== false,
|
||||
'Not found in response: '.$check
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
29
tests/functional/application/views/helpers/GetFreeDiskspaceTest.php
Normale Datei
29
tests/functional/application/views/helpers/GetFreeDiskspaceTest.php
Normale Datei
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'GetFreeDiskspace.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class GetFreeDiskspaceTest extends ControllerTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->view = new Zend_View();
|
||||
$helperPath = APPLICATION_PATH . DIRECTORY_SEPARATOR
|
||||
. 'views' . DIRECTORY_SEPARATOR . 'helpers';
|
||||
$this->view->addHelperPath($helperPath, 'Msd_View_Helper');
|
||||
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
|
||||
$viewRenderer->setView($this->view);
|
||||
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
|
||||
}
|
||||
|
||||
public function testGetFreeDiskspace()
|
||||
{
|
||||
$ret = $this->view->getFreeDiskspace();
|
||||
$res = strpos($ret, '<span class="explain tooltip"')!== false ? true:false;
|
||||
$this->assertEquals(true, $res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
50
tests/functional/application/views/helpers/MenuTest.php
Normale Datei
50
tests/functional/application/views/helpers/MenuTest.php
Normale Datei
|
|
@ -0,0 +1,50 @@
|
|||
<?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();
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$config->set('dynamic.dbActual', -1);
|
||||
$this->dispatch('/');
|
||||
$this->assertQueryContentContains('#selectedDb', 'information_schema');
|
||||
}
|
||||
|
||||
public function testCanFallbackToDefaultDbIfActualDbIsInvalid()
|
||||
{
|
||||
$this->loginUser();
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$config->set('dynamic.dbActual', 'i_dont_exist');
|
||||
$config->set('config.dbuser.defaultDb', 'information_schema');
|
||||
$this->dispatch('/');
|
||||
$this->assertQueryContentContains('#selectedDb', 'information_schema');
|
||||
}
|
||||
|
||||
public function testCanFallbackToFirstDbIfActualAndDefaultDbsAreInvalid()
|
||||
{
|
||||
$this->loginUser();
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$config->set('dynamic.dbActual', 'i_dont_exist');
|
||||
$config->set('config.dbuser.defaultDb', 'I_dont_exist');
|
||||
$this->dispatch('/');
|
||||
$this->assertQueryContentContains('#selectedDb', 'information_schema');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
28
tests/functional/application/views/helpers/PopUpMessageTest.php
Normale Datei
28
tests/functional/application/views/helpers/PopUpMessageTest.php
Normale Datei
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class PopUpMessageTest extends ControllerTestCase
|
||||
{
|
||||
public function testcanAddPopUpMessage()
|
||||
{
|
||||
// force popUp by log in with wrong credentials
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'user' => 'tester',
|
||||
'pass' => 'wrongPassword',
|
||||
'autologin' => 0
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/login');
|
||||
$this->assertNotRedirect();
|
||||
// make sure we see the login error message
|
||||
$this->assertQueryCount("//div[@id='login-message']", 1);
|
||||
$msg = "Diese Kombination von Benutzername und Passwort ist unbekannt.";
|
||||
$this->assertQueryContentContains('#login-message', $msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
17
tests/functional/controllers/ErrorControllerTest.php
Normale Datei
17
tests/functional/controllers/ErrorControllerTest.php
Normale Datei
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* @group Error
|
||||
*/
|
||||
class Msd_Application_Controller_ErrorControllerTest
|
||||
extends ControllerTestCase
|
||||
{
|
||||
public function testErrorControllerCatchesInvalidPageCalls()
|
||||
{
|
||||
$this->dispatch('/invalid/page');
|
||||
$this->assertResponseCode(404);
|
||||
$this->assertQueryContentContains('h2', 'Page not found');
|
||||
$this->assertQueryContentContains('#controller', 'invalid');
|
||||
$this->assertQueryContentContains('#action', 'page');
|
||||
$this->assertQueryContentContains('#module', 'default');
|
||||
}
|
||||
}
|
||||
268
tests/functional/controllers/IndexControllerTest.php
Normale Datei
268
tests/functional/controllers/IndexControllerTest.php
Normale Datei
|
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
/**
|
||||
* @group Index
|
||||
*/
|
||||
class Msd_Application_Controller_IndexControllerTest
|
||||
extends ControllerTestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
Testhelper::copyFile('mysqldumper2.ini', CONFIG_PATH . DS .'mysqldumper2.ini');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
Testhelper::removeFile(CONFIG_PATH . DS . 'mysqldumper2.ini');
|
||||
}
|
||||
|
||||
public function testRedirectsToLoginFormIfUserNotLoggedIn()
|
||||
{
|
||||
$this->dispatch('/index/phpinfo');
|
||||
//we should be redirected to the log in page
|
||||
$this->assertResponseCode('302');
|
||||
$this->assertRedirectTo('/index/login');
|
||||
}
|
||||
|
||||
public function testCanLoginUser()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('/');
|
||||
//make sure we are not redirected to the log in page
|
||||
$this->assertNotRedirect();
|
||||
|
||||
// make sure we are on the home page now
|
||||
$this->assertQueryContentContains('h2', 'Home');
|
||||
// we should have one div with id username
|
||||
$this->assertQueryCount('#username', 1);
|
||||
// which contains the username
|
||||
$this->assertQueryContentContains('#username > p', 'tester');
|
||||
|
||||
// now lets check if we can access a page without being redirected
|
||||
// to the log in page
|
||||
$this->clearRequest();
|
||||
$this->dispatch('/index/phpinfo');
|
||||
$this->assertNotRedirect();
|
||||
$this->assertQueryCount('#phpinfo', 1);
|
||||
}
|
||||
|
||||
public function testWontLoginUserWithWrongCredentials()
|
||||
{
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'user' => 'tester',
|
||||
'pass' => 'wrongPassword',
|
||||
'autologin' => 0
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/login');
|
||||
$this->assertNotRedirect();
|
||||
// make sure we see the login error message
|
||||
$this->assertQueryCount("//div[@id='login-message']", 1);
|
||||
$msg = "Diese Kombination von Benutzername und Passwort ist unbekannt.";
|
||||
$this->assertQueryContentContains('#login-message', $msg);
|
||||
}
|
||||
|
||||
public function testCanRedirectToInstallIfUserFileIsBroken()
|
||||
{
|
||||
$path= APPLICATION_PATH . '/configs/';
|
||||
rename($path.'users.ini', $path.'users.bak');
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'user' => 'tester',
|
||||
'pass' => 'test',
|
||||
'autologin' => 0
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/login');
|
||||
$this->assertResponseCode('302');
|
||||
rename($path.'users.bak', $path.'users.ini');
|
||||
$this->assertRedirect();
|
||||
$this->assertRedirectTo('/install');
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCanLoginUser
|
||||
*/
|
||||
public function testCanLogoutUser()
|
||||
{
|
||||
$_COOKIE['msd_autologin'] =
|
||||
'ZC5UZ1xNHTfnaQN2FqIOCuA--:1ef26361573f7032cebe97cec16f0bd0';
|
||||
$this->dispatch('/index/logout');
|
||||
// now we should be redirected to login page
|
||||
$this->assertRedirectTo('/index/login');
|
||||
$this->assertResponseCode('302');
|
||||
$this->assertRedirect();
|
||||
}
|
||||
|
||||
public function testCanAutoLoginUserByCookie()
|
||||
{
|
||||
$_COOKIE['msd_autologin'] =
|
||||
'ZC5UZ1xNHTfnaQN2FqIOCuA--:1ef26361573f7032cebe97cec16f0bd0';
|
||||
$this->dispatch('/index/phpinfo');
|
||||
$this->assertNotRedirect();
|
||||
// dom id #phpinfo is only shown on phpinfo page, so let's look for it
|
||||
$this->assertQueryCount('#phpinfo', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @outputBuffering enabled
|
||||
*/
|
||||
public function testCanLoginWithAutoLogin()
|
||||
{
|
||||
$this->dispatch('/index/logout');
|
||||
$this->clearRequest();
|
||||
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'user' => 'tester',
|
||||
'pass' => 'test',
|
||||
'autologin' => 1
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/login');
|
||||
// after successful login we should be redirected to the index page
|
||||
$this->assertResponseCode('302');
|
||||
$this->assertRedirectTo('/');
|
||||
$this->clearRequest();
|
||||
}
|
||||
|
||||
public function testCanShowIndex()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('/');
|
||||
$this->assertNotRedirect();
|
||||
// we are there if button PHP-Info is shown
|
||||
$this->assertQueryContentContains('#content', 'PHP-Info');
|
||||
}
|
||||
|
||||
public function testCanShowPhpinfo()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('/index/phpinfo');
|
||||
$this->assertNotRedirect();
|
||||
// dom id #phpinfo is only shown on phpinfo page, so let's look for it
|
||||
$this->assertQueryCount('#phpinfo', 1);
|
||||
}
|
||||
|
||||
public function testCanRefreshDbListAndRedirectsToOldAction()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'lastAction' => 'phpinfo',
|
||||
'lastController' => 'index'
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/dbrefresh');
|
||||
$this->assertRedirectTo('/index/phpinfo');
|
||||
}
|
||||
|
||||
public function testCanRefreshDbListWithInvalidActiveDb()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'lastAction' => 'phpinfo',
|
||||
'lastController' => 'index'
|
||||
)
|
||||
);
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$config->set('dynamic.dbActual', -1);
|
||||
$this->dispatch('/index/dbrefresh');
|
||||
$this->assertRedirectTo('/index/phpinfo');
|
||||
}
|
||||
|
||||
public function testCanSelectDb()
|
||||
{
|
||||
$this->loginUser();
|
||||
$config = Msd_Configuration::getInstance();
|
||||
// set invalid active db
|
||||
$config->set('dynamic.dbActual', -1);
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'lastAction' => 'phpinfo',
|
||||
'lastController' => 'index',
|
||||
'selectedDb' => base64_encode('information_schema')
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/selectdb');
|
||||
$this->assertRedirectTo('/index/phpinfo');
|
||||
// check if actual db was switched
|
||||
$this->assertEquals(
|
||||
'information_schema',
|
||||
$config->get('dynamic.dbActual')
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanToggleMenuStatus()
|
||||
{
|
||||
$this->dispatch('index/ajax.Toggle.Menu');
|
||||
$menu = new Zend_Session_Namespace('menu');
|
||||
$this->assertEquals(1, $menu->showMenu);
|
||||
$this->dispatch('index/ajax.Toggle.Menu');
|
||||
$this->assertEquals(0, $menu->showMenu);
|
||||
}
|
||||
|
||||
public function testCanSwitchConfiguration()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'lastAction' => 'phpinfo',
|
||||
'lastController' => 'index',
|
||||
'selectedConfig' => base64_encode('mysqldumper')
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/switchconfig');
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$this->assertEquals('mysqldumper', $config->get('dynamic.configFile'));
|
||||
// are we still on the phpinfo page?
|
||||
$this->assertQueryCount('#phpinfo', 1);
|
||||
|
||||
// now lets switch to another configuration
|
||||
$this->clearRequest();
|
||||
$this->getRequest()
|
||||
->setMethod('POST')
|
||||
->setParams(
|
||||
array(
|
||||
'lastAction' => 'phpinfo',
|
||||
'lastController' => 'index',
|
||||
'selectedConfig' => base64_encode('mysqldumper2')
|
||||
)
|
||||
);
|
||||
$this->dispatch('/index/switchconfig');
|
||||
$config = Msd_Configuration::getInstance();
|
||||
$this->assertEquals('mysqldumper2', $config->get('dynamic.configFile'));
|
||||
// are we still on the phpinfo page?
|
||||
$this->assertQueryCount('#phpinfo', 1);
|
||||
}
|
||||
|
||||
public function testCanLoadConfigFromSession()
|
||||
{
|
||||
$_SESSION = unserialize($this->loadFixtureFile('sessions/sessionTester.txt'));
|
||||
$reflection = new ReflectionClass('Msd_Configuration');
|
||||
$property = $reflection->getProperty('_instance');
|
||||
$property->setAccessible(true);
|
||||
$oldInstance = $property->getValue(null);
|
||||
$property->setValue(null, null);
|
||||
Msd_Configuration::getInstance();
|
||||
$property->setValue(null, $oldInstance);
|
||||
$this->loginUser();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
15
tests/functional/controllers/InstallControllerTest.php
Normale Datei
15
tests/functional/controllers/InstallControllerTest.php
Normale Datei
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* @group Error
|
||||
*/
|
||||
class Msd_Application_Controller_InstallControllerTest
|
||||
extends ControllerTestCase
|
||||
{
|
||||
public function testCanDispatchInstallPage()
|
||||
{
|
||||
$_GET['language'] = 'de';
|
||||
$this->dispatch('/install/index');
|
||||
$this->assertQueryContentContains('h3', 'Schritt 1: Sprache wählen (de)');
|
||||
$this->assertQueryCount('input[@id="lang-de"]', 1);
|
||||
}
|
||||
}
|
||||
54
tests/functional/controllers/SqlControllerTest.php
Normale Datei
54
tests/functional/controllers/SqlControllerTest.php
Normale Datei
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* @group Sql
|
||||
*/
|
||||
class Msd_Application_Controller_SqlControllerTest
|
||||
extends ControllerTestCase
|
||||
{
|
||||
public function testCanShowDatabaseList()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('sql');
|
||||
// make sure headline of db list is shown with correct user
|
||||
$expected = "Datenbanken des Benutzers 'root'@'localhost'";
|
||||
$this->assertQueryContentContains('h2', $expected);
|
||||
// make sure we see the "show tables" link for db information_schema
|
||||
$expected = base64_encode("information_schema");
|
||||
$this->assertXpath("//a[contains(@href, '" . $expected ."')]");
|
||||
}
|
||||
|
||||
public function testCanShowTableList()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('sql/show.tables/dbName/bXlzcWw%3D');
|
||||
// make sure headline shows the selected database
|
||||
$expected = 'Tabellen der Datenbank `mysql`';
|
||||
$this->assertQueryContentContains('h2', $expected);
|
||||
// make sure we see the detail link for table `mysql`.`db`
|
||||
$expected = 'columns_priv';
|
||||
$this->assertQueryContentContains('table > tr > td > label', $expected);
|
||||
}
|
||||
|
||||
public function testCanShowTableData()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('sql/show.table.data/dbName/bXlzcWw%3D/tableName/dXNlcg%3D%3D');
|
||||
// make sure headline shows the selected table
|
||||
$expected = 'Datensätze der Tabelle `mysql`.`user`';
|
||||
$this->assertQueryContentContains('h2', $expected);
|
||||
// make sure user root@localhost is shown
|
||||
$expected = 'localhost ';
|
||||
$this->assertQueryContentContains('table > tr > td', $expected);
|
||||
$expected = 'root ';
|
||||
$this->assertQueryContentContains('table > tr > td', $expected);
|
||||
}
|
||||
|
||||
public function testCanFallbackToShowingDataOfFirstTableOnIncorrectTable()
|
||||
{
|
||||
$this->loginUser();
|
||||
$this->dispatch('sql/show.table.data/dbName/bXlzcWw%3D/tableName/iDontExits');
|
||||
// we excpect a fall back to the first found table in db `mysql`
|
||||
$expected = 'Datensätze der Tabelle `mysql`.`columns_priv`';
|
||||
$this->assertQueryContentContains('h2', $expected);
|
||||
}
|
||||
}
|
||||
58
tests/functional/library/Msd/UserTest.php
Normale Datei
58
tests/functional/library/Msd/UserTest.php
Normale Datei
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
* @group login
|
||||
*/
|
||||
class Msd_UserTest extends ControllerTestCase
|
||||
{
|
||||
public function testCanLoginUserByCookie()
|
||||
{
|
||||
$_COOKIE['msd_autologin'] =
|
||||
'ZC5UZ1xNHTfnaQN2FqIOCuA--:1ef26361573f7032cebe97cec16f0bd0';
|
||||
$request = Zend_Controller_Front::getInstance()->getRequest();
|
||||
$request->setParam('msd_autologin', $_COOKIE['msd_autologin']);
|
||||
|
||||
$user = new Msd_User();
|
||||
$this->assertTrue($user->isLoggedIn());
|
||||
// make sure auth session is set after log in
|
||||
$this->assertEquals(
|
||||
'tester',
|
||||
$_SESSION['Zend_Auth']['storage']['name']
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanDetectInvalidLoginCookie()
|
||||
{
|
||||
$_COOKIE['msd_autologin'] =
|
||||
'C5UZ1xNHTfnaQN2FqIOCuA--:1ef26361573f7032cebe97cec16f0bd0';
|
||||
$request = Zend_Controller_Front::getInstance()->getRequest();
|
||||
$request->setParam('msd_autologin', $_COOKIE['msd_autologin']);
|
||||
|
||||
$user = new Msd_User();
|
||||
$this->assertFalse($user->isLoggedIn());
|
||||
}
|
||||
|
||||
public function testCanDetectNonExistantUsersFile()
|
||||
{
|
||||
Testhelper::removeFile(
|
||||
APPLICATION_PATH . DS . 'configs' . DS . 'users.ini'
|
||||
);
|
||||
$user = new Msd_User();
|
||||
$loginResult = $user->login('tester', 'test');
|
||||
$this->assertEquals(Msd_User::NO_USER_FILE, $loginResult);
|
||||
Testhelper::copyFile(
|
||||
'users.ini', APPLICATION_PATH . DS . 'configs' . DS .'users.ini');
|
||||
}
|
||||
|
||||
public function testCanDetectEmptyUsersFile()
|
||||
{
|
||||
// overwrite users.ini with en empty file
|
||||
Testhelper::copyFile('usersEmpty.ini',
|
||||
APPLICATION_PATH . DS . 'configs' . DS .'users.ini');
|
||||
$user = new Msd_User();
|
||||
$loginResult = $user->login('tester', 'test');
|
||||
$this->assertEquals(Msd_User::NO_VALID_USER, $loginResult);
|
||||
// restore users.ini file
|
||||
Testhelper::copyFile(
|
||||
'users.ini', APPLICATION_PATH . DS . 'configs' . DS .'users.ini');
|
||||
}
|
||||
}
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren