コード例 #1
0
 public function testIncorrect()
 {
     $dom = SimpleHtmlDom::fromUrl(__DIR__ . '/incorrect.html');
     $a = new ReplacementsParser();
     $result = $a->getReplacements($dom);
     $this->assertEquals(null, $result);
     $this->assertGreaterThan(0, count($a->getErrors()));
 }
コード例 #2
0
 private function updateReplacements($dom)
 {
     $model = new ReplacementsRepository();
     $parser = new ReplacementsParser();
     $remoteList = $parser->getReplacements($dom);
     $this->logErrors('ReplacementsParser', $parser->getErrors());
     if ($remoteList !== null) {
         foreach ($remoteList as $remote) {
             $local = $model->getByClassAndDate($remote->class, $remote->date);
             if ($local === null || $remote->value !== $local->value) {
                 $model->setValue($remote->class, $remote->date, $remote->value);
                 echo "updated replacements/{$remote->date}/{$remote->class}\n";
             }
         }
     }
 }