浏览代码

Adjust methods.

dereuromark 9 年之前
父节点
当前提交
e7831a9ac1

+ 12 - 12
src/Controller/Component/UrlComponent.php

@@ -43,7 +43,7 @@ class UrlComponent extends Component {
 	 * @param bool $full If true, the full base URL will be prepended to the result
 	 * @return string Full translated URL with base path.
 	 */
-	public function reset($url = null, $full = false) {
+	public function buildReset($url = null, $full = false) {
 		if (is_array($url)) {
 			$url += $this->defaults();
 		}
@@ -60,7 +60,7 @@ class UrlComponent extends Component {
 	 * @param bool $full If true, the full base URL will be prepended to the result
 	 * @return string Full translated URL with base path.
 	 */
-	public function complete($url = null, $full = false) {
+	public function buildComplete($url = null, $full = false) {
 		if (is_array($url)) {
 			$url = $this->addQueryStrings($url);
 		}
@@ -69,16 +69,6 @@ class UrlComponent extends Component {
 	}
 
 	/**
-	 * @return array
-	 */
-	public function defaults() {
-		return [
-			'prefix' => false,
-			'plugin' => false
-		];
-	}
-
-	/**
 	 * Returns a URL based on provided parameters.
 	 *
 	 * ### Options:
@@ -103,6 +93,16 @@ class UrlComponent extends Component {
 	}
 
 	/**
+	 * @return array
+	 */
+	public function defaults() {
+		return [
+			'prefix' => false,
+			'plugin' => false
+		];
+	}
+
+	/**
 	 * @param array $url
 	 *
 	 * @return array

+ 12 - 12
src/View/Helper/UrlHelper.php

@@ -55,7 +55,7 @@ class UrlHelper extends CoreUrlHelper {
 	 * @param bool $full If true, the full base URL will be prepended to the result
 	 * @return string Full translated URL with base path.
 	 */
-	public function reset($url = null, $full = false) {
+	public function buildReset($url = null, $full = false) {
 		if (is_array($url)) {
 			$url += $this->defaults();
 		}
@@ -64,16 +64,6 @@ class UrlHelper extends CoreUrlHelper {
 	}
 
 	/**
-	 * @return array
-	 */
-	public function defaults() {
-		return [
-			'prefix' => false,
-			'plugin' => false
-		];
-	}
-
-	/**
 	 * Returns a URL based on provided parameters.
 	 *
 	 * Can only add query strings for array URLs.
@@ -82,7 +72,7 @@ class UrlHelper extends CoreUrlHelper {
 	 * @param bool $full If true, the full base URL will be prepended to the result
 	 * @return string Full translated URL with base path.
 	 */
-	public function complete($url = null, $full = false) {
+	public function buildComplete($url = null, $full = false) {
 		if (is_array($url)) {
 			$url = $this->addQueryStrings($url);
 		}
@@ -91,6 +81,16 @@ class UrlHelper extends CoreUrlHelper {
 	}
 
 	/**
+	 * @return array
+	 */
+	public function defaults() {
+		return [
+			'prefix' => false,
+			'plugin' => false
+		];
+	}
+
+	/**
 	 * @param array $url
 	 *
 	 * @return array

+ 6 - 6
tests/TestCase/Controller/Component/UrlComponentTest.php

@@ -102,10 +102,10 @@ class UrlComponentTest extends TestCase {
 	/**
 	 * @return void
 	 */
-	public function testReset() {
+	public function testBuildReset() {
 		Router::connect('/:controller/:action/*');
 
-		$result = $this->Controller->Url->reset(['controller' => 'foobar', 'action' => 'test']);
+		$result = $this->Controller->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
 		$expected = '/foobar/test';
 		$this->assertSame($expected, $result);
 
@@ -129,7 +129,7 @@ class UrlComponentTest extends TestCase {
 		$expected = '/admin/foo/bar/baz/x';
 		$this->assertSame($expected, $result);
 
-		$result = $this->Controller->Url->reset(['controller' => 'bar', 'action' => 'baz', 'x']);
+		$result = $this->Controller->Url->buildReset(['controller' => 'bar', 'action' => 'baz', 'x']);
 		$expected = '/bar/baz/x';
 		$this->assertSame($expected, $result);
 	}
@@ -137,14 +137,14 @@ class UrlComponentTest extends TestCase {
 	/**
 	 * @return void
 	 */
-	public function testComplete() {
+	public function testBuildComplete() {
 		$this->Controller->Url->request->query['x'] = 'y';
 
-		$result = $this->Controller->Url->complete(['action' => 'test']);
+		$result = $this->Controller->Url->buildComplete(['action' => 'test']);
 		$expected = '/test?x=y';
 		$this->assertSame($expected, $result);
 
-		$result = $this->Controller->Url->complete(['action' => 'test', '?' => ['a' => 'b']]);
+		$result = $this->Controller->Url->buildComplete(['action' => 'test', '?' => ['a' => 'b']]);
 		$expected = '/test?a=b&x=y';
 		$this->assertSame($expected, $result);
 

+ 14 - 15
tests/TestCase/View/Helper/UrlHelperTest.php

@@ -15,6 +15,11 @@ use Tools\View\Helper\UrlHelper;
 class UrlHelperTest extends TestCase {
 
 	/**
+	 * @var \Tools\View\Helper\UrlHelper
+	 */
+	protected $Url;
+
+	/**
 	 * @return void
 	 */
 	public function setUp() {
@@ -26,14 +31,12 @@ class UrlHelperTest extends TestCase {
 	}
 
 	/**
-	 * Tests
-	 *
 	 * @return void
 	 */
-	public function testReset() {
+	public function testBuildReset() {
 		Router::connect('/:controller/:action/*');
 
-		$result = $this->Url->reset(['controller' => 'foobar', 'action' => 'test']);
+		$result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
 		$expected = '/foobar/test';
 		$this->assertSame($expected, $result);
 
@@ -54,20 +57,18 @@ class UrlHelperTest extends TestCase {
 		$expected = '/admin/foobar/test';
 		$this->assertSame($expected, $result);
 
-		$result = $this->Url->reset(['controller' => 'foobar', 'action' => 'test']);
+		$result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
 		$expected = '/foobar/test';
 		$this->assertSame($expected, $result);
 	}
 
 	/**
-	 * Tests
-	 *
 	 * @return void
 	 */
-	public function testResetWithPlugin() {
+	public function testBuildResetWithPlugin() {
 		Router::connect('/:controller/:action/*');
 
-		$result = $this->Url->reset(['controller' => 'foobar', 'action' => 'test']);
+		$result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
 		$expected = '/foobar/test';
 		$this->assertSame($expected, $result);
 
@@ -91,24 +92,22 @@ class UrlHelperTest extends TestCase {
 		$expected = '/admin/foo/bar/baz/x';
 		$this->assertSame($expected, $result);
 
-		$result = $this->Url->reset(['controller' => 'bar', 'action' => 'baz', 'x']);
+		$result = $this->Url->buildReset(['controller' => 'bar', 'action' => 'baz', 'x']);
 		$expected = '/bar/baz/x';
 		$this->assertSame($expected, $result);
 	}
 
 	/**
-	 * Tests
-	 *
 	 * @return void
 	 */
-	public function testComplete() {
+	public function testBuildComplete() {
 		$this->Url->request->query['x'] = 'y';
 
-		$result = $this->Url->complete(['action' => 'test']);
+		$result = $this->Url->buildComplete(['action' => 'test']);
 		$expected = '/test?x=y';
 		$this->assertSame($expected, $result);
 
-		$result = $this->Url->complete(['action' => 'test', '?' => ['a' => 'b']]);
+		$result = $this->Url->buildComplete(['action' => 'test', '?' => ['a' => 'b']]);
 		$expected = '/test?a=b&x=y';
 		$this->assertSame($expected, $result);
 	}