Browse Source

Deprecated ServerRequest::addPaths()

This method modifies requests in place, we can't have that with PSR7
requests.
Mark Story 8 years ago
parent
commit
7a865a5ddd
2 changed files with 8 additions and 5 deletions
  1. 4 0
      src/Http/ServerRequest.php
  2. 4 5
      tests/TestCase/View/Helper/UrlHelperTest.php

+ 4 - 0
src/Http/ServerRequest.php

@@ -945,6 +945,10 @@ class ServerRequest implements ArrayAccess, ServerRequestInterface
      */
     public function addPaths(array $paths)
     {
+        deprecationWarning(
+            'ServerRequest::addPaths() is deprecated. ' .
+            'Use `withAttribute($key, $value)` instead.'
+        );
         foreach (['webroot', 'here', 'base'] as $element) {
             if (isset($paths[$element])) {
                 $this->{$element} = $paths[$element];

+ 4 - 5
tests/TestCase/View/Helper/UrlHelperTest.php

@@ -212,11 +212,10 @@ class UrlHelperTest extends TestCase
      */
     public function testAssetUrlNoRewrite()
     {
-        $this->Helper->request->addPaths([
-            'base' => '/cake_dev/index.php',
-            'webroot' => '/cake_dev/app/webroot/',
-            'here' => '/cake_dev/index.php/tasks',
-        ]);
+        $this->Helper->request = $this->Helper->request
+            ->withAttribute('base', '/cake_dev/index.php')
+            ->withAttribute('webroot', '/cake_dev/app/webroot/')
+            ->withRequestTarget('/cake_dev/index.php/tasks');
         $result = $this->Helper->assetUrl('img/cake.icon.png', ['fullBase' => true]);
         $expected = Configure::read('App.fullBaseUrl') . '/cake_dev/app/webroot/img/cake.icon.png';
         $this->assertEquals($expected, $result);