alleyinteractive / alleyinteractive/mantle-framework
HTML: improve assertions while chaining
- Langage dominant
- PHP
- Étoiles
- 28
- Forks
- 7
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 2
Description
### Description
As a new user of the `\Mantle\Support\HTML` class helper methods, I noticed something that can be prone to induce a user to make a mistake.
I wonder if it is important to help users, either with documentation or maybe with errors so that it doesn't happen or so that the user is aware of them.
### Use Case
For example, take this html:
```html
'
```
A user would assume that the `has_class` method is checking the `div` with the id, unaware it is actually checking the whole `string`.
```php
$response->html()
->filter( 'div' )
->eq( 1 )
->assertElementExistsById( 'random-element' )
->has_class( 'unrelated-class-not-in-the-random-element' )
```
So the fact that the HTML class has multiple helpers, including methods from `SymfonyCrawler`, makes it prone to mistakes, particularly while writing unit tests where chaining them is so easy.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.