Skip to content

Commit

Permalink
Merge branch 'geggleto-master'
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
akrabat committed Nov 12, 2015
2 parents 70cc36f + e518d24 commit a03d12b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
composer.lock
phpunit.xml
vendor
.idea
.idea
composer.phar
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"psr-4": {
"Slim\\Views\\": "src"
}
}
},
"require-dev": {
"phpunit/phpunit": "^4.0",
"slim/slim" : "^3.0-RC2"
}
}
25 changes: 25 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="Renderer Tests">
<directory>tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src/</directory>
</whitelist>
</filter>
</phpunit>
28 changes: 28 additions & 0 deletions tests/PhpRendererTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
use Slim\Http\Body;
use Slim\Http\Headers;
use Slim\Http\Response;

/**
* Created by PhpStorm.
* User: Glenn
* Date: 2015-11-12
* Time: 1:19 PM
*/
class PhpRendererTest extends \PHPUnit_Framework_TestCase
{

public function testRenderer() {
$renderer = new \Slim\Views\PhpRenderer("tests/");

$headers = new Headers();
$body = new Body(fopen('php://temp', 'r+'));
$response = new Response(200, $headers, $body);

$newResponse = $renderer->render($response, "testTemplate.php", array("hello" => "Hi"));

$newResponse->getBody()->rewind();

$this->assertEquals("Hi", $newResponse->getBody()->getContents());
}
}
9 changes: 9 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Created by PhpStorm.
* User: Glenn
* Date: 2015-11-12
* Time: 11:31 AM
*/

include "vendor/autoload.php";
8 changes: 8 additions & 0 deletions tests/testTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Created by PhpStorm.
* User: Glenn
* Date: 2015-11-12
* Time: 1:20 PM
*/
print $hello;

0 comments on commit a03d12b

Please sign in to comment.