thc1967's avatar

Testing and Apostrophe Characters in Fields

I get tests that fail every so often because of the way the system, not sure what part, handles apostrophes.

When I use $faker->name, I often get something with an apostrophe, and it's most often O'Connell.

When this happens, my tests that do an ->assertSee($model->name) fail because what actually goes into the HTML is O'Connell.

What's the best way to avoid these phantom failures?

Thanks!

0 likes
3 replies
Cronix's avatar
Cronix
Best Answer
Level 67

It's because blade runs variables through html entities, so apostrophes get converted to their html entity '

In your tests, you just need to run your variables through the e() function, which is what blade is doing.

->assertSee(e($model->name))

2 likes
Jmichel's avatar

Thank you so much -- I get that bug every once in while an the whole page dumps.

Please or to participate in this conversation.