FakerPHP / Faker

Faker is a PHP library that generates fake data for you
https://fakerphp.github.io
Other
3.58k stars 345 forks source link

Feature request name without special character #650

Closed agus24 closed 1 year ago

agus24 commented 1 year ago

Summary

i did some test using laravel with faker. but sometimes it generates name like Ambrose O'Conner then i assert html has that name but the html generated like this Ambrose O'Conner is there a way to remove special character in name? or other way to resolve this issue?

Versions

Version
PHP 8.1.18
fakerphp/faker 1.21.0

Self-enclosed code snippet for reproduction

class OutletFactory extends Factory 
{
    public function definition()
    {
        return [
            'name' => fake()->name()
        ];
    }
}
$outlet = Outlet::factory()->create();
Livewire::test(EventPage::class)->assertSeeHtml($outlet->name) // this fails

Expected output

Ambrose O'Conner found on html

Actual output

Ambrose O'Conner does not found on html. but `Ambrose O'Conner` found
bram-pkg commented 1 year ago

You should escape the HTML when using assertSeeHtml, that would fix this. Unfortunately names like these are valid and your tests should probably keep them in mind ;)

bram-pkg commented 1 year ago
Screenshot 2023-05-22 at 09 27 54

From what I see in the Livewire code, the assertSee has an option to automatically escape text :)