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
ErrorException :sprintf(): Too few arguments
.../vendor/nunomaduro/laravel-mojito/src/ViewAssertion.php:168
.../vendor/nunomaduro/laravel-mojito/src/ViewAssertion.php:99
I encountered this error when doing a contains where the expected text has a percentage (%) symbol and does not exist in the html provided. See below test that replicates this issue and currently fails but will pass when the issue has been fixed.
publicfunctiontestPercentageEscaped()
{
try {
(newViewAssertion('<div>This is a test</div>'))
->contains('This text has a percentage 43% symbol');
$this->assertTrue(false, 'Expected assertion error was not thrown.');
} catch (AssertionFailedError$e) {
$this->assertSame(
"Failed asserting that the text `This text has a percentage 43% symbol` exists within `<div>This is a test</div>`.",
$e->getMessage()
);
}
}
One solution would be to add this str_replace line to the contains method which will escape any percentage symbols. Although it might be better to stop using sprintf in ViewAssertion::assert:
publicfunctioncontains(string$text): ViewAssertion
{
$escaped = str_replace('%', '%%', $text);
self::assert(function () use ($text) {
Assert::assertStringContainsString((string) $text, $this->html);
}, "Failed asserting that the text `$escaped` exists within %s.");
return$this;
}
The text was updated successfully, but these errors were encountered:
I encountered this error when doing a
contains
where the expected text has a percentage (%) symbol and does not exist in the html provided. See below test that replicates this issue and currently fails but will pass when the issue has been fixed.One solution would be to add this
str_replace
line to thecontains
method which will escape any percentage symbols. Although it might be better to stop usingsprintf
inViewAssertion::assert
:The text was updated successfully, but these errors were encountered: