Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sean Fraser
committed
Jul 8, 2016
1 parent
22fd539
commit 6bfe289
Showing
9 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Frasmage\Mediable\Exceptions\MediaUrlException; | ||
use Frasmage\Mediable\UrlGenerators\LocalUrlGenerator; | ||
use Frasmage\Mediable\Media; | ||
use Illuminate\Contracts\Config\Repository as Config; | ||
use Illuminate\Routing\UrlGenerator as Url; | ||
|
||
class LocalUrlGeneratorTest extends TestCase | ||
{ | ||
public function test_it_generates_absolute_path(){ | ||
$generator = $this->setupGenerator(); | ||
$this->assertEquals(public_path('uploads/foo/bar.jpg'), $generator->getAbsolutePath()); | ||
} | ||
|
||
public function test_it_generates_url(){ | ||
$generator = $this->setupGenerator(); | ||
$this->assertEquals('http://localhost/uploads/foo/bar.jpg', $generator->getUrl()); | ||
} | ||
|
||
public function test_it_throws_exception_for_non_public_disk(){ | ||
$generator = $this->setupGenerator('tmp'); | ||
$this->expectException(MediaUrlException::class); | ||
$generator->getPublicPath(); | ||
} | ||
|
||
protected function setupGenerator($disk = 'uploads'){ | ||
$media = factory(Media::class)->make([ | ||
'disk' => $disk, | ||
'directory' => 'foo', | ||
'filename' => 'bar', | ||
'extension' => 'jpg' | ||
]); | ||
$this->seedFileForMedia($media); | ||
$generator = new LocalUrlGenerator(config(), url()); | ||
$generator->setMedia($media); | ||
return $generator; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Frasmage\Mediable\Exceptions\MediaUrlException; | ||
use Frasmage\Mediable\UrlGenerators\S3UrlGenerator; | ||
use Frasmage\Mediable\Media; | ||
use Illuminate\Contracts\Config\Repository as Config; | ||
use Illuminate\Routing\UrlGenerator as Url; | ||
|
||
class S3UrlGeneratorTest extends TestCase | ||
{ | ||
public function test_it_generates_absolute_path(){ | ||
$generator = $this->setupGenerator(); | ||
$this->assertEquals('https://s3.amazonaws.com/' . env('S3_BUCKET') . '/foo/bar.jpg', $generator->getAbsolutePath()); | ||
} | ||
|
||
public function test_it_generates_url(){ | ||
$generator = $this->setupGenerator(); | ||
$this->assertEquals('https://s3.amazonaws.com/' . env('S3_BUCKET') . '/foo/bar.jpg', $generator->getUrl()); | ||
} | ||
|
||
protected function setupGenerator(){ | ||
$media = factory(Media::class)->make([ | ||
'disk' => 's3', | ||
'directory' => 'foo', | ||
'filename' => 'bar', | ||
'extension' => 'jpg' | ||
]); | ||
$generator = new S3UrlGenerator(config(), app(Illuminate\Filesystem\FilesystemManager::class)); | ||
$generator->setMedia($media); | ||
return $generator; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters