-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #899 from cakephp/fix-request-params
Fix request panel data saving with authentication
- Loading branch information
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
**/ | ||
namespace DebugKit\Test\TestCase\Panel; | ||
|
||
use Cake\Controller\Controller; | ||
use Cake\Event\Event; | ||
use Cake\Http\ServerRequest; | ||
use Cake\TestSuite\TestCase; | ||
use DebugKit\Panel\RequestPanel; | ||
|
||
/** | ||
* Class RequestPanelTest | ||
*/ | ||
class RequestPanelTest extends TestCase | ||
{ | ||
/** | ||
* @var RequestPanel | ||
*/ | ||
protected $panel; | ||
|
||
/** | ||
* set up | ||
* | ||
* @return void | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->panel = new RequestPanel(); | ||
} | ||
|
||
/** | ||
* Test that shutdown will skip unserializable attributes. | ||
* | ||
* @return void | ||
*/ | ||
public function testShutdownSkipAttributes() | ||
{ | ||
$request = new ServerRequest([ | ||
'url' => '/', | ||
'post' => ['name' => 'bob'], | ||
'query' => ['page' => 1], | ||
]); | ||
$request = $request | ||
->withAttribute('ok', 'string') | ||
->withAttribute('closure', function () { | ||
}); | ||
|
||
$controller = new Controller($request); | ||
$event = new Event('Controller.shutdown', $controller); | ||
$this->panel->shutdown($event); | ||
|
||
$data = $this->panel->data(); | ||
$this->assertArrayHasKey('attributes', $data); | ||
$this->assertEquals('string', $data['attributes']['ok']); | ||
$this->assertStringContainsString('Could not serialize `closure`', $data['attributes']['closure']); | ||
} | ||
} |