You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$response->assertSeeInOrder does not actually assert anything, but instead calls PHPUnit::fail() if the conditions are not met. This causes tests which only have that assertion to be reported as "risky".
public function assertSeeInOrder(array $values)
{
$position = 0;
foreach ($values as $value) {
$valuePosition = mb_strpos($this->getContent(), $value, $position);
if ($valuePosition === false || $valuePosition < $position) {
PHPUnit::fail(
'Failed asserting that \''.$this->getContent().
'\' contains "'.$value.'" in specified order.'
);
}
$position = $valuePosition + mb_strlen($value);
}
return $this;
}
// A test which only uses this assertion will be reported as "risky" by PHPUnit because of not running any assertions.
public function canViewAlbumTitleFromBandView()
{
$band = factory(Band::class)->create();
$album = factory(Album::class)->create([
'band_id' => $band->id
]);
// visit the page
$response = $this->get("/bands/$band->id");
// assert we can see the data
$response->assertSeeInOrder(['Albums:', $album->name]);
}
Yes, in my case I could just write different assertions that would assert reliably, but isn't this bad practice to be including built-in custom assertions that don't actually assert anything? Shouldn't we be able to write a custom assertion class instead?
The text was updated successfully, but these errors were encountered:
$response->assertSeeInOrder does not actually assert anything, but instead calls PHPUnit::fail() if the conditions are not met. This causes tests which only have that assertion to be reported as "risky".
Yes, in my case I could just write different assertions that would assert reliably, but isn't this bad practice to be including built-in custom assertions that don't actually assert anything? Shouldn't we be able to write a custom assertion class instead?
The text was updated successfully, but these errors were encountered: