public function expectConfirms(JDownloaderPackage $package)
 {
     $confirmPackage = $this->confirmPackage;
     $this->buildAtMethodGroupExpectation('confirmPackage', 'default')->with($this->equalTo($package->getName()))->will($this->returnCallback(function ($packageName) use($package, $confirmPackage) {
         $confirmPackage($packageName, $package);
     }));
 }
 public function testPackageWithMissingFilesWillSetEpisodeStatusWhileDownloadingToMISSING_FILES()
 {
     $list = array($episode = $this->getDownloadingEpisode());
     $this->expectClientReturnsEpisodes($list);
     $package = new JDownloaderPackage($episode->getPackageName());
     $package->setFiles(array($this->notFoundFile1));
     $this->assertTrue($this->notFoundFile1->isNotFound());
     $this->assertTrue($package->hasMissingFiles());
     $this->jd->hasPackage($package);
     $this->jd->expectHasPackageCalls($this->atLeastOnce());
     $this->runOrganizer();
     $this->assertEquals(Status::MISSING_FILES, $episode->getStatus());
 }
 public function getPackage($name)
 {
     $doc = $this->getDownloadsAllList();
     $res = xml::query($doc, 'jdownloader packages[package_name="' . $name . '"]');
     if (count($res) === 0) {
         throw new JDownloaderException('Ergebnis für ' . 'jdownloader packages[package_name="' . $name . '"] ist leer');
     }
     return JDownloaderPackage::parse(current($res));
 }
 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());
 }