Common = new CommonHelper($View); $this->Html = new CommonHelper($View); } /** * CommonHelperTest::testFlash() * * @return void */ public function testFlash() { $this->Common->addFlashMessage(h('Foo & bar'), 'success'); $result = $this->Common->flash(); $expected = '
'; $this->assertEquals($expected, $result); $this->Common->addFlashMessage('I am an error', 'error'); $this->Common->addFlashMessage('I am a warning', 'warning'); $this->Common->addFlashMessage('I am some info', 'info'); $this->Common->addFlashMessage('I am also some info'); $this->Common->addFlashMessage('I am sth custom', 'custom'); $result = $this->Common->flash(); $this->assertTextContains('message error', $result); $this->assertTextContains('message warning', $result); $this->assertTextContains('message info', $result); $this->assertTextContains('message custom', $result); $result = substr_count($result, 'message info'); $this->assertSame(2, $result); } /** * Test that you can define your own order or just output a subpart of * the types. * * @return void */ public function testFlashWithTypes() { $this->Common->addFlashMessage('I am an error', 'error'); $this->Common->addFlashMessage('I am a warning', 'warning'); $this->Common->addFlashMessage('I am some info', 'info'); $this->Common->addFlashMessage('I am also some info'); $this->Common->addFlashMessage('I am sth custom', 'custom'); $result = $this->Common->flash(array('warning', 'error')); $expected = ''; $this->assertEquals($expected, $result); $result = $this->Common->flash(array('info')); $expected = ''; $this->assertEquals($expected, $result); $result = $this->Common->flash(); $expected = ''; $this->assertEquals($expected, $result); } /** * @return void */ public function testMetaCanonical() { $is = $this->Common->metaCanonical('/some/url/param1'); $this->assertEquals('', trim($is)); $is = $this->Common->metaCanonical('/some/url/param1', true); $this->assertEquals('', trim($is)); } /** * @return void */ public function testMetaAlternate() { $is = $this->Common->metaAlternate('/some/url/param1', 'de-de', true); $this->out(h($is)); $this->assertEquals('', trim($is)); $is = $this->Common->metaAlternate(array('controller' => 'some', 'action' => 'url'), 'de', true); $this->out(h($is)); $this->assertEquals('', trim($is)); $is = $this->Common->metaAlternate(array('controller' => 'some', 'action' => 'url'), array('de', 'de-ch'), true); $this->out(h($is)); $this->assertEquals('' . PHP_EOL . '', trim($is)); $is = $this->Common->metaAlternate(array('controller' => 'some', 'action' => 'url'), array('de' => array('ch', 'at'), 'en' => array('gb', 'us')), true); $this->out(h($is)); $this->assertEquals('' . PHP_EOL . '' . PHP_EOL . '' . PHP_EOL . '', trim($is)); } /** * @return void */ public function testEsc() { $is = $this->Common->esc('Some Cool Text with Html'); $this->assertEquals($is, 'Some Cool Text with <b>Html</b>'); $is = $this->Common->esc('Some Cool Text' . PHP_EOL . 'with Html'); $this->assertEquals($is, 'Some Cool Text