在测试

时间:2015-07-15 12:49:55

标签: symfony

在控制器方法中我有类似的东西:

 public function showAllCustomersAction(Request $request) {
        return $this->render('cus/showAllCustomers.html.twig', $myarray);
 }

并且在视图中我可以通过cource访问数组$ myarray。

我的任务是:如何测试访问此数组。我不解析HTML。我只想要数组。

class CustomerTest extends WebTestCase {

    public function testAllCustomers() {
          $client = static::createClient();
          $crawler = $client->request('GET', '/cus/showAllCustomers');

          // here somehow access the array $myarray
    }

}

谢谢你的建议:)

1 个答案:

答案 0 :(得分:1)

你不能,Crawler将返回一个Symfony Response对象,它不知道控制器传递的数据以返回此响应。

您当然可以使用DomCrawler组件来搜索数组显示的内容(我猜您在视图中使用它)。

的Mickaël

相关问题