|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace Cake\Test\View;
|
|
|
|
|
|
+use Cake\Core\Plugin;
|
|
|
use Cake\TestSuite\TestCase;
|
|
|
use Cake\View\StringTemplate;
|
|
|
|
|
|
@@ -67,4 +68,36 @@ class StringTemplateTest extends TestCase {
|
|
|
$this->assertEquals('<a href="/">example</a>', $result);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Test loading templates files in the app.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testLoad() {
|
|
|
+ $this->assertEquals([], $this->template->get());
|
|
|
+ $this->assertNull($this->template->load('test_templates'));
|
|
|
+ $this->assertEquals('<a href="{{url}}">{{text}}</a>', $this->template->get('link'));
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test loading templates files from a plugin
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testLoadPlugin() {
|
|
|
+ Plugin::load('TestPlugin');
|
|
|
+ $this->assertNull($this->template->load('TestPlugin.test_templates'));
|
|
|
+ $this->assertEquals('<em>{{text}}</em>', $this->template->get('italic'));
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test that loading non-existing templates causes errors.
|
|
|
+ *
|
|
|
+ * @expectedException Cake\Error\Exception
|
|
|
+ * @expectedExceptionMessage Could not load configuration file
|
|
|
+ */
|
|
|
+ public function testLoadErrorNoFile() {
|
|
|
+ $this->template->load('no_such_file');
|
|
|
+ }
|
|
|
+
|
|
|
}
|