/** * @test * @medium * @group crawler * @group crawler-crawl */ public function 正常な処理() { $this->crawler->setPlugin($this->plugin); $result = $this->crawler->crawl(); $this->assertTrue(is_array($result)); $this->assertTrue(is_array($result[0])); $this->assertArrayHasKey('title', $result[0]); $this->assertArrayHasKey('eyecatch', $result[0]); $this->assertArrayHasKey('movies', $result[0]); }
/** * クロール処理を行う * * @param array $plugins 読み込むプラグイン名の配列 * @return array **/ private function _crawl($plugins) { $crawler = new Crawler(); $p_manager = new PluginManager(); $crawl_data = array(); foreach ($plugins as $plugin_name) { $plugin = $p_manager->getPlugin($plugin_name); $crawler->setPlugin($plugin); $crawl_data = $crawler->crawl(); $this->crawl_data = array_merge($this->crawl_data, $crawl_data); } // エントリーデータを整理する $entry_manager = new EntryManager(); $this->crawl_data = $entry_manager->format($this->crawl_data); }
/** * テスト用ページをクロールする * * @return void **/ private function _crawlTestPages() { $crawler = new Crawler(); $manager = new PluginManager(); $container = new Container(new CrawlerPluginTestDataFactory()); foreach ($manager->getEnablePluginNames() as $plugin_name) { $plugin = $manager->getPlugin($plugin_name); $plugin->setTestData($container->get($plugin_name)); $crawler->setPlugin($plugin); $entry_data = $crawler->crawl(); $this->crawl_data = array_merge($this->crawl_data, $entry_data); } $entry_manager = new EntryManager(); $this->crawl_data = $entry_manager->format($this->crawl_data); }