Skip to content

Improve DOM tree navigation #15

@jubianchi

Description

@jubianchi

Since cfef991, AtoumBundle provides a nice fluent API to write tests. This API has some requirements that may be improved : actually, we need to add several calls to ->end() to get the right scope in assertions. This can be improved and I would like to propose a better syntax : https://gist.github.com/4336789#file-controllertest-php-L54-L83 (Two test method are implemented, one with actual API and one with the proposed one)

In the previous Gist, you'll see that quite every call to ->end() have been removed. This makes the test shorter and perhaps easier to write :

  • It provides us a shorter way to put simple assertions on child nodes of an element
  • Calls to ->end() are useless : the asserters would be able to manage scope by themselves.

To me, this snippet is cleaner but this modification has a cost : it introduces a BC break with current tests has some assertions will not work the same way :

  • To do complex assertions on child nodes, we'll have to use a crawler
  • end will be removed and also replaced by parentwhich seems to be more expressive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions