Skip to content

Commit

Permalink
Update test controllers to use undeprecated APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 16, 2017
1 parent 34eacb1 commit a8665a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion tests/Fixture/AssertIntegrationTestCase.php
Expand Up @@ -18,7 +18,7 @@ class AssertIntegrationTestCase extends IntegrationTestCase
public function testBadAssertNoRedirect()
{
$this->_response = new Response();
$this->_response->header('Location', 'http://localhost/tasks/index');
$this->_response = $this->_response->withLocation('http://localhost/tasks/index');

$this->assertNoRedirect();
}
Expand Down
59 changes: 19 additions & 40 deletions tests/test_app/TestApp/Controller/RequestActionController.php
Expand Up @@ -35,9 +35,7 @@ class RequestActionController extends AppController
*/
public function test_request_action()
{
$this->response->body('This is a test');

return $this->response;
return $this->response->withStringBody('This is a test');
}

/**
Expand All @@ -49,9 +47,7 @@ public function test_request_action()
*/
public function another_ra_test($id, $other)
{
$this->response->body($id + $other);

return $this->response;
return $this->response->withStringBody($id + $other);
}

/**
Expand All @@ -61,9 +57,7 @@ public function another_ra_test($id, $other)
*/
public function normal_request_action()
{
$this->response->body('Hello World');

return $this->response;
return $this->response->withStringBody('Hello World');
}

/**
Expand All @@ -73,9 +67,7 @@ public function normal_request_action()
*/
public function return_here()
{
$this->response->body($this->here);

return $this->response;
return $this->response->withStringBody($this->here);
}

/**
Expand All @@ -96,9 +88,7 @@ public function paginate_request_action()
*/
public function post_pass()
{
$this->response->body(json_encode($this->request->data));

return $this->response;
return $this->response->withStringBody(json_encode($this->request->data));
}

/**
Expand All @@ -108,9 +98,7 @@ public function post_pass()
*/
public function query_pass()
{
$this->response->body(json_encode($this->request->query));

return $this->response;
return $this->response->withStringBody(json_encode($this->request->query));
}

/**
Expand All @@ -120,9 +108,7 @@ public function query_pass()
*/
public function cookie_pass()
{
$this->response->body(json_encode($this->request->cookies));

return $this->response;
return $this->response->withStringBody(json_encode($this->request->cookies));
}

/**
Expand All @@ -132,18 +118,15 @@ public function cookie_pass()
*/
public function params_pass()
{
$this->response->body(json_encode([
'params' => $this->request->params,
'base' => $this->request->base,
'here' => $this->request->here,
'webroot' => $this->request->webroot,
'params' => $this->request->params,
'query' => $this->request->query,
'url' => $this->request->url,
return $this->response->withStringBody(json_encode([
'params' => $this->request->getAttribute('params'),
'base' => $this->request->getAttribute('base'),
'here' => $this->request->getRequestTarget(),
'webroot' => $this->request->getAttribute('webroot'),
'query' => $this->request->getQueryParams(),
'url' => $this->request->getUri()->getPath(),
'contentType' => $this->request->contentType(),
]));

return $this->response;
}

/**
Expand All @@ -155,12 +138,10 @@ public function param_check()
{
$this->autoRender = false;
$content = '';
if (isset($this->request->params[0])) {
if ($this->request->getParam('0')) {
$content = 'return found';
}
$this->response->body($content);

return $this->response;
return $this->response->withStringBody($content);
}

/**
Expand All @@ -170,9 +151,7 @@ public function param_check()
*/
public function session_test()
{
$this->response->body($this->request->session()->read('foo'));

return $this->response;
return $this->response->withStringBody($this->request->getSession()->read('foo'));
}

/**
Expand All @@ -182,9 +161,9 @@ public function session_test()
*/
public function input_test()
{
$this->response->body($this->request->input('json_decode')->hello);
$text = $this->request->input('json_decode')->hello;

return $this->response;
return $this->response->withStringBody($text);
}

/**
Expand Down
12 changes: 4 additions & 8 deletions tests/test_app/TestApp/Controller/TestsAppsController.php
Expand Up @@ -31,17 +31,15 @@ class TestsAppsController extends AppController
public function index()
{
$var = '';
if (isset($this->request->query['var'])) {
$var = $this->request->query['var'];
if ($this->request->getQuery('var')) {
$var = $this->request->getQuery('var');
}
$this->set('var', $var);
}

public function some_method()
{
$this->response->body(5);

return $this->response;
return $this->response->withStringBody(5);
}

public function set_action()
Expand All @@ -62,9 +60,7 @@ public function redirect_to_permanent()

public function set_type()
{
$this->response->type('json');

return $this->response;
return $this->response->withType('json');
}

public function throw_exception()
Expand Down

0 comments on commit a8665a0

Please sign in to comment.