1
0
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:
Oliver Vogel 2014-05-12 13:56:31 +02:00
parent a0b8468209
commit 5155eecacc
2 changed files with 63 additions and 0 deletions

View 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);
}
}

View 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);
}
}