/**
  * @runInSeparateProcess
  */
 public function testItAltersFile()
 {
     putenv('ALLOWED_HOSTS=placehold.it,placeholdit.imgix.net');
     putenv('APP_ENV=testing');
     $request = Mockery::mock(Request::class);
     $request->shouldReceive('get')->with('height')->andReturn(150);
     $request->shouldReceive('get')->with('width')->andReturn(300);
     $request->shouldReceive('get')->with('crop')->andReturn(false);
     $request->shouldReceive('get')->with('source')->andReturn($this->getPlaceholditImage(300, 500));
     $request->shouldReceive('get')->with('min_quality', Image::FULL_COMPRESSION)->andReturn(10);
     $request->shouldReceive('get')->with('max_quality', image::NO_COMPRESSION)->andReturn(100);
     $request->shouldReceive('get')->with('max_file_size_bytes')->andReturn(2200);
     $image_blob = App::run($request);
     $this->assertTrue(is_string($image_blob));
     $imagick = new Imagick();
     $imagick->readImageBlob($image_blob);
     $this->assertEquals(150, $imagick->getImageHeight());
     $this->assertEquals(250, $imagick->getImageWidth());
     // we expect 250 because of Best Fit
 }
Example #2
0
<?php

/**
 * Setup dependencies and environment
 */
require __DIR__ . '/vendor/autoload.php';
use Fuzz\ImageResizer\App;
use Fuzz\ImageResizer\ExceptionHandler;
use Symfony\Component\HttpFoundation\Request;
try {
    echo App::run(Request::createFromGlobals());
} catch (Exception $e) {
    echo json_encode(ExceptionHandler::handleException($e));
}