Skip to content

Commit

Permalink
🔀 Merge pull request #120 from carbontwelve/issue-118-test-kernel-plates
Browse files Browse the repository at this point in the history
Issue 118 test kernel plates
  • Loading branch information
carbontwelve authored Mar 28, 2017
2 parents b6acd32 + 4dc2a15 commit 7dffd4b
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tapestry.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public function boot()
{
$this->register(\Tapestry\Providers\CommandServiceProvider::class);
$this->register(\Tapestry\Providers\ProjectConfigurationServiceProvider::class);
$this->register(\Tapestry\Providers\ProjectKernelServiceProvider::class);
$this->register(\Tapestry\Providers\ProjectServiceProvider::class);
$this->register(\Tapestry\Providers\CompileStepsServiceProvider::class);
$this->register(\Tapestry\Providers\PlatesServiceProvider::class);
$this->register(\Tapestry\Providers\ProjectKernelServiceProvider::class);
}

/**
Expand Down
27 changes: 27 additions & 0 deletions tests/KernelTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Tapestry\Tests;

use Symfony\Component\Finder\SplFileInfo;
use Tapestry\Entities\ContentType;
use Tapestry\Entities\File;
use Tapestry\Modules\ContentTypes\ContentTypeFactory;

class KernelTest extends CommandTestBase
{
public function testSiteKernelLoading()
{
$this->copyDirectory('assets/build_test_28/src', '_tmp');
$output = $this->runCommand('build', '--quiet');

$this->assertEquals('', trim($output->getDisplay()));
$this->assertEquals(0, $output->getStatusCode());

$this->assertFileEquals(
__DIR__.'/assets/build_test_28/check/index.html',
__DIR__.'/_tmp/build_local/index.html',
'',
true
);
}
}
1 change: 1 addition & 0 deletions tests/assets/build_test_28/check/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world!
6 changes: 6 additions & 0 deletions tests/assets/build_test_28/src/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'debug' => false,
'kernel' => \SiteTwentyEight\Kernel::class,
];
45 changes: 45 additions & 0 deletions tests/assets/build_test_28/src/kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace SiteTwentyEight;

use Tapestry\Modules\Kernel\KernelInterface;
use Tapestry\Plates\Engine;
use Tapestry\Tapestry;
use TapestryCloud\Lib\TestPlatesExtension;

class Kernel implements KernelInterface
{
/**
* @var Tapestry
*/
private $tapestry;

public function __construct()
{
$this->tapestry = Tapestry::getInstance();
}

/**
* This method is executed by Tapestry when the Kernel is registered.
*
* @return void
*/
public function register()
{
include (__DIR__ . '/lib/TestPlatesExtension.php');

/** @var Engine $engine */
$engine = $this->tapestry->getContainer()->get(Engine::class);
$engine->loadExtension($this->tapestry->getContainer()->get(TestPlatesExtension::class));
}

/**
* This method of executed by Tapestry as part of the build process.
*
* @return void
*/
public function boot()
{
// TODO: Implement boot() method.
}
}
17 changes: 17 additions & 0 deletions tests/assets/build_test_28/src/lib/TestPlatesExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php namespace TapestryCloud\Lib;

use League\Plates\Engine;
use League\Plates\Extension\ExtensionInterface;

class TestPlatesExtension implements ExtensionInterface
{
public function register(Engine $engine)
{
$engine->registerFunction('test', [$this, 'test']);
}

public function test()
{
return 'hello world!';
}
}
1 change: 1 addition & 0 deletions tests/assets/build_test_28/src/source/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?= $this->test() ?>

0 comments on commit 7dffd4b

Please sign in to comment.