Search Results

Search found 1 results on 1 pages for 'asbja'.

Page 1/1 | 1 

  • Robust unit-testing of HTML in PHP

    - by asbja
    I'm adding unit-tests to an older PHP codebase at work. I will be testing and then rewriting a lot of HTML generation code and currently I'm just testing if the generated strings are identical to the expected string, like so: (using PHPUnit) public function testConntype_select() { $this->assertEquals( '<select><option value="blabla">Some text</option></select>', conntype_select(1); // A value from the test dataset. ); } This way has the downside that attribute ordering, whitespace and a lot of other irrelevant details are tested as well. I'm wondering if there are any better ways to do this. For example if there are any good and easy ways to compare the generated DOM trees. I found very similar questions for ruby, but couldn't find anything for PHP.

    Read the article

1