Beispiel #1
0
 public function testDownloadRevision()
 {
     $this->assertTrue(downloader()->isDownloaded('/laws/card/254к/96-вр'));
     $this->assertTrue(downloader()->isDownloaded('/laws/show/254к/96-вр/ed20140515/page'));
     $this->assertTrue(downloader()->isDownloaded('/laws/show/254к/96-вр/ed20140515/page2'));
     $this->assertTrue(downloader()->isDownloaded('/laws/show/254к/96-вр/ed20140515/page3'));
     $this->assertTrue(downloader()->isDownloaded('/laws/show/254к/96-вр/ed20140515/page4'));
     Law::firstOrCreate(['id' => '254к/96-вр']);
     $law = $this->obj->downloadCard('254к/96-вр');
     $revision = $this->obj->downloadRevision('254к/96-вр', '2014-05-15');
     $text = file_get_contents(base_path() . '/tests/fixtures/partials/254к/96-вр/text.txt');
     $this->assertEquals($revision->text, $text);
     $this->assertEquals($law->active_revision()->first()->text, $text);
     $this->assertEquals($revision->status, Revision::UP_TO_DATE);
     $this->assertTrue(downloader()->isDownloaded('/laws/card/2952-17'));
     $this->assertTrue(downloader()->isDownloaded('/laws/show/2952-17/ed20110201/page'));
     Law::firstOrCreate(['id' => '2952-17']);
     $law = $this->obj->downloadCard('2952-17');
     $revision = $this->obj->downloadRevision('2952-17', '2011-02-01');
     $text = file_get_contents(base_path() . '/tests/fixtures/partials/2952-17/text.txt');
     $this->assertEquals($revision->text, $text);
     $this->assertEquals($law->active_revision()->first()->text, $text);
     $this->assertEquals($revision->status, Revision::UP_TO_DATE);
 }
Beispiel #2
0
 /**
  * Crawl the law list page. Take all law urls from it and add them to database.
  *
  * @param string $law_list_url Law list URL.
  * @param string $date
  * @param int $page_num
  * @param bool $re_download
  */
 public function discoverDailyLawListPage($law_list_url, $page_num, $date, $re_download = false)
 {
     $data = downloadList($law_list_url, ['re_download' => $page_num > 1 ? $re_download || $this->re_download : false, 'save' => $date != date('Y-m-d')]);
     foreach ($data['laws'] as $id => $law) {
         Law::firstOrCreate(['id' => $id])->update(['date' => $law['date']]);
         $this->jobsManager->add('command.lawgrabber.download', 'downloadCard', ['id' => $id], 'download', 1);
     }
 }