/** * @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()); }
/** * @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']); }
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')); }); }
/** * Returns the current Crawler instance. * * @return Crawler|null A Crawler instance * * @api */ public function getCrawler() { return $this->subject->getCrawler(); }