alleyinteractive / alleyinteractive/mantle-framework
HTML: improve assertions while chaining
- Linguagem predominante
- PHP
- Estrelas
- 28
- Forks
- 7
- Merge médio
- 2d 4h
- PRs com merge (30d)
- 2
Descrição
### 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.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.