Skip to content

Commit

Permalink
add create archive method
Browse files Browse the repository at this point in the history
  • Loading branch information
jrm2k6 committed May 25, 2016
1 parent 33f3308 commit ca1acf3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/JD/Cloudder/CloudinaryWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,16 @@ public function replaceTag($tag, $publicIds = array(), $options = array())
return $this->getUploader()->replace_tag($tag, $publicIds, $options);
}

/**
* Create a zip file containing images matching options.
*
* @param array $options
* @param string $archiveName
* @param string $mode
*/
public function createArchive($options = array(), $nameArchive = null, $mode = 'create')
{
$options = array_merge($options, ['target_public_id' => $nameArchive, 'mode' => $mode]);
return $this->getUploader()->create_archive($options);
}
}
24 changes: 24 additions & 0 deletions tests/CloudinaryWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,28 @@ public function it_should_set_uploaded_result_when_uploading_video()
$result = $this->cloudinary_wrapper->getResult();
$this->assertEquals($expected_result, $result);
}

/** @test */
public function it_should_call_api_create_archive_when_generating_archive()
{
// given
$this->uploader->shouldReceive('create_archive')->once()->with(
['tag' => 'kitten', 'mode' => 'create', 'target_public_id' => null]
);

// when
$this->cloudinary_wrapper->createArchive(['tag' => 'kitten']);
}

/** @test */
public function it_should_call_api_create_archive_with_correct_archive_name()
{
// given
$this->uploader->shouldReceive('create_archive')->once()->with(
['tag' => 'kitten', 'mode' => 'create', 'target_public_id' => 'kitten_archive']
);

// when
$this->cloudinary_wrapper->createArchive(['tag' => 'kitten'], 'kitten_archive');
}
}

0 comments on commit ca1acf3

Please sign in to comment.