本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::getCrawler方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getCrawler方法的具体用法?PHP Client::getCrawler怎么用?PHP Client::getCrawler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Client
的用法示例。
在下文中一共展示了Client::getCrawler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLogout
/**
* @depends testLogin
*/
public function testLogout(Client $client)
{
$this->setSecurityContextUser();
$crawler = $client->getCrawler();
$crawler = $client->request('GET', self::URL_DECONNECTION);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertEquals(self::URL_DECONNECTION, $client->getRequest()->getRequestUri());
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertEquals('/en/', $client->getRequest()->getRequestUri());
}
示例2: submitThemeUploadForm
/**
* @return void
*/
private function submitThemeUploadForm()
{
$form = $this->client->getCrawler()->selectButton('Install')->form();
$_FILES['file'] = ['name' => "{$this->fileName}.zip", 'type' => 'application/zip', 'tmp_name' => "{$this->fileName}.zip", 'error' => 0, 'size' => 0];
$this->submitEditForm($this->client, $form, ['form' => 'upload']);
}
示例3: assertSEOCompatible
protected function assertSEOCompatible(Client $client, $type = 'article')
{
$crawler = $client->getCrawler();
$url = $client->getRequest()->getUri();
$title = $crawler->filter('title')->text();
// title
$this->assertNotEmpty($title, 'The title is empty.');
// meta
$this->assertCount(1, $crawler->filter('meta[charset=UTF-8]'));
$this->assertCount(1, $crawler->filter('meta[property="og:title"][content="' . $title . '"]'));
$this->assertCount(1, $crawler->filter('meta[property="og:type"][content="' . $type . '"]'));
$this->assertCount(1, $crawler->filter('meta[property="og:url"][content="' . $url . '"]'));
// img
// $this->assertCount(0, $crawler->filter('img[alt=""]'));
$crawler->filter('img:not([alt])')->each(function ($node, $i) {
$this->assertTrue(false, 'An image with no alt attribute has been found src=' . $node->attr('src'));
});
}
示例4: getCrawler
/**
* Returns the current Crawler instance.
*
* @return Crawler|null A Crawler instance
*
* @api
*/
public function getCrawler()
{
return $this->subject->getCrawler();
}