Skip to content

[5.6] Allow asserting an integer with assertSee()#23892

Merged
taylorotwell merged 1 commit intolaravel:5.6from
shadoWalker89:patch-1
Apr 17, 2018
Merged

[5.6] Allow asserting an integer with assertSee()#23892
taylorotwell merged 1 commit intolaravel:5.6from
shadoWalker89:patch-1

Conversation

@shadoWalker89
Copy link
Copy Markdown
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.

2 participants