2012-03-28 1 views
1

Iは、ワードプレスのテーマをテストするために(symfonyの機能テストコンポーネントのスタンドアロンパッケージである)Goutteを使用している:グット/ symfonyのCssSelector成分と属性によってノードを選択

public function testDocumentHasBasicNodes(){ 
    $this->assertEquals(1, $this->crawler->filter('title')->count(), 
      'document shall have a TITLE node'); 

    $this->assertEquals(1, $this->crawler->filter('meta')->count(), 
      'document shall have a meta[charset="utf-8"] node'); 
} 

最初のテストがなく通過:

indexTest::testDocumentHasBasicNodes 
document shall have a meta[charset="utf-8"] node 
Failed asserting that 0 matches expected 1. 

だから私の質問総括する:私はグット/ symfonyのCSSセレクタコンポーネントと属性でノードを取得するにはどうすればよい
を?

答えて

2

このような属性でフィルタリングすることができます。

$this->assertEquals(1, $this->crawler->filter('meta[charset="utf-8"]')->count(), 
    'document shall have a meta[charset="utf-8"] node'); 
関連する問題