コード例 #1
0
 function it_creates_a_file_if_writer_is_correct(CsvWriter $writer, JobExecution $jobExecution, JobInstance $jobInstance, Job $job, ItemStep $step, $factory, $filesystem)
 {
     $jobExecution->getJobInstance()->willReturn($jobInstance);
     $jobExecution->getId()->willReturn(12);
     $jobInstance->getJob()->willReturn($job);
     $jobInstance->getType()->willReturn('type');
     $jobInstance->getAlias()->willReturn('alias');
     $job->getSteps()->willReturn([$step]);
     $step->getWriter()->willReturn($writer);
     $writer->getWrittenFiles()->willReturn(['/tmp/tmp' => 'tmp', '/tmp/tmp2' => 'tmp2']);
     $writer->getPath()->willReturn('/tmp/tmp');
     $adapter = new LocalAdapter('/tmp');
     $fs = new Filesystem($adapter);
     $fs->write('tmp', '', true);
     $fs->write('tmp2', '', true);
     $factory->createZip(Argument::any())->willReturn($filesystem);
     $filesystem->write('tmp', '', true)->shouldBeCalled();
     $filesystem->write('tmp2', '', true)->shouldBeCalled();
     $this->archive($jobExecution);
 }
 function it_creates_a_file_if_writer_is_correct(CsvWriter $writer, JobExecution $jobExecution, JobInstance $jobInstance, Job $job, ItemStep $step, $factory, $filesystem)
 {
     $file1 = tempnam(sys_get_temp_dir(), 'spec');
     $file2 = tempnam(sys_get_temp_dir(), 'spec');
     $jobExecution->getJobInstance()->willReturn($jobInstance);
     $jobExecution->getId()->willReturn(12);
     $jobInstance->getJob()->willReturn($job);
     $jobInstance->getType()->willReturn('type');
     $jobInstance->getAlias()->willReturn('alias');
     $job->getSteps()->willReturn([$step]);
     $step->getWriter()->willReturn($writer);
     $writer->getWrittenFiles()->willReturn([$file1 => 'file1', $file2 => 'file2']);
     $writer->getPath()->willReturn(sys_get_temp_dir());
     $filesystem->has('type/alias/12/archive')->willReturn(false);
     $filesystem->createDir('type/alias/12/archive')->shouldBeCalled();
     $factory->createZip(Argument::any())->willReturn($filesystem);
     $filesystem->put('file1', '')->shouldBeCalled();
     $filesystem->put('file2', '')->shouldBeCalled();
     $this->archive($jobExecution);
     unlink($file1);
     unlink($file2);
 }