From 5155eecacc8d9b6d6b5c7849a8bbad00fa8b3690 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Mon, 12 May 2014 13:56:31 +0200 Subject: [PATCH] added static image manager --- src/Intervention/Image/ImageManagerStatic.php | 28 +++++++++++++++ tests/ImageManagerStaticTest.php | 35 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/Intervention/Image/ImageManagerStatic.php create mode 100644 tests/ImageManagerStaticTest.php diff --git a/src/Intervention/Image/ImageManagerStatic.php b/src/Intervention/Image/ImageManagerStatic.php new file mode 100644 index 00000000..d4b85e7a --- /dev/null +++ b/src/Intervention/Image/ImageManagerStatic.php @@ -0,0 +1,28 @@ +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); + } +} diff --git a/tests/ImageManagerStaticTest.php b/tests/ImageManagerStaticTest.php new file mode 100644 index 00000000..2153fa5f --- /dev/null +++ b/tests/ImageManagerStaticTest.php @@ -0,0 +1,35 @@ +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); + } +}