Skip to content

Commit

Permalink
Deprecated View::uuid() as it's unused in core.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 13, 2018
1 parent 9d78fc4 commit 5570206
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/View/View.php
Expand Up @@ -198,7 +198,7 @@ class View implements EventDispatcherInterface
* List of generated DOM UUIDs.
*
* @var array
* @deprecated 3.7.0 The property is unused and will be removed in 4.0.0.
* @deprecated 3.7.0 The property is deprecated and will be removed in 4.0.0.
*/
public $uuids = [];

Expand Down Expand Up @@ -1143,9 +1143,12 @@ public function extend($name)
* @param string $object Type of object, i.e. 'form' or 'link'
* @param string $url The object's target URL
* @return string
* @deprecated 3.7.0 This method is deprecated and will be removed in 4.0.0.
*/
public function uuid($object, $url)
{
deprecationWarning('View::uuid() is deprecated and will be removed in 4.0.0.');

$c = 1;
$url = Router::url($url);
$hash = $object . substr(md5($object . $url), 0, 10);
Expand Down
16 changes: 9 additions & 7 deletions tests/TestCase/View/ViewTest.php
Expand Up @@ -858,15 +858,17 @@ public function testViewVars()
*/
public function testUUIDGeneration()
{
Router::connect('/:controller', ['action' => 'index']);
$result = $this->View->uuid('form', ['controller' => 'posts', 'action' => 'index']);
$this->assertEquals('form5988016017', $result);
$this->deprecated(function () {
Router::connect('/:controller', ['action' => 'index']);
$result = $this->View->uuid('form', ['controller' => 'posts', 'action' => 'index']);
$this->assertEquals('form5988016017', $result);

$result = $this->View->uuid('form', ['controller' => 'posts', 'action' => 'index']);
$this->assertEquals('formc3dc6be854', $result);
$result = $this->View->uuid('form', ['controller' => 'posts', 'action' => 'index']);
$this->assertEquals('formc3dc6be854', $result);

$result = $this->View->uuid('form', ['controller' => 'posts', 'action' => 'index']);
$this->assertEquals('form28f92cc87f', $result);
$result = $this->View->uuid('form', ['controller' => 'posts', 'action' => 'index']);
$this->assertEquals('form28f92cc87f', $result);
});
}

/**
Expand Down

0 comments on commit 5570206

Please sign in to comment.