【问题标题】:PHPUnit: how to test HTML structure outputPHPUnit:如何测试 HTML 结构输出
【发布时间】:2021-12-17 16:31:29
【问题描述】:

我正在尝试测试 HTML 结构渲染。

我看到了这个方法:https://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.assertions.assertTag

...但是在最后一个版本中,它已经过时了。

现在这种验证的最佳做法是什么?

最好的问候。

【问题讨论】:

  • 既然你标记了这个 Laravel,那么你可以查看 laravel.com/docs/8.x/http-tests 。你也可以使用 browser-kit testing library,它曾经是 Laravel 的一部分,但不是一个单独的包。
  • 我想你想使用these methods中的任何一个,你应该使用$response->assertSee()或类似的。
  • 谢谢。最后,我做了一些非常简单的事情: $dom = new \DOMDocument(); $dom->loadHTML($blocks_html); $this->assertTrue($dom->getElementById('MYID')->hasAttributes());

标签: php laravel phpunit


【解决方案1】:
猜你喜欢
  • 2012-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-04
  • 2017-08-20
相关资源
最近更新 更多