Exemple #1
0
 public function save($filename)
 {
     $zip = new ZipArchiveAdapter($filename);
     foreach ($this->tmpFiles as $path => $tmpFile) {
         $zip->writeStream($path, $tmpFile, new Config());
     }
 }
Exemple #2
0
 /**
  * @param $file
  * @param ProgressBar $progress
  */
 private function processGtfs($file, ProgressBar $progress)
 {
     $mergers = ['agencyMerger' => 'agency.txt', 'routesMerger' => 'routes.txt', 'stopsMerger' => 'stops.txt', 'calendarMerger' => 'calendar.txt', 'calendarDatesMerger' => 'calendar_dates.txt', 'tripsMerger' => 'trips.txt', 'stopTimesMerger' => 'stop_times.txt', 'externalIDsMerger' => 'stop_external_ids.txt'];
     if (!is_readable($file)) {
         throw new InvalidArgumentException('Cannot read file/s in path "' . $file . '". Aborting.');
     }
     $zip = new ZipArchiveAdapter($file);
     foreach ($mergers as $merger => $subfile) {
         $progress->setMessage($subfile, 'gtfs_part');
         $progress->display();
         $resource = $zip->readStream($subfile);
         if ($resource === false || !is_resource($resource['stream'])) {
             throw new InvalidArgumentException('Cannot find or read GTFS part "' . $subfile . '" in file "' . $file . '". Aborting.');
         }
         $items = $this->{$merger}->merge($resource['stream']);
         $this->gtfsWriter->append($subfile, $items);
     }
 }
Exemple #3
0
 public function testCopyFailed()
 {
     if (defined('HHVM_VERSION')) {
         $this->markTestSkipped('This test results in a fatal error on HHVM');
     }
     $mock = Mockery::mock('ZipArchive');
     $mock->shouldReceive('open')->andReturn(true);
     $mock->shouldReceive('close')->andReturn(true);
     $mock->shouldReceive('getStream')->andReturn(false);
     $zip = new Zip('location', $mock);
     $this->assertFalse($zip->copy('old', 'new'));
 }