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.8] allow view assertions to see all data #28893

Merged
merged 1 commit into from
Jun 20, 2019
Merged

[5.8] allow view assertions to see all data #28893

merged 1 commit into from
Jun 20, 2019

Conversation

browner12
Copy link
Contributor

Problem

The assertViewHas() assertion in the HTTP testing will currently only look at data bound directly to the view, and not data that has been 'shared' with the view. This makes it a little clunkier to check for shared data.

$response = $this->get('/');

$response->assertOk();

$response->assertViewHas('someKey');  // fails with shared data

$this->assertArrayHasKey('someKey', $response->original->gatherData());

Solution

The view assertions now use the gatherData() method, instead of the getData() method, which provides us both the directly bound data, and the globally shared data.

Concerns

  • Is this BC kosher? Not sure if this would be considered a 'bug fix' or a 'change of behavior', and I guess depends on the intent of the assertion.
  • Or does this belong in a separate assertion? assertViewHasShared() or something similar?

currently, the view assertions can only see data passed directly to the view. this change allows the assertions to also see the data that has been 'shared'
@taylorotwell taylorotwell merged commit f1bb3fe into laravel:5.8 Jun 20, 2019
@browner12 browner12 deleted the assert-view branch June 20, 2019 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants