lundi 25 novembre 2019

Should I mock crawler

I have the following code. I want to test it. I create stub for httpClient. For crawler I have two choices. I can create stub for it or I can create a simple html file and test real crawler object with this file. What should I do in this case?

$wallpapersURL = self::URL . '/category/wallpapers';
$response = $this->httpClient->get($wallpapersURL);
$body = $response->getBody()->getContents();

$this->crawler->clear();
$this->crawler->addHtmlContent($body);
$node = $this->crawler->filterXPath("//*[@class='tilted-featured-article__title']/a[starts-with(@href, '$this->date')]/@href");

if ($node->count()) {
    return $node->text();
}

...

Aucun commentaire:

Enregistrer un commentaire