Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed Nov 5, 2014
1 parent 8751b6e commit 291188e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/ImageResizeTest.php
Expand Up @@ -21,6 +21,11 @@
class ImageResizeTest extends \PHPUnit_Framework_TestCase
{

public function setUp()
{
$_SERVER["DOCUMENT_ROOT"] = __DIR__ . "/../example/";
}

public function testShouldBeTrue()
{
$this->assertTrue(true);
Expand Down Expand Up @@ -116,4 +121,50 @@ public function testImagesShouldNotBeAllowed()
"size" => "100x200",
"extension" => "pdf")));
}

public function testShouldReturnImage()
{

\Slim\Environment::mock(array(
"SCRIPT_NAME" => "/index.php",
"PATH_INFO" => "/images/viper-200x200.jpg"
));
$app = new \Slim\Slim();
$app->get("/foo", function () {
echo "Success";
});

$middleware = new \Slim\Middleware\ImageResize(array(
));

$middleware->setApplication($app);
$middleware->setNextMiddleware($app);
$middleware->call();

$this->assertEquals(200, $app->response()->status());
$this->assertEquals("image/jpeg", $app->response()->header("Content-Type"));
}

public function testShouldReturnHtml()
{

\Slim\Environment::mock(array(
"SCRIPT_NAME" => "/index.php",
"PATH_INFO" => "/foo"
));
$app = new \Slim\Slim();
$app->get("/foo", function () {
echo "Success";
});

$middleware = new \Slim\Middleware\ImageResize(array(
));

$middleware->setApplication($app);
$middleware->setNextMiddleware($app);
$middleware->call();

$this->assertEquals(200, $app->response()->status());
$this->assertEquals("text/html", $app->response()->header("Content-Type"));
}
}

0 comments on commit 291188e

Please sign in to comment.