Skip to content

Commit

Permalink
Adding a test for #97
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Jun 24, 2015
1 parent 6be6016 commit c72ed28
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/TestDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,36 @@ public function testDeleteCrops() {

}

// https://github.com/BKWLD/croppa/issues/97
public function testDeleteWithDashedName() {

$disk = Mockery::mock('League\Flysystem\Filesystem')
->shouldReceive('listContents')
->withAnyArgs()
->andReturn([
['path' => '7up-33cl.png', 'basename' => '7up-33cl.png'],
['path' => '7up-33cl-130x130.png', 'basename' => '7up-33cl-130x130.png'],
])
->shouldReceive('delete')
->withAnyArgs()
->times(2)
->getMock();

$storage = new Storage();
$storage->setSrcDisk($disk);
$storage->setCropsDisk($disk);
$this->assertNull($storage->deleteSrc('7up-33cl.png'));
$this->assertNull($storage->deleteCrops('7up-33cl.png'));

}

// Instantiate a helpers instance using mocked disks so the whole delete
// logic can be checked
private function mockHelpersForDeleting() {

// The path is to a sub dir
$url = new URL([
'path' => 'uploads/thumbs/(.*)$',
'path' => 'uploads/(?:thumbs/)?(.*)$',
]);

$src = Mockery::mock('League\Flysystem\Filesystem')
Expand Down

0 comments on commit c72ed28

Please sign in to comment.