Ejemplo n.º 1
0
 public function testStartStop()
 {
     $helper = new ehough_templating_helper_SlotsHelper();
     $helper->start('bar');
     echo 'foo';
     $helper->stop();
     $this->assertEquals('foo', $helper->get('bar'), '->start() starts a slot');
     $this->assertTrue($helper->has('bar'), '->starts() starts a slot');
     $helper->start('bar');
     try {
         $helper->start('bar');
         $helper->stop();
         $this->fail('->start() throws an InvalidArgumentException if a slot with the same name is already started');
     } catch (Exception $e) {
         $helper->stop();
         $this->assertInstanceOf('InvalidArgumentException', $e, '->start() throws an InvalidArgumentException if a slot with the same name is already started');
         $this->assertEquals('A slot named "bar" is already started.', $e->getMessage(), '->start() throws an InvalidArgumentException if a slot with the same name is already started');
     }
     try {
         $helper->stop();
         $this->fail('->stop() throws an LogicException if no slot is started');
     } catch (Exception $e) {
         $this->assertInstanceOf('LogicException', $e, '->stop() throws an LogicException if no slot is started');
         $this->assertEquals('No slot started.', $e->getMessage(), '->stop() throws an LogicException if no slot is started');
     }
 }
Ejemplo n.º 2
0
 public function testGetSetCharset()
 {
     $helper = new ehough_templating_helper_SlotsHelper();
     $engine = new ProjectTemplateEngine(new ehough_templating_TemplateNameParser(), $this->loader, array($helper));
     $this->assertEquals('UTF-8', $engine->getCharset(), 'ehough_templating_EngineInterface::getCharset() returns UTF-8 by default');
     $this->assertEquals('UTF-8', $helper->getCharset(), 'ehough_templating_helper_HelperInterface::getCharset() returns UTF-8 by default');
     $engine->setCharset('ISO-8859-1');
     $this->assertEquals('ISO-8859-1', $engine->getCharset(), 'ehough_templating_EngineInterface::setCharset() changes the default charset to use');
     $this->assertEquals('ISO-8859-1', $helper->getCharset(), 'ehough_templating_EngineInterface::setCharset() changes the default charset of helper');
 }