mirror of
https://github.com/Intervention/image.git
synced 2025-01-17 20:28:21 +01:00
added static image manager
This commit is contained in:
parent
a0b8468209
commit
5155eecacc
28
src/Intervention/Image/ImageManagerStatic.php
Normal file
28
src/Intervention/Image/ImageManagerStatic.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
class ImageManagerStatic
|
||||
{
|
||||
public $manager;
|
||||
|
||||
public function __construct(ImageManager $manager = null)
|
||||
{
|
||||
$this->manager = $manager ? $manager : new ImageManager;
|
||||
}
|
||||
|
||||
public static function newInstance()
|
||||
{
|
||||
return new self;
|
||||
}
|
||||
|
||||
public static function make($data)
|
||||
{
|
||||
return self::newInstance()->manager->make($data);
|
||||
}
|
||||
|
||||
public static function canvas($width, $height, $background = null)
|
||||
{
|
||||
return self::newInstance()->manager->canvas($width, $height, $background);
|
||||
}
|
||||
}
|
35
tests/ImageManagerStaticTest.php
Normal file
35
tests/ImageManagerStaticTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Intervention\Image\ImageManagerStatic;
|
||||
|
||||
class ImageManagerStaticTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function tearDown()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function testNewInstance()
|
||||
{
|
||||
$manager = Mockery::mock('Intervention\Image\ImageManager');
|
||||
$managerStatic = new ImageManagerStatic($manager);
|
||||
$m = $managerStatic->newInstance();
|
||||
$this->assertInstanceOf('Intervention\Image\ImageManagerStatic', $m);
|
||||
}
|
||||
|
||||
public function testMake()
|
||||
{
|
||||
$manager = Mockery::mock('Intervention\Image\ImageManager');
|
||||
$managerStatic = new ImageManagerStatic($manager);
|
||||
$img = $managerStatic->make('tests/images/tile.png');
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
}
|
||||
|
||||
public function testCanvas()
|
||||
{
|
||||
$manager = Mockery::mock('Intervention\Image\ImageManager');
|
||||
$managerStatic = new ImageManagerStatic($manager);
|
||||
$img = $managerStatic->canvas(100, 100);
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user