php - Symfony2 功能测试 - 检查表格内容

标签 php symfony functional-testing

我只用过类似 contains() 的东西在我的断言中,所以我不确定如何处理像这样复杂的事情。

假设我有一系列预期答案 - 在本例中是"is"、"is"、“否”。

所以这意味着有效,对于第一个和第二个问题,我希望看到 <span class="glyphicon glyphicon-ok"></span>第三个里面<td>对于第三个问题,我希望在第四个 <td> 中看到它.

这是我的 HTML 代码:

<table class="table table-curved">
    <tr>
        <th width="10%">Item</th>
        <th width="60%">Description</th>
        <th width="10%">YES</th>
        <th width="10%">NO</th>
        <th width="10%">NOT APPLICABLE</th>
    </tr>

    <tr>
        <td class="report-table-inner report-centre">1</td>
        <td class="report-table-inner">Check cargo is secure and undamaged.</td>
        <td class="report-centre success"><span class="glyphicon glyphicon-ok"></span></td>
        <td class="report-centre"></td>
        <td class="report-centre"></td>
    </tr>
    <tr>
        <td class="report-table-inner report-centre">2</td>
        <td class="report-table-inner">Is all cargo accounted for.</td>
        <td class="report-centre success"><span class="glyphicon glyphicon-ok"></span></td>
        <td class="report-centre"></td>
        <td class="report-centre"></td>
    </tr>
    <tr>
        <td class="report-table-inner report-centre">3</td>
        <td class="report-table-inner">Is all cargo checked by customs.</td>
        <td class="report-centre"></td>
        <td class="report-centre danger"><span class="glyphicon glyphicon-ok"></span></td>
        <td class="report-centre"></td>
    </tr>
    ...

我应该如何为此编写测试?遍历 <tr> 很难吗?是程序化的吗?

谢谢

最佳答案

我认为您应该查看有关测试和 DomCrawler 组件的文档页面:

有很简单的方法可以过滤html或xml内容。

关于php - Symfony2 功能测试 - 检查表格内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31868369/

相关文章:

symfony - 转义模板的内容

symfony - 使用capifony在symfony2部署上,方法Assetic\AssetWriter::getCombinations()不存在异常

.net MVC 功能测试

grails - WithNewWindow() 在 Geb 中返回 MultipleCompilationErrorsException

php - 没有数据库的 Laravel 模型

php - Wordpress - 为前 4 个帖子设置自定义 CSS 类,并包装前 2 个帖子

php - JMSSerializer 分组属性的交集

functional-testing - 如何在 Nightwatch 中运行单个测试

php - 如何格式化 unix 时间戳数组中的日期列表?

php - 通过 PHP 访问文件属性