浏览代码

Add helper

euromark 11 年之前
父节点
当前提交
dafa826ec5
共有 2 个文件被更改,包括 60 次插入0 次删除
  1. 18 0
      src/View/Helper/TextHelper.php
  2. 42 0
      tests/TestCase/View/Helper/TextHelperTest.php

+ 18 - 0
src/View/Helper/TextHelper.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace Tools\View\Helper;
+
+use Cake\Utility\Hash;
+use Cake\View\Helper\TextHelper as CakeTextHelper;
+
+/**
+ * Ovewrite to allow usage of own Text class.
+ */
+class TextHelper extends CakeTextHelper {
+
+	public function __construct($View = null, $options = array()) {
+		$options = Hash::merge(array('engine' => 'Tools.Text'), $options);
+		parent::__construct($View, $options);
+	}
+
+}

+ 42 - 0
tests/TestCase/View/Helper/TextHelperTest.php

@@ -0,0 +1,42 @@
+<?php
+namespace Tools\TestCase\View\Helper;
+
+use Tools\View\Helper\TextHelper;
+use Tools\TestSuite\TestCase;
+use Cake\View\View;
+use Cake\Core\Configure;
+
+/**
+ * DateText Test Case
+ *
+ */
+class TextHelperTest extends TestCase {
+
+	public function setUp() {
+		parent::setUp();
+
+		$this->Text = new TextHelper(new View(null));
+	}
+
+	/**
+	 * TearDown method
+	 *
+	 * @return void
+	 */
+	public function tearDown() {
+		parent::tearDown();
+
+		unset($this->Text);
+	}
+
+	/**
+	 * Test calling Utility.Text class
+	 *
+	 * @return void
+	 */
+	public function testParentCall() {
+		$result = $this->Text->abbreviate('FooBar');
+		$this->assertSame('FooBar', $result);
+	}
+
+}