public function testTheInformationOfAnAdAreCorrectlyExtracted()
 {
     $node = (new Crawler($this->adContent))->filter('.list-lbc > a')->first();
     $search = new SearchResultAdCrawler($node);
     $expected = (object) ['id' => '753398357', 'title' => 'Volkswagen TOUAREG RLINE 245ch V6', 'price' => 49990, 'url' => 'http://www.leboncoin.fr/voitures/753398357.htm?ca=4_s', 'created_at' => SearchResultDateTimeParser::toDt('5 jan', '19:58'), 'thumb' => 'http://193.164.197.60/thumbs/0a3/0a3d6148ed12dfa159bd124810f3bfd612d23e5f.jpg', 'nb_image' => 3, 'placement' => 'Colleville-Montgomery / Calvados', 'type' => 'pro'];
     $this->assertEquals($expected, $search->getAll());
 }
 public function testGetTheDetailedAdInTheSearchResult()
 {
     $response = $this->getResponse(dirname(__DIR__) . '/content/search_result.html');
     $mock = new Mock();
     $mock->addResponse($response);
     $getFrom = new GetFrom();
     $getFrom->getHttpClient()->getEmitter()->attach($mock);
     $url = 'http://www.leboncoin.fr/voitures/offres/basse_normandie/?f=a&th=1&ms=30000&me=100000&fu=2&gb=2';
     $data = $getFrom->search($url, true);
     $expected = (object) ['id' => '746080950', 'title' => 'Volkswagen touareg 3.0 v6 tdi 240 carat edition', 'price' => 24200, 'url' => 'http://www.leboncoin.fr/voitures/746080950.htm?ca=4_s', 'created_at' => SearchResultDateTimeParser::toDt("Aujourd'hui", "11:01"), 'thumb' => 'http://193.164.196.50/thumbs/aa5/aa55af1f945f02f8452fcfb2061d93b2d380eefd.jpg', 'nb_image' => 7, 'placement' => 'Caen / Calvados', 'type' => 'part'];
     $this->assertEquals($expected, array_pop($data['ads']));
 }
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Unable to parse the month
  */
 public function testItThrowAnExceptionWhenTheMonthFormatIsWrong()
 {
     SearchResultDateTimeParser::toDt("29 whatever", "7:22");
 }
 /**
  * Return the data and time the ad was created
  *
  * @return \Carbon\Carbon
  */
 public function getCreatedAt()
 {
     list($date, $time) = $this->node->filter('.date > div')->each(function (Crawler $node) {
         return $node->text();
     });
     return SearchResultDateTimeParser::toDt($date, $time);
 }