예제 #1
0
 /**
  * @param array $data
  * @return string
  */
 public function createArchive(array $data)
 {
     foreach ($data as $key => $values) {
         $name = $this->parseDataKeyName($values, $key);
         $data[$key] = array_replace_recursive($this->extensions[$name]['data'], $data[$key]);
     }
     $this->archive = new Extension\Archive();
     $this->archive->queueToFile('puphpet/config.yaml', $this->yamlDump($data));
     $this->archive->write();
     return $this->archive->zip();
 }
예제 #2
0
 /**
  * @param array $data
  * @return string
  */
 public function createArchive(array $data)
 {
     $data = $this->createConfig($data);
     $this->archive = new Extension\Archive();
     $this->archive->queueToFile('puphpet/config.yaml', $this->yamlDump($data));
     $this->archive->write();
     return $this->archive->zip();
 }
예제 #3
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(Archive::ZIP_COMMAND, $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);
 }