/** * エントリデータの初期化 * * @return void **/ private function _initEntryData() { $entry_data = file_get_contents(ROOT . '/data/fixtures/entry_data.json'); $entry_data = json_decode($entry_data); $manager = new EntryManager(); $this->entry_data = $manager->format($entry_data); }
/** * @test * @group builder * @group builder-build-demo */ public function デモページを構築する() { $demo_path = ROOT . '/public_html/demo.html'; if (file_exists($demo_path)) { unlink($demo_path); } $data = file_get_contents(ROOT . '/data/fixtures/entry_data.json'); $data = $this->manager->format(json_decode($data)); $this->builder->setEntryData($data); $this->builder->buildContents('demo'); $this->assertTrue(file_exists($demo_path)); }
/** * テスト用ページをクロールする * * @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); }
/** * @test * @group entry-format * @group entry */ public function エントリデータを正規化する() { $result = $this->manager->format($this->entry_data); $this->assertTrue(is_array($result)); $this->assertEquals(20, count($result)); }
/** * クロール処理を行う * * @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); }