Exemplo n.º 1
0
 public function testZipReturnsAZipFileLocation()
 {
     $file1 = ['name' => 'foobar', 'content' => 'file1 content'];
     $file2 = ['name' => 'fizzbuzz', 'content' => 'file2 content'];
     $file3 = ['name' => 'bizzbang', 'content' => 'file3 content'];
     $this->archive->expects($this->exactly(3))->method('file_put_contents');
     $this->archive->expects($this->once())->method('exec');
     $targetDir = '/tmp/foobar';
     $baseDir = 'foobar';
     $this->setAttribute($this->archive, 'targetDir', $targetDir);
     $exec = sprintf('cd "%s" && cd .. && zip -r "%s" "%s" -x */.git[!a]\\*', $targetDir, $targetDir . '.zip', $baseDir);
     $this->archive->expects($this->once())->method('exec')->with($exec);
     $this->archive->queueToFile($file1['name'], $file1['content']);
     $this->archive->queueToFile($file2['name'], $file2['content']);
     $this->archive->queueToFile($file3['name'], $file3['content']);
     $this->archive->write();
     $returned = $this->archive->zip();
     $this->assertEquals($targetDir . '.zip', $returned);
 }