Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Make MakesHttpRequest methods accept method chaining #13529

Merged
merged 1 commit into from
May 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,12 @@ protected function seeCookie($cookieName, $value = null, $encrypted = true)
$actual = $encrypted
? $this->app['encrypter']->decrypt($cookieValue) : $cookieValue;

return $this->assertEquals(
$this->assertEquals(
$actual, $value,
"Cookie [{$cookieName}] was found, but value [{$actual}] does not match [{$value}]."
);

return $this;
}

/**
Expand Down Expand Up @@ -615,34 +617,38 @@ protected function transformHeadersToServerVars(array $headers)
/**
* Assert that the client response has an OK status code.
*
* @return void
* @return $this
*/
public function assertResponseOk()
{
$actual = $this->response->getStatusCode();

return PHPUnit::assertTrue($this->response->isOk(), "Expected status code 200, got {$actual}.");
PHPUnit::assertTrue($this->response->isOk(), "Expected status code 200, got {$actual}.");

return $this;
}

/**
* Assert that the client response has a given code.
*
* @param int $code
* @return void
* @return $this
*/
public function assertResponseStatus($code)
{
$actual = $this->response->getStatusCode();

return PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}.");
PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}.");

return $this;
}

/**
* Assert that the response view has a given piece of bound data.
*
* @param string|array $key
* @param mixed $value
* @return void
* @return $this
*/
public function assertViewHas($key, $value = null)
{
Expand All @@ -659,13 +665,15 @@ public function assertViewHas($key, $value = null)
} else {
PHPUnit::assertEquals($value, $this->response->original->$key);
}

return $this;
}

/**
* Assert that the view has a given list of bound data.
*
* @param array $bindings
* @return void
* @return $this
*/
public function assertViewHasAll(array $bindings)
{
Expand All @@ -676,13 +684,15 @@ public function assertViewHasAll(array $bindings)
$this->assertViewHas($key, $value);
}
}

return $this;
}

/**
* Assert that the response view is missing a piece of bound data.
*
* @param string $key
* @return void
* @return $this
*/
public function assertViewMissing($key)
{
Expand All @@ -691,14 +701,16 @@ public function assertViewMissing($key)
}

PHPUnit::assertArrayNotHasKey($key, $this->response->original->getData());

return $this;
}

/**
* Assert whether the client was redirected to a given URI.
*
* @param string $uri
* @param array $with
* @return void
* @return $this
*/
public function assertRedirectedTo($uri, $with = [])
{
Expand All @@ -707,6 +719,8 @@ public function assertRedirectedTo($uri, $with = [])
PHPUnit::assertEquals($this->app['url']->to($uri), $this->response->headers->get('Location'));

$this->assertSessionHasAll($with);

return $this;
}

/**
Expand All @@ -715,11 +729,11 @@ public function assertRedirectedTo($uri, $with = [])
* @param string $name
* @param array $parameters
* @param array $with
* @return void
* @return $this
*/
public function assertRedirectedToRoute($name, $parameters = [], $with = [])
{
$this->assertRedirectedTo($this->app['url']->route($name, $parameters), $with);
return $this->assertRedirectedTo($this->app['url']->route($name, $parameters), $with);
}

/**
Expand All @@ -728,11 +742,11 @@ public function assertRedirectedToRoute($name, $parameters = [], $with = [])
* @param string $name
* @param array $parameters
* @param array $with
* @return void
* @return $this
*/
public function assertRedirectedToAction($name, $parameters = [], $with = [])
{
$this->assertRedirectedTo($this->app['url']->action($name, $parameters), $with);
return $this->assertRedirectedTo($this->app['url']->action($name, $parameters), $with);
}

/**
Expand Down