Browse Source

Merge pull request #12033 from cakephp/here-attribute

Add 'here' to the emulated property set.
Jeremy Harris 7 years ago
parent
commit
9ff2776559
2 changed files with 4 additions and 1 deletions
  1. 1 1
      src/Http/ServerRequest.php
  2. 3 0
      tests/TestCase/Http/ServerRequestTest.php

+ 1 - 1
src/Http/ServerRequest.php

@@ -196,7 +196,7 @@ class ServerRequest implements ArrayAccess, ServerRequestInterface
      *
      * @var array
      */
-    protected $emulatedAttributes = ['session', 'webroot', 'base', 'params'];
+    protected $emulatedAttributes = ['session', 'webroot', 'base', 'params', 'here'];
 
     /**
      * Array of Psr\Http\Message\UploadedFileInterface objects.

+ 3 - 0
tests/TestCase/Http/ServerRequestTest.php

@@ -3590,6 +3590,7 @@ XML;
                     'controller' => 'Articles',
                     'action' => 'index'
                 ],
+                'url' => '/articles/view',
                 'base' => '/cakeapp',
                 'webroot' => '/cakeapp/'
             ]);
@@ -3597,6 +3598,7 @@ XML;
             if ($prop === 'session') {
                 $this->assertSame($request->getSession(), $request->getAttribute($prop));
             } else {
+                $this->assertNotEmpty($request->getAttribute($prop));
                 $this->assertSame($request->{$prop}, $request->getAttribute($prop));
             }
         });
@@ -3733,6 +3735,7 @@ XML;
     public function emulatedPropertyProvider()
     {
         return [
+            ['here'],
             ['params'],
             ['base'],
             ['webroot'],