Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Dec 28, 2016
1 parent fa168ba commit be6a366
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
phpunit.xml
Tests/autoload.php
composer.phar
composer.lock
vendor/*
!vendor/vendors.php
vendor/
28 changes: 28 additions & 0 deletions Tests/Storage/FileSystemStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,34 @@ public function testResolveUri($uploadDir, $uri)
$this->assertEquals($uri, $path);
}

public function testResolveStream()
{
$this->mapping
->expects($this->once())
->method('getUploadDir')
->will($this->returnValue(''));

$this->mapping
->expects($this->once())
->method('getUploadDestination')
->will($this->returnValue($this->root->url().'/uploads'));

$this->mapping
->expects($this->once())
->method('getFileName')
->will($this->returnValue('test.txt'));

$this->factory
->expects($this->once())
->method('fromField')
->with($this->object, 'file_field')
->will($this->returnValue($this->mapping));

$stream = $this->storage->resolveStream($this->object, 'file_field', null);

$this->assertNotEmpty($stream);
}

public function resolveUriDataProvider()
{
return array(
Expand Down
43 changes: 43 additions & 0 deletions Tests/Storage/GaufretteStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,49 @@ public function testResolvePath($protocol, $filesystemKey, $uploadDir, $expected
$this->assertEquals($expectedPath, $path);
}

public function testResolveUri()
{
$this->mapping
->expects($this->once())
->method('getUriPrefix')
->will($this->returnValue('/uploads'));

$this->mapping
->expects($this->once())
->method('getFileName')
->will($this->returnValue('file.txt'));

$this->factory
->expects($this->once())
->method('fromField')
->with($this->object, 'file_field')
->will($this->returnValue($this->mapping));

$this->storage = new GaufretteStorage($this->factory, $this->filesystemMap, 'gaufrette');
$path = $this->storage->resolveUri($this->object, 'file_field');

$this->assertEquals('/uploads/file.txt', $path);
}

public function testResolveUriFileNull()
{
$this->mapping
->expects($this->once())
->method('getFileName')
->will($this->returnValue(''));

$this->factory
->expects($this->once())
->method('fromField')
->with($this->object, 'file_field')
->will($this->returnValue($this->mapping));

$this->storage = new GaufretteStorage($this->factory, $this->filesystemMap, 'gaufrette');
$path = $this->storage->resolveUri($this->object, 'file_field');

$this->assertNull($path);
}

public function pathProvider()
{
return array(
Expand Down

0 comments on commit be6a366

Please sign in to comment.