/
FlysystemLoaderTest.php
74 lines (61 loc) · 1.99 KB
/
FlysystemLoaderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Liip\ImagineBundle\Tests\Binary\Loader;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Liip\ImagineBundle\Binary\Loader\FlysystemLoader;
use Liip\ImagineBundle\Binary\Loader\LoaderInterface;
use Liip\ImagineBundle\Tests\AbstractTest;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
/**
* @requires PHP 5.4
*
* @covers \Liip\ImagineBundle\Binary\Loader\FlysystemLoader
*/
class FlysystemLoaderTest extends AbstractTest
{
private $flyFilesystem;
public function setUp()
{
parent::setUp();
if (!class_exists(Filesystem::class)) {
$this->markTestSkipped('Requires the league/flysystem package.');
}
$this->flyFilesystem = new Filesystem(new Local($this->fixturesPath));
}
/**
* @return FlysystemLoader
*/
public function getFlysystemLoader()
{
return new FlysystemLoader(ExtensionGuesser::getInstance(), $this->flyFilesystem);
}
public function testShouldImplementLoaderInterface()
{
$this->assertInstanceOf(LoaderInterface::class, $this->getFlysystemLoader());
}
public function testReturnImageContentOnFind()
{
$loader = $this->getFlysystemLoader();
$this->assertSame(
file_get_contents($this->fixturesPath.'/assets/cats.jpeg'),
$loader->find('assets/cats.jpeg')->getContent()
);
}
/**
* @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException
* @expectedExceptionMessageRegExp {Source image .+ not found}
*/
public function testThrowsIfInvalidPathGivenOnFind()
{
$loader = $this->getFlysystemLoader();
$loader->find('invalid.jpeg');
}
}