public function testFileParsing()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
     $xml .= '<packages package_ETA="~" package_linksinprogress="0" package_linkstotal="2" package_loaded="0 B" package_name="2.Broke.Girls.S01E09.de.en.XViD-4SJ" package_percent="0,00" package_size="0 B" package_speed="0 B" package_todo="0 B">';
     $xml .= '<file file_downloaded="0 B" file_hoster="uploaded.to" file_name="d6cno5nf" file_package="2.Broke.Girls.S01E09.de.en.XViD-4SJ" file_percent="0,00" file_size="0 B" file_speed="0" file_status="File not found"/>';
     $xml .= '<file file_downloaded="0 B" file_hoster="uploaded.to" file_name="kla6pdp2" file_package="2.Broke.Girls.S01E09.de.en.XViD-4SJ" file_percent="0,00" file_size="0 B" file_speed="0" file_status="File not found"/>';
     $xml .= '</packages>';
     $res = xml::query(xml::doc($xml), 'packages');
     $package = JDownloaderPackage::parse(current($res));
     $this->assertChainable($package);
     $this->assertCount(2, $files = $package->getFiles());
     $this->assertContainsOnlyInstancesOf('SerienLoader\\JDownloaderFile', $files);
     list($file1, $file2) = $files;
     $this->assertEquals('d6cno5nf', $file1->getName());
     $this->assertTrue($file1->isNotFound());
     $this->assertEquals('kla6pdp2', $file2->getName());
     $this->assertTrue($file2->isNotFound());
     $this->assertTrue($package->hasMissingFiles());
 }
 /**
  * @return xml::doc()
  */
 protected function getCachedDoc($name, $url)
 {
     if (!isset($this->cache->{$name})) {
         $xmls = $this->send($url);
         if (empty($xmls)) {
             throw new JDownloaderException('Kein Output von: ' . $this->request->getURL());
         }
         $this->cache->{$name} = xml::doc($xmls);
     }
     return $this->cache->{$name};
 }
 public function getBoardIds()
 {
     $this->logger->writeln('Lade BoardIds');
     $cache = new \Psc\Data\FileCache();
     $ser = $cache->load('boardIds', $loaded);
     if (!$loaded) {
         $this->logger->writeln('BoardIds nicht im Cache, mache URL Request');
         $this->req = new URLRequest('http://www.subcentral.de/index.php?s=' . $this->sessionId, $this->cookieJar);
         $html = $this->req->init()->process();
         $boardIds = array();
         $dom = xml::doc($html);
         foreach (xml::query($dom, '#search select[name=boardID] option') as $option) {
             $title = $option->nodeValue;
             $boardIds[mb_strtolower($title)] = (int) $option->getAttribute('value');
         }
         $this->logger->writeln(count($boardIds) . ' BoardIds gefunden. Speichere im Cache');
         $ser = serialize($boardIds);
         $cache->store('boardIds', $ser);
     } else {
         $boardIds = unserialize($ser);
         $this->logger->writeln(count($boardIds) . ' BoardIds im Cache gefunden');
     }
     return $boardIds;
 }
Exemple #4
0
 public function testUTF8DocumentSnipped()
 {
     $dom = Helper::docPart('<span>Game Templates für Testprodukt</span>');
     $q = Helper::query($dom, 'span');
     $this->assertEquals('Game Templates für Testprodukt', $q[0]->nodeValue);
 }