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.6] Allow asserting an integer with assertSee() #23892

Merged
merged 1 commit into from
Apr 17, 2018

Conversation

shadoWalker89
Copy link
Contributor

@shadoWalker89 shadoWalker89 commented Apr 16, 2018

When trying to assert a number (example: id, downloads count ...) is seen or not seen on the page with any of these methods

assertSee() assertDontSee() assertSeeText() assertDontSeeText()

a phpunit exception will be raised, because the haystack (response content) is a string and the needle (what i'm asserting to be seen) is an integer (not a string)

Check the phpunit source code for that
https://github.com/sebastianbergmann/phpunit/blob/c1b35f210334bf1695af4fe6a16c3a72ebbe5e3d/src/Framework/Assert.php#L196

For example this assertion

$response = $this->get("some url");

$response->assertSee($paper->id);

Will raise this exception

Argument #1 (No Value) of PHPUnit\Framework\Assert::assertContains() must be a string
 F:\projects\quick-conference\src\quick-conference\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestResponse.php:284

This PR tries to solve that by casting the $value to a string

@GrahamCampbell GrahamCampbell changed the title [5.6] allow asserting an integer with assertSee() [5.6] Allow asserting an integer with assertSee() Apr 16, 2018
@taylorotwell taylorotwell merged commit 00e92dd into laravel:5.6 Apr 17, 2018
@shadoWalker89 shadoWalker89 deleted the patch-1 branch April 17, 2018 13:37
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.

None yet

2 participants