/** * Test the product scraper */ public function testScrape() { $productScraper = new ProductScraper(); $responseJSON = $productScraper->scrape(); $this->assertJSON($responseJSON); $this->assertTrue($this->isValidJSON($responseJSON)); $responseArray = json_decode($responseJSON, true); $results = $responseArray['results']; $this->assertArrayHasKey('results', $responseArray); $this->assertArrayHasKey('total', $responseArray); $this->assertArrayHasKey('title', $results[0]); $this->assertArrayHasKey('size', $results[0]); $this->assertArrayHasKey('unit_price', $results[0]); $this->assertArrayHasKey('description', $results[0]); }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Fetching products...'); $output->writeln($this->scraper->scrape()); $output->writeln('Finished fetching the products.'); }