Dieser Commit ist enthalten in:
Ursprung
2b21070b1a
Commit
f7a7c71f86
1583 geänderte Dateien mit 454759 neuen und 0 gelöschten Zeilen
35
tests/unit/application/views/helpers/ByteOutputTest.php
Normale Datei
35
tests/unit/application/views/helpers/ByteOutputTest.php
Normale Datei
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'ByteOutput.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
|
||||
class ByteOutputTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testByteOutputWithoutHtml()
|
||||
{
|
||||
$expected='1.00 KB';
|
||||
$viewHelper = new Msd_View_Helper_ByteOutput();
|
||||
$res = $viewHelper->byteOutput(1024, 2, false);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testByteOutputWithHtml()
|
||||
{
|
||||
$expected = '1.00 <span class="explain tooltip" title="KiloBytes">KB</span>';
|
||||
$viewHelper = new Msd_View_Helper_ByteOutput();
|
||||
$res = $viewHelper->byteOutput(1024, 2, true);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testByteOutputWithNonNumericValue()
|
||||
{
|
||||
$expected = 'I am not a number';
|
||||
$viewHelper = new Msd_View_Helper_ByteOutput();
|
||||
$res = $viewHelper->byteOutput($expected, 2, true);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
}
|
||||
|
||||
29
tests/unit/application/views/helpers/FilesizeTest.php
Normale Datei
29
tests/unit/application/views/helpers/FilesizeTest.php
Normale Datei
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'Filesize.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class FilesizeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFilesize()
|
||||
{
|
||||
$expected='14.00 <span class="explain tooltip" title="Bytes">B</span>';
|
||||
//setup view and helper path to Msd_View_Helper
|
||||
// needed because the filesize-helper calls the byteOupt-Helper
|
||||
$view = new Zend_View();
|
||||
$helperPath = APPLICATION_PATH . DIRECTORY_SEPARATOR
|
||||
. 'views' . DIRECTORY_SEPARATOR . 'helpers';
|
||||
$view->addHelperPath($helperPath, 'Msd_View_Helper');
|
||||
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
|
||||
$viewRenderer->setView($view);
|
||||
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
|
||||
|
||||
$res = $view->filesize(
|
||||
APPLICATION_PATH . '/.htaccess'
|
||||
);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
}
|
||||
|
||||
34
tests/unit/application/views/helpers/GetConfigTitleTest.php
Normale Datei
34
tests/unit/application/views/helpers/GetConfigTitleTest.php
Normale Datei
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once('GetConfigTitle.php');
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class GetConfigTitleTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCanReadConfigTitleFromConfigFile()
|
||||
{
|
||||
$expected='MySQLDumper';
|
||||
$viewHelper = new Msd_View_Helper_GetConfigTitle();
|
||||
$res = $viewHelper->getConfigTitle('mysqldumper');
|
||||
$this->assertEquals(true, is_string($res));
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testWillThrowExceptionOnInvalidConfigFile()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_GetConfigTitle();
|
||||
try {
|
||||
$viewHelper->getConfigTitle('i_dont_exist');
|
||||
} catch (Msd_Exception $e) {
|
||||
$this->assertInstanceof('Msd_Exception', $e);
|
||||
$expected = 'Couldn\'t read configuration file';
|
||||
$this->assertEquals($expected, substr($e->getMessage(), 0, 32));
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
37
tests/unit/application/views/helpers/GetIconSrcTest.php
Normale Datei
37
tests/unit/application/views/helpers/GetIconSrcTest.php
Normale Datei
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'GetIconSrc.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class GetIconSrcTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetIconSrcForIconWithoutSize()
|
||||
{
|
||||
$expected = '/css/msd/icons/openfile.gif';
|
||||
$viewHelper = new Msd_View_Helper_GetIconSrc();
|
||||
$res = $viewHelper->getIconSrc('openFile');
|
||||
$this->assertEquals(true, is_string($res));
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testGetIconSrcForIconWithSize()
|
||||
{
|
||||
$expected = '/css/msd/icons/16x16/Edit.png';
|
||||
$viewHelper = new Msd_View_Helper_GetIconSrc();
|
||||
$res = $viewHelper->getIconSrc('Edit', 16);
|
||||
$this->assertEquals(true, is_string($res));
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Msd_Exception
|
||||
*/
|
||||
public function testFailGetNonExistantIcon()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_GetIconSrc();
|
||||
$res = $viewHelper->getIconSrc('nonExistantIcon', 16);
|
||||
}
|
||||
}
|
||||
|
||||
64
tests/unit/application/views/helpers/GetIconTest.php
Normale Datei
64
tests/unit/application/views/helpers/GetIconTest.php
Normale Datei
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'GetIcon.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class GetIconTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetIconEdit()
|
||||
{
|
||||
$expected = '<img src="/css/msd/icons/16x16/Edit.png" '
|
||||
.'alt="" title="" />';
|
||||
$viewHelper = new Msd_View_Helper_GetIcon();
|
||||
$res = $viewHelper->getIcon('Edit', '', 16);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testGetIconEditWithTitle()
|
||||
{
|
||||
$expected = '<img src="/css/msd/icons/16x16/Edit.png" alt="Titletest" '
|
||||
.'title="Titletest" />';
|
||||
$viewHelper = new Msd_View_Helper_GetIcon();
|
||||
$res = $viewHelper->getIcon('Edit', 'Titletest', 16);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testGetIconInfoSize16()
|
||||
{
|
||||
$expected = '<img src="/css/msd/icons/16x16/Info.png" '
|
||||
. 'alt="" title="" />';
|
||||
$viewHelper = new Msd_View_Helper_GetIcon();
|
||||
$res = $viewHelper->getIcon('Info', '', 16);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testGetIconInfoSize20()
|
||||
{
|
||||
$expected = '<img src="/css/msd/icons/20x20/Info.png" '
|
||||
. 'alt="" title="" />';
|
||||
$viewHelper = new Msd_View_Helper_GetIcon();
|
||||
$res = $viewHelper->getIcon('Info', '', 20);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Msd_Exception
|
||||
*/
|
||||
public function testFailGetNonExistantIcon()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_GetIcon();
|
||||
$viewHelper->getIcon('nonExistantIcon');
|
||||
}
|
||||
|
||||
public function testGetIconWithoutSize()
|
||||
{
|
||||
$expected = '<img src="/css/msd/icons/minus.gif" '
|
||||
. 'alt="" title="" />';
|
||||
$viewHelper = new Msd_View_Helper_GetIcon();
|
||||
$res = $viewHelper->getIcon('minus');
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
}
|
||||
|
||||
29
tests/unit/application/views/helpers/GetServerProtocolTest.php
Normale Datei
29
tests/unit/application/views/helpers/GetServerProtocolTest.php
Normale Datei
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'GetServerProtocol.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class GetServerProtocolTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetServerProtocolHTTP()
|
||||
{
|
||||
$expected='http://';
|
||||
$_SERVER['HTTPS'] = 'Off';
|
||||
$viewHelper = new Msd_View_Helper_GetServerProtocol();
|
||||
$res = $viewHelper->getServerProtocol();
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testGetServerProtocolHTTPS()
|
||||
{
|
||||
$expected='https://';
|
||||
$_SERVER['HTTPS'] = 'On';
|
||||
$viewHelper = new Msd_View_Helper_GetServerProtocol();
|
||||
$res = $viewHelper->getServerProtocol();
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
30
tests/unit/application/views/helpers/IsTableOptimizableTest.php
Normale Datei
30
tests/unit/application/views/helpers/IsTableOptimizableTest.php
Normale Datei
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'IsTableOptimizable.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class IsTableOptimizableTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Tests if helper returns true for MyIsam-Engine
|
||||
*/
|
||||
public function testIsTableOptimizable()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_IsTableOptimizable();
|
||||
$res = $viewHelper->isTableOptimizable('MyISAM');
|
||||
$this->assertEquals(true, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if helper returns false for CSV-Engine
|
||||
*/
|
||||
public function testFailIsTableOptimizable()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_IsTableOptimizable();
|
||||
$res = $viewHelper->isTableOptimizable('CSV');
|
||||
$this->assertEquals(false, $res);
|
||||
}
|
||||
}
|
||||
|
||||
18
tests/unit/application/views/helpers/JsEscapeTest.php
Normale Datei
18
tests/unit/application/views/helpers/JsEscapeTest.php
Normale Datei
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'JsEscape.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class JsEscapeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testJsEscapeWithQuotes()
|
||||
{
|
||||
$expected = "test\'with\'quotes\'";
|
||||
$viewHelper = new Msd_View_Helper_JsEscape();
|
||||
$res = $viewHelper->jsEscape("test'with'quotes'");
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
}
|
||||
|
||||
31
tests/unit/application/views/helpers/NumberFormatTest.php
Normale Datei
31
tests/unit/application/views/helpers/NumberFormatTest.php
Normale Datei
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'NumberFormat.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class NumberFormatTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFormatNumberWithoutPrecision()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_NumberFormat();
|
||||
$res = $viewHelper->numberFormat(24.123456);
|
||||
$this->assertEquals('24', $res);
|
||||
}
|
||||
|
||||
public function testFormatNumberWithPrecision()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_NumberFormat();
|
||||
$res = $viewHelper->numberFormat(24.12356789, 3);
|
||||
$this->assertEquals('24,124', $res);
|
||||
}
|
||||
|
||||
public function testFailFormatNumberConversionToFloat()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_NumberFormat();
|
||||
$res = $viewHelper->numberFormat('AAA', 3);
|
||||
$this->assertEquals('0,000', $res);
|
||||
}
|
||||
}
|
||||
|
||||
42
tests/unit/application/views/helpers/OutTest.php
Normale Datei
42
tests/unit/application/views/helpers/OutTest.php
Normale Datei
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'Out.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
|
||||
class OutTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
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 testCanReturnOriginalValue()
|
||||
{
|
||||
$expected='test';
|
||||
$res = $this->view->out('test');
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
public function testCanConvertNullValue()
|
||||
{
|
||||
$expected='NULL';
|
||||
$res = $this->view->out(null, true);
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testCanDecorateValue()
|
||||
{
|
||||
$expected='<i>NULL</i>';
|
||||
$res = $this->view->out(null, true, 'i');
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
}
|
||||
|
||||
203
tests/unit/application/views/helpers/PaginatorTest.php
Normale Datei
203
tests/unit/application/views/helpers/PaginatorTest.php
Normale Datei
|
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'Paginator.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class PaginatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var Zend_View
|
||||
*/
|
||||
public $view = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->view = new Zend_View();
|
||||
$helperPath = implode(DIRECTORY_SEPARATOR, array(APPLICATION_PATH, 'views', 'helpers'));
|
||||
$scriptPath = implode(DIRECTORY_SEPARATOR, array(APPLICATION_PATH, 'views', 'scripts'));
|
||||
$this->view->addHelperPath($helperPath, 'Msd_View_Helper');
|
||||
$this->view->setScriptPath($scriptPath);
|
||||
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
|
||||
$viewRenderer->setView($this->view);
|
||||
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
|
||||
}
|
||||
|
||||
public function testOnChangeReturnsValidJavascriptCode()
|
||||
{
|
||||
$paginator = new Msd_View_Helper_Paginator();
|
||||
$reflection = new ReflectionClass($paginator);
|
||||
$method = $reflection->getMethod('_getOnChange');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$onChange = $method->invokeArgs($paginator, array('form'));
|
||||
$this->assertEquals('$(this).parent().parent()[0].submit();', $onChange);
|
||||
|
||||
$onChange = $method->invokeArgs($paginator, array('url', '/sql/index/', 'pageNumber'));
|
||||
$this->assertEquals("window.location.href = '/sql/index/pageNumber/' + this.value + '/';", $onChange);
|
||||
|
||||
$onChange = $method->invokeArgs($paginator, array('js', 'changePage(this.value);'));
|
||||
$this->assertEquals('changePage(this.value);', $onChange);
|
||||
}
|
||||
|
||||
public function testGetButtonClickReturnsValidJavascriptCode()
|
||||
{
|
||||
$paginator = new Msd_View_Helper_Paginator();
|
||||
$reflection = new ReflectionClass($paginator);
|
||||
$method = $reflection->getMethod('_getButtonClick');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$onChange = $method->invokeArgs(
|
||||
$paginator,
|
||||
array(
|
||||
'form',
|
||||
array('targetPage' => 2)
|
||||
)
|
||||
);
|
||||
$this->assertEquals("$(this).parent().children('select').val(2); $(this).parent().parent()[0].submit();", $onChange);
|
||||
|
||||
$onChange = $method->invokeArgs(
|
||||
$paginator,
|
||||
array(
|
||||
'url',
|
||||
array('baseUrl' => '/sql/index/', 'urlParam' => 'pageNumber', 'targetPage' => 2)
|
||||
)
|
||||
);
|
||||
$this->assertEquals("window.location.href = '/sql/index/pageNumber/2/';", $onChange);
|
||||
|
||||
$onChange = $method->invokeArgs(
|
||||
$paginator,
|
||||
array(
|
||||
'js',
|
||||
array('targetPage' => 2, 'onClick' => 'PHPUnitTest(:PAGE:);')
|
||||
)
|
||||
);
|
||||
$this->assertEquals('PHPUnitTest(2);', $onChange);
|
||||
}
|
||||
|
||||
public function testGetButtonInfoReturnsInformationForTheButtonState()
|
||||
{
|
||||
$paginator = new Msd_View_Helper_Paginator();
|
||||
$reflection = new ReflectionClass($paginator);
|
||||
$method = $reflection->getMethod('_getButtonInfo');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$buttonInfo = $method->invoke($paginator, false);
|
||||
$this->assertArrayHasKey('icon', $buttonInfo);
|
||||
$this->assertEmpty($buttonInfo['icon']);
|
||||
$this->assertArrayHasKey('disabled', $buttonInfo);
|
||||
$this->assertEmpty($buttonInfo['disabled']);
|
||||
|
||||
$buttonInfo = $method->invoke($paginator, true);
|
||||
$this->assertArrayHasKey('icon', $buttonInfo);
|
||||
$this->assertEquals('Disabled', $buttonInfo['icon']);
|
||||
$this->assertArrayHasKey('disabled', $buttonInfo);
|
||||
$this->assertEquals(' disabled="disabled"', $buttonInfo['disabled']);
|
||||
}
|
||||
|
||||
public function testCanBuildAPaginatorWhichUsesJavascriptForPageSwitch()
|
||||
{
|
||||
$options = array(
|
||||
'currentPage' => 1,
|
||||
'pageCount' => 10,
|
||||
'urlParam' => 'pageNr',
|
||||
'baseUrl' => '/php/unit/test/',
|
||||
'mode' => 'js',
|
||||
'actions' => array(
|
||||
'first' => 'first(:PAGE:);',
|
||||
'prev' => 'prev(:PAGE:);',
|
||||
'next' => 'next(:PAGE:);',
|
||||
'last' => 'last(:PAGE:);',
|
||||
'change' => 'change(this.value);',
|
||||
),
|
||||
);
|
||||
$paginator = new Msd_View_Helper_Paginator();
|
||||
$paginator->setView($this->view);
|
||||
$result = $paginator->paginator($options);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton first" type="button" onclick="first(1);" accesskey="c" disabled="disabled">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton paginator prev" type="button" onclick="prev(0);" accesskey="v" disabled="disabled">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<select id="combobox" name="pageNr" onchange="change(this.value);" accesskey="b">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton next" type="button" onclick="next(2);" accesskey="n">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton last" type="button" onclick="last(10);" accesskey="m">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '$("#combobox").combobox();');
|
||||
$this->assertNotEquals(false, $button);
|
||||
}
|
||||
|
||||
public function testCanBuildAPaginatorWhichUsesFormForPageSwitch()
|
||||
{
|
||||
$options = array(
|
||||
'currentPage' => 1,
|
||||
'pageCount' => 10,
|
||||
'urlParam' => 'pageNr',
|
||||
'baseUrl' => '/php/unit/test/',
|
||||
'mode' => 'form',
|
||||
);
|
||||
|
||||
$paginator = new Msd_View_Helper_Paginator();
|
||||
$paginator->setView($this->view);
|
||||
$result = $paginator->paginator($options);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton first" type="submit" onclick="$(this).parent().children(\'select\').val(1); $(this).parent().parent()[0].submit();" accesskey="c" disabled="disabled">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton paginator prev" type="submit" onclick="$(this).parent().children(\'select\').val(0); $(this).parent().parent()[0].submit();" accesskey="v" disabled="disabled">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<select id="combobox" name="pageNr" onchange="$(this).parent().parent()[0].submit();" accesskey="b">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton next" type="submit" onclick="$(this).parent().children(\'select\').val(2); $(this).parent().parent()[0].submit();" accesskey="n">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton last" type="submit" onclick="$(this).parent().children(\'select\').val(10); $(this).parent().parent()[0].submit();" accesskey="m">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '$("#combobox").combobox();');
|
||||
$this->assertNotEquals(false, $button);
|
||||
}
|
||||
|
||||
public function testCanBuildAPaginatorWhichUsesUrlsForPageSwitch()
|
||||
{
|
||||
$options = array(
|
||||
'currentPage' => 1,
|
||||
'pageCount' => 10,
|
||||
'urlParam' => 'pageNr',
|
||||
'baseUrl' => '/php/unit/test/',
|
||||
'mode' => 'url',
|
||||
);
|
||||
|
||||
$paginator = new Msd_View_Helper_Paginator();
|
||||
$paginator->setView($this->view);
|
||||
$result = $paginator->paginator($options);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton first" type="button" onclick="window.location.href = \'/php/unit/test/pageNr/1/\';" accesskey="c" disabled="disabled">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton paginator prev" type="button" onclick="window.location.href = \'/php/unit/test/pageNr/0/\';" accesskey="v" disabled="disabled">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<select id="combobox" name="pageNr" onchange="window.location.href = \'/php/unit/test/pageNr/\' + this.value + \'/\';" accesskey="b">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton next" type="button" onclick="window.location.href = \'/php/unit/test/pageNr/2/\';" accesskey="n">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '<button class="Formbutton last" type="button" onclick="window.location.href = \'/php/unit/test/pageNr/10/\';" accesskey="m">');
|
||||
$this->assertNotEquals(false, $button);
|
||||
|
||||
$button = strpos($result, '$("#combobox").combobox();');
|
||||
$this->assertNotEquals(false, $button);
|
||||
}
|
||||
}
|
||||
27
tests/unit/application/views/helpers/TimeToDateTest.php
Normale Datei
27
tests/unit/application/views/helpers/TimeToDateTest.php
Normale Datei
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
require_once 'TimeToDate.php';
|
||||
|
||||
/**
|
||||
* @group MsdViewHelper
|
||||
*/
|
||||
class TimeToDateTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testTimeToDate()
|
||||
{
|
||||
$expected='27.08.2010 00:49:48';
|
||||
$viewHelper = new Msd_View_Helper_TimeToDate();
|
||||
$res = $viewHelper->timeToDate('2010-08-27T00:49:48+02:00');
|
||||
$this->assertEquals($expected, $res);
|
||||
}
|
||||
|
||||
public function testInvalidTimeToDate()
|
||||
{
|
||||
$viewHelper = new Msd_View_Helper_TimeToDate();
|
||||
$res = $viewHelper->timeToDate('an invalid date timestamp');
|
||||
$this->assertEquals(
|
||||
'No date part in \'an invalid date timestamp\' found.', $res
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren