Skip to content
Permalink
Browse files

Fix header manipulation.

Convert headers from the format humans expect to the format PHP uses
internally.
  • Loading branch information...
markstory committed Sep 2, 2014
1 parent 07d559a commit 210fd896613ff4d550cd51d8963f13f42b1eaf4b
Showing with 7 additions and 1 deletion.
  1. +5 −1 src/TestSuite/IntegrationTestCase.php
  2. +2 −0 tests/TestCase/TestSuite/IntegrationTestCaseTest.php
@@ -226,7 +226,11 @@ protected function _buildRequest($url, $method, $data) {
'session' => $session,
];
if (isset($this->_request['headers'])) {
$props['environment'] = $this->_request['headers'];
$env = [];
foreach ($this->_request['headers'] as $k => $v) {
$env['HTTP_' . str_replace('-', '_', strtoupper($k))] = $v;
}
$props['environment'] = $env;
unset($this->_request['headers']);
}
$props += $this->_request;
@@ -54,6 +54,7 @@ public function testRequestBuilding() {
$this->session(['User' => ['id' => 1, 'username' => 'mark']]);
$request = $this->_buildRequest('/tasks/add', 'POST', ['title' => 'First post']);
$this->assertEquals('abc123', $request->header('X-CSRF-Token'));
$this->assertEquals('tasks/add', $request->url);
$this->assertEquals(['split_token' => 'def345'], $request->cookies);
$this->assertEquals(['id' => '1', 'username' => 'mark'], $request->session()->read('User'));
@@ -70,6 +71,7 @@ public function testSendingGet() {
$this->get('/request_action/test_request_action');
$this->assertNotEmpty($this->_response);
$this->assertInstanceOf('Cake\Network\Response', $this->_response);
$this->assertEquals('This is a test', $this->_response->body());
}
}

0 comments on commit 210fd89

Please sign in to comment.
You can’t perform that action at this time.