diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d6e1e02
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+composer.lock
+vendor
+data/cache/*.php
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..fbb8ca4
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,34 @@
+{
+ "name": "hiropeke/slim-blade-view",
+ "type": "library",
+ "description": "Slim Framework 3 view helper built on top of the Blade component",
+ "keywords": [
+ "slim",
+ "framework",
+ "view",
+ "template",
+ "blade",
+ "renderer"
+ ],
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Hiroaki Matsuura",
+ "email": "hiropeke.jp@gmail.com"
+ }
+ ],
+ "require": {
+ "illuminate/view": "5.*",
+ "philo/laravel-blade": "3.*",
+ "psr/http-message": "^1.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "Slim\\Views\\": "src"
+ }
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^5.0",
+ "slim/slim": "^3.0"
+ }
+}
\ No newline at end of file
diff --git a/data/cache/.gitkeep b/data/cache/.gitkeep
new file mode 100644
index 0000000..212c4ba
--- /dev/null
+++ b/data/cache/.gitkeep
@@ -0,0 +1 @@
+#!/usr/bin/env bash
\ No newline at end of file
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..388c093
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,24 @@
+
+
+
Hi, my name is Josh.
\n", $output); + } + + public function testSingleTemplateWithANamespace() + { + $views = new Blade([ + 'One' => __DIR__ . '/templates', + ]); + $output = $views->fetch('example', [ + 'name' => 'Josh', + ]); + $this->assertEquals("Hi, my name is Josh.
\n", $output); + } + + public function testMultipleTemplatesWithMulNamespace() + { + $views = new Blade([ + 'One' => __DIR__ . '/templates', + 'Two' => __DIR__ . '/another', + ]); + $outputOne = $views->fetch('example', [ + 'name' => 'Peter', + ]); + $outputTwo = $views->fetch('example2', [ + 'name' => 'Peter', + 'gender' => 'male', + ]); + $this->assertEquals("Hi, my name is Peter.
\n", $outputOne); + $this->assertEquals("Hi, my name is Peter and I am male.
\n", $outputTwo); + } + + public function testRender() + { + $mockBody = $this->getMockBuilder('Psr\Http\Message\StreamInterface') + ->disableOriginalConstructor() + ->getMock(); + $mockResponse = $this->getMockBuilder('Psr\Http\Message\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); + $mockBody->expects($this->once()) + ->method('write') + ->with("Hi, my name is Josh.
\n") + ->willReturn(28); + $mockResponse->expects($this->once()) + ->method('getBody') + ->willReturn($mockBody); + $response = $this->view->render($mockResponse, 'example', [ + 'name' => 'Josh', + ]); + $this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response); + } +} \ No newline at end of file diff --git a/tests/another/example2.blade.php b/tests/another/example2.blade.php new file mode 100644 index 0000000..ee69620 --- /dev/null +++ b/tests/another/example2.blade.php @@ -0,0 +1 @@ +Hi, my name is {{ $name }} and I am {{ $gender }}.
diff --git a/tests/templates/example.blade.php b/tests/templates/example.blade.php new file mode 100644 index 0000000..8114d2f --- /dev/null +++ b/tests/templates/example.blade.php @@ -0,0 +1 @@ +Hi, my name is {{ $name }}.