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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren