Unit tests for HTML Output?

后端 未结 9 1207
-上瘾入骨i
-上瘾入骨i 2021-02-19 00:39

This may be a dumb question, but do you make unit tests for the HTML output of your PHP functions/scripts?

I try to keep my HTML and my PHP separate - i.e. HTML includes

9条回答
  •  长发绾君心
    2021-02-19 01:19

    One very simple way to do this is with output buffering.

    eg

    ob_start();
    function_which_produces_some_output();
    $this->assertEquals( ob_get_clean(), '

    Expected Output Here

    ');

提交回复
热议问题