浏览代码

Move cookie to shim

dereuromark 9 年之前
父节点
当前提交
d0b08ccec6
共有 2 个文件被更改,包括 0 次插入122 次删除
  1. 0 45
      src/View/Helper/CookieHelper.php
  2. 0 77
      tests/TestCase/View/Helper/CookieHelperTest.php

+ 0 - 45
src/View/Helper/CookieHelper.php

@@ -1,45 +0,0 @@
-<?php
-
-namespace Tools\View\Helper;
-
-use Cake\View\Helper;
-
-/**
- * Cookie Helper.
- */
-class CookieHelper extends Helper {
-
-	/**
-	 * Reads a cookie value for a key or return values for all keys.
-	 *
-	 * In your view: `$this->Cookie->read('key');`
-	 *
-	 * @param string|null $name the name of the cookie key you want to read
-	 * @return mixed values from the cookie vars
-	 */
-	public function read($name = null) {
-		return $this->request->cookie($name);
-	}
-
-	/**
-	 * Checks if a cookie key has been set.
-	 *
-	 * In your view: `$this->Cookie->check('key');`
-	 *
-	 * @param string $name Cookie name to check.
-	 * @return bool
-	 */
-	public function check($name) {
-		return $this->request->cookie($name) !== null;
-	}
-
-	/**
-	 * Event listeners.
-	 *
-	 * @return array
-	 */
-	public function implementedEvents() {
-		return [];
-	}
-
-}

+ 0 - 77
tests/TestCase/View/Helper/CookieHelperTest.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace Tools\Test\TestCase\View\Helper;
-
-use Cake\Network\Request;
-use Cake\ORM\Table;
-use Cake\View\View;
-use Tools\TestSuite\TestCase;
-use Tools\View\Helper\CookieHelper;
-
-class CookieHelperTest extends TestCase {
-
-	/**
-	 * @var \Tools\View\Helper\CookieHelper
-	 */
-	public $Cookie;
-
-	/**
-	 * @return void
-	 */
-	public function setUp() {
-		parent::setUp();
-
-		$this->Cookie = new CookieHelper(new View(null));
-		$this->Cookie->request = $this->getMockBuilder(Request::class)->setMethods(['cookie'])->getMock();
-	}
-
-	/**
-	 * @return void
-	 */
-	public function tearDown() {
-		unset($this->Table);
-
-		parent::tearDown();
-	}
-
-	/**
-	 * CookieHelperTest::testObject()
-	 *
-	 * @return void
-	 */
-	public function testObject() {
-		$this->assertInstanceOf('Tools\View\Helper\CookieHelper', $this->Cookie);
-	}
-
-	/**
-	 * CookieHelperTest::testCheck()
-	 *
-	 * @return void
-	 */
-	public function testCheck() {
-		$this->Cookie->request->expects($this->at(0))
-			->method('cookie')
-			->will($this->returnValue(null));
-		$this->Cookie->request->expects($this->at(1))
-			->method('cookie')
-			->will($this->returnValue('val'));
-
-		$this->assertFalse($this->Cookie->check('Foo.key'));
-		$this->assertTrue($this->Cookie->check('Foo.key'));
-	}
-
-	/**
-	 * CookieHelperTest::testRead()
-	 *
-	 * @return void
-	 */
-	public function testRead() {
-		$this->Cookie->request->expects($this->once())
-			->method('cookie')
-			->will($this->returnValue('val'));
-
-		$output = $this->Cookie->read('Foo.key');
-		$this->assertTextEquals('val', $output);
-	}
-
-}