'; const PREFIX = '
'; const SUFFIX = '
'; protected static $statusTags = array('OK', 'WARNING', 'CRITICAL', 'UNKNOWN', 'UP', 'DOWN'); public function setUp() { parent::setUp(); $this->helper = $h = new Zend_View_Helper_PluginOutput; $h->setView(new View()); } protected function checkOutput($output, $html, $regexp = false, $isHtml = false) { $actual = $this->helper->pluginOutput($output); if ($isHtml) { $prefix = self::PREFIX; } else { $prefix = self::PREFIX_PRE; } if ($regexp) { $expect = sprintf( '~%s%s%s~', preg_quote($prefix, '~'), $html, preg_quote(self::SUFFIX, '~') ); $this->assertRegExp($expect, $actual, 'Output must match example regexp'); } else { $expect = $prefix . $html . self::SUFFIX; $this->assertEquals($expect, $actual, 'Output must match example'); } } protected function checkHtmlOutput($outputHtml, $html, $regexp = false) { return $this->checkOutput($outputHtml, $html, $regexp, true); } public function testSimpleOutput() { $this->checkOutput( 'Foobar', 'Foobar' ); } public function testOutputWithHtmlEntities() { $this->checkOutput( 'foo & bar', 'foo & bar' ); } public function testSimpleHtmlOutput() { /** @noinspection HtmlUnknownAttribute */ $this->checkHtmlOutput( 'OK - Teststatus Info', 'OK - Teststatus ]*>Info', true ); } public function testMultilineHtmlOutput() { $input = array( 'Teststatus', 'Info

' . 'Info2' ); /** @noinspection HtmlUnknownAttribute */ $output = array( 'Teststatus', ']*>Info

' . ']*>Info2' ); $this->checkHtmlOutput( join("\n", $input), join("\n", $output), true ); } public function testHtmlTable() { $this->markTestIncomplete(); } public function testAllowedHtmlTags() { $this->markTestIncomplete(); } public function testTextStatusTags() { foreach (self::$statusTags as $s) { $l = strtolower($s); $this->checkOutput( sprintf('[%s] Test', $s), sprintf('[%s] Test', $l, $s) ); $this->checkOutput( sprintf('(%s) Test', $s), sprintf('(%s) Test', $l, $s) ); } } public function testHtmlStatusTags() { $dummyHtml = ''; foreach (self::$statusTags as $s) { $l = strtolower($s); $this->checkHtmlOutput( sprintf('%s [%s] Test', $dummyHtml, $s), sprintf('%s [%s] Test', $dummyHtml, $l, $s) ); $this->checkHtmlOutput( sprintf('%s (%s) Test', $dummyHtml, $s), sprintf('%s (%s) Test', $dummyHtml, $l, $s) ); } } }