euromark 11 年之前
父节点
当前提交
af62cb7aab
共有 1 个文件被更改,包括 67 次插入0 次删除
  1. 67 0
      tests/TestCase/View/Helper/JsHelperTest.php

+ 67 - 0
tests/TestCase/View/Helper/JsHelperTest.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace Tools\TestCase\View\Helper;
+
+use Tools\View\Helper\JsHelper;
+use Cake\TestSuite\TestCase;
+use Cake\View\View;
+use Cake\ORM\TableRegistry;
+use Cake\Datasource\ConnectionManager;
+use Cake\Core\Configure;
+
+class JsHelperTest extends TestCase {
+
+	/**
+	 * @return void
+	 */
+	public function setUp() {
+		parent::setUp();
+
+		$this->Js = new JsHelper(new View(null));
+	}
+
+	/**
+	 * @return void
+	 */
+	public function tearDown() {
+		unset($this->Table);
+
+ 		//TableRegistry::clear();
+		parent::tearDown();
+	}
+
+	/**
+	 * @return void
+	 */
+	public function testObject() {
+		$this->assertInstanceOf('Tools\View\Helper\JsHelper', $this->Js);
+	}
+
+	/**
+	 * JsHelperTest::testBuffer()
+	 *
+	 * @return void
+	 */
+	public function testBuffer() {
+		$script = <<<JS
+jQuery(document).ready(function() {
+	// Code
+});
+JS;
+		$this->Js->buffer($script);
+
+		$output = $this->Js->writeBuffer();
+
+		$expected = <<<HTML
+<script>
+//<![CDATA[
+jQuery(document).ready(function() {
+	// Code
+});
+//]]>
+</script>
+HTML;
+		$this->assertTextEquals($expected, $output);
+	}
+
+}