basePath = dirname(__FILE__) . '/_files/modules'; $this->helper = new Zend_View_Helper_HeadTitle(); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @return void */ public function tearDown() { unset($this->helper); } public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation() { $registry = Zend_View_Helper_Placeholder_Registry::getRegistry(); if ($registry->containerExists('Zend_View_Helper_HeadTitle')) { $registry->deleteContainer('Zend_View_Helper_HeadTitle'); } $this->assertFalse($registry->containerExists('Zend_View_Helper_HeadTitle')); $helper = new Zend_View_Helper_HeadTitle(); $this->assertTrue($registry->containerExists('Zend_View_Helper_HeadTitle')); } public function testHeadTitleReturnsObjectInstance() { $placeholder = $this->helper->headTitle(); $this->assertTrue($placeholder instanceof Zend_View_Helper_HeadTitle); } public function testCanSetTitleViaHeadTitle() { $placeholder = $this->helper->headTitle('Foo Bar', 'SET'); $this->assertContains('Foo Bar', $placeholder->toString()); } public function testCanAppendTitleViaHeadTitle() { $placeholder = $this->helper->headTitle('Foo'); $placeholder = $this->helper->headTitle('Bar'); $this->assertContains('FooBar', $placeholder->toString()); } public function testCanPrependTitleViaHeadTitle() { $placeholder = $this->helper->headTitle('Foo'); $placeholder = $this->helper->headTitle('Bar', 'PREPEND'); $this->assertContains('BarFoo', $placeholder->toString()); } public function testReturnedPlaceholderToStringContainsFullTitleElement() { $placeholder = $this->helper->headTitle('Foo'); $placeholder = $this->helper->headTitle('Bar', 'APPEND')->setSeparator(' :: '); $this->assertEquals('Foo :: Bar', $placeholder->toString()); } public function testToStringEscapesEntries() { $this->helper->headTitle(''); $string = $this->helper->toString(); $this->assertNotContains('assertNotContains('', $string); } public function testToStringEscapesSeparator() { $this->helper->headTitle('Foo') ->headTitle('Bar') ->setSeparator('
'); $string = $this->helper->toString(); $this->assertNotContains('
', $string); $this->assertContains('Foo', $string); $this->assertContains('Bar', $string); $this->assertContains('br /', $string); } public function testIndentationIsHonored() { $this->helper->setIndent(4); $this->helper->headTitle('foo'); $string = $this->helper->toString(); $this->assertContains(' ', $string); } public function testAutoEscapeIsHonored() { $this->helper->headTitle('Some Title ©right;'); $this->assertEquals('<title>Some Title &copyright;', $this->helper->toString()); $this->assertTrue($this->helper->headTitle()->getAutoEscape()); $this->helper->headTitle()->setAutoEscape(false); $this->assertFalse($this->helper->headTitle()->getAutoEscape()); $this->assertEquals('Some Title ©right;', $this->helper->toString()); } /** * @issue ZF-2918 * @link http://framework.zend.com/issues/browse/ZF-2918 */ public function testZF2918() { $this->helper->headTitle('Some Title'); $this->helper->setPrefix('Prefix: '); $this->helper->setPostfix(' :Postfix'); $this->assertEquals('Prefix: Some Title :Postfix', $this->helper->toString()); } /** * @issue ZF-3577 * @link http://framework.zend.com/issues/browse/ZF-3577 */ public function testZF3577() { $this->helper->setAutoEscape(true); $this->helper->headTitle('Some Title'); $this->helper->setPrefix('Prefix & '); $this->helper->setPostfix(' & Postfix'); $this->assertEquals('Prefix & Some Title & Postfix', $this->helper->toString()); } public function testCanTranslateTitle() { require_once 'Zend/Translate/Adapter/Ini.php'; require_once 'Zend/Registry.php'; $adapter = new Zend_Translate_Adapter_Ini(dirname(__FILE__) . '/../../Translate/Adapter/_files/translation_en.ini', 'en'); Zend_Registry::set('Zend_Translate', $adapter); $this->helper->enableTranslation(); $this->helper->headTitle('Message_1'); $this->assertEquals('Message 1 (en)', $this->helper->toString()); } /** * @see ZF-8036 */ public function testHeadTitleZero() { $this->helper->headTitle('0'); $this->assertEquals('0', $this->helper->toString()); } } // Call Zend_View_Helper_HeadTitleTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_HeadTitleTest::main") { Zend_View_Helper_HeadTitleTest::main(); }