Prechádzať zdrojové kódy

Improve test coverage.

Justin Hileman 12 rokov pred
rodič
commit
a467124a46

+ 44 - 0
test/Mustache/Test/Cache/AbstractCacheTest.php

@@ -0,0 +1,44 @@
+<?php
+
+/*
+ * This file is part of Mustache.php.
+ *
+ * (c) 2013 Justin Hileman
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+class Mustache_Test_Cache_AbstractCacheTest extends PHPUnit_Framework_TestCase
+{
+    public function testGetSetLogger()
+    {
+         $cache  = new CacheStub();
+         $logger = new Mustache_Logger_StreamLogger('php://stdout');
+         $cache->setLogger($logger);
+         $this->assertSame($logger, $cache->getLogger());
+    }
+
+    /**
+     * @expectedException Mustache_Exception_InvalidArgumentException
+     */
+    public function testSetLoggerThrowsExceptions()
+    {
+        $cache  = new CacheStub();
+        $logger = new StdClass();
+        $cache->setLogger($logger);
+    }
+}
+
+class CacheStub extends Mustache_Cache_AbstractCache
+{
+    public function load($key)
+    {
+        // nada
+    }
+
+    public function cache($key, $value)
+    {
+        // nada
+    }
+}

+ 2 - 0
test/Mustache/Test/EngineTest.php

@@ -45,6 +45,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
                 'bar' => 'BAR',
             ),
             'escape'  => 'strtoupper',
+            'entity_flags' => ENT_QUOTES,
             'charset' => 'ISO-8859-1',
         ));
 
@@ -54,6 +55,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('{{ foo }}', $partialsLoader->load('foo'));
         $this->assertContains('__whot__', $mustache->getTemplateClassName('{{ foo }}'));
         $this->assertEquals('strtoupper', $mustache->getEscape());
+        $this->assertEquals(ENT_QUOTES, $mustache->getEntityFlags());
         $this->assertEquals('ISO-8859-1', $mustache->getCharset());
         $this->assertTrue($mustache->hasHelper('foo'));
         $this->assertTrue($mustache->hasHelper('bar'));