Skip to content

Commit

Permalink
Restore missing tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzap committed Jul 6, 2015
1 parent 23b1891 commit 9910b5a
Show file tree
Hide file tree
Showing 22 changed files with 901 additions and 0 deletions.
Empty file added tests/_files/assets/foo.css
Empty file.
Empty file added tests/_files/assets/foo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added tests/_files/assets/foo.js
Empty file.
Empty file added tests/_files/bar/foo.php
Empty file.
16 changes: 16 additions & 0 deletions tests/_files/bar/second.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php $this->layout('main', ['foo' => 'Bar!']) ?>

<?php $this->section('one') ?>
World <?= $this->foo ?>
<?php $this->stop() ?>

<?php $this->section('two') ?>
I Win
<?php $this->replace() ?>

Buffalo Bill

<?php $this->section('three') ?>
MAN
<?php
$this->stop();
1 change: 1 addition & 0 deletions tests/_files/foo/alias.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?= $T->foo ?>
2 changes: 2 additions & 0 deletions tests/_files/foo/bar.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo implode('|', $this->data());
11 changes: 11 additions & 0 deletions tests/_files/foo/blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php $this->block('spaceless') ?>
<?php $this->block('wrap', '<div>', '</div>') ?>
<?php $this->block('spaceless') ?>
<ul>
<?php $this->block('repeat', 3) ?>
<li>a</li>
<?php $this->endblock('repeat'); ?>
</ul>
<?php $this->endblock('spaceless') ?>
<?php $this->endblock('wrap') ?>
<?php $this->endblock('spaceless') ?>
1 change: 1 addition & 0 deletions tests/_files/foo/double.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I have 2 extensions
2 changes: 2 additions & 0 deletions tests/_files/foo/foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo implode(',', $this->data());
14 changes: 14 additions & 0 deletions tests/_files/foo/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php $this->section('one') ?>
Hello <?= $this->foo.' ' ?>
<?php $this->stop() ?>

Alone

<?php $this->section('two') ?>
NO
<?php $this->stop() ?>

<?php $this->section('three') ?>
YES
<?php
$this->stop();
49 changes: 49 additions & 0 deletions tests/_files/stubs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php namespace Foil\Tests;

use JsonSerializable;

class Value
{
public $value;

public function __construct($value)
{
$this->value = $value;
}
}

class ToArray extends Value
{
public function toArray()
{
return ['toarray' => (array) $this->value];
}
}

class AsArray extends Value
{
public function asArray()
{
return ['asarray' => (array) $this->value];
}
}

class Json implements JsonSerializable
{
public function jsonSerialize()
{
return '<b>I am JSON</b>';
}
}

class Target extends Value
{
}

class Transformer
{
public function transform($object)
{
return is_object($object) ? ['transformed' => get_object_vars($object)] : false;
}
}
113 changes: 113 additions & 0 deletions tests/_files/templates/expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Foil is Awesome!</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<div>
<ul>
<li><a href="http://www.example.com">First Item</a></li>
<li><a href="#">Second Item</a></li>
</ul>
</div>

<div>

<p>Deep var test: Lorem Ipsum Dolor</p>

<p>Default test: I am a default.</p>

<p>__get test: TEST ME!</p>

<p>Raw test: <strong>This is a strong tag html content</strong></p>

<p>Autoescape test: &lt;strong&gt;This is a strong tag html content&lt;/strong&gt;</p>

<p>Filter test: I AM LOWERCASE</p>

<p>Advanced test: HELLO WORLD!</p>

</div>

<div>
Here something for you.
</div>

<div>
<p>OVERRIDE a section defined in a PARTIAL</p>

<p>
I am a partial. And this: &quot;TEST ME!&quot; is a var I share with template, but
this &quot;I am a partial var!&quot; is a specific partial var.
</p>

</div>

<div>
<p>
I am another partial.
This: &quot;I am a partial var too.&quot; is a specific partial var.
This: &quot;TEST ME!&quot; is a var I share with template.
A shared var skipped: &quot;Foil is Awesome!&quot;.
</p>
</div>

<div>
<p>Should BE SUPPLYED by layout.</p>
</div>

<div>
I am here.
</div>

<div>

<p>MAIN LAYOUT, first section</p>

<div>

<p>Should REPLACE layout first-child layout section.</p>

</div>

<p>MAIN LAYOUT, first section after child</p>

<p>Should BE APPENDED to layout first section.</p>

</div>

<div>

<p>Should REPLACE layout second section.</p>

<div>
<p>Extended layout third section.</p>
<p>Should BE APPENDED to extended layout third section.</p>
</div>

</div>

<div>

<p>EXTENDED LAYOUT, Out of any section, output a deep var Another deep var.</p>

<div>

<p>
I am another partial.
This: &quot;!!!&quot; is a specific partial var.
This: &quot;TEST ME!&quot; is a var I share with template.
A shared var skipped: &quot;&quot;.
</p>

<p>FINAL TEMPLATE, Out of any section, ouput a var TEST ME!</p>

</div>
</div>

</body>
</html>
33 changes: 33 additions & 0 deletions tests/_files/templates/extended.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php $this->layout('layout') ?>

<p>EXTENDED LAYOUT, Out of any section, output a deep var <?= $this->v('a.var.in.extended') ?></p>

<?php $this->section('first') ?>

<p>Should BE APPENDED to layout first section.</p>

<?php $this->append() // first ?>

<?php $this->section('first-child') ?>

<p>Should REPLACE layout first-child layout section.</p>

<?php $this->replace() // first-child ?>

<?php $this->section('second') ?>

<p>Should REPLACE layout second section.</p>

<div>

<?php $this->section('third') ?>
<p>Extended layout third section.</p>
<?php $this->append() // third ?>

</div>

<?php $this->replace(); // second ?>

<div>
<?= $this->buffer() ?>
</div>
25 changes: 25 additions & 0 deletions tests/_files/templates/final-template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php $this->layout('extended') ?>

<?php $this->section('a-section') ?>

<p>Should BE SUPPLYED by layout.</p>

<?php $this->stop() ?>


<?php $this->section('third') ?>

<p>Should BE APPENDED to extended layout third section.</p>

<?php $this->append() // third ?>


<?php $this->section('another-section') ?>

<p>OVERRIDE a section defined in a PARTIAL</p>

<?php $this->replace() // another-section ?>

<?= $this->insert('partials/partial-2', ['a_partial_var' => '"!!!"'], ['test_me']) ?>

<p>FINAL TEMPLATE, Out of any section, ouput a var <?= $this->v('test_me') ?></p>
90 changes: 90 additions & 0 deletions tests/_files/templates/layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= $this->v('title', 'Default Title') ?></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<?= $this->ww('menu', '<div><ul>%s</ul></div>', '<li><a href="%s">%s</a></li>') ?>

<?= $this->wwif('menu', false, '<div>%s</div>', '<li><a href="%s">%s</a></li>') ?>

<div>

<p>Deep var test: <?= $this->v('a.pretty.deep.var') ?></p>

<p>Default test: <?= $this->v('i_do_not_exist', 'I am a default.') ?></p>

<p>__get test: <?= $this->test_me ?></p>

<p>Raw test: <?= $this->raw('html_content') ?></p>

<p>Autoescape test: <?= $this->html_content ?></p>

<p>Filter test: <?= $this->f('uppercase|reverse', 'lowercase') ?></p>

<p>Advanced test: <?= $this->v('a.var.0|uppercase|reverse') ?></p>

</div>

<div>
<?= $this->returnSomething() ?>
</div>

<div>
<?= $this->insert('partials/partial', ['a_partial_var' => '"I am a partial var!"']) ?>
</div>

<div>
<?= $this->raw('i_do_not_exist', $this->insert('partials/partial-2', ['a_partial_var' => '"I am a partial var too."'])) ?>
</div>

<div>
<?= $this->supply('a-section') ?>
</div>

<div>
<?= $this->supply('a-non-existent-section', 'I am here.') ?>
</div>

<div>

<?php $this->section('first') ?>

<p>MAIN LAYOUT, first section</p>

<div>

<?php $this->section('first-child') ?>

<p>MAIN LAYOUT, first child section</p>

<?php $this->stop() // first-child ?>

</div>

<p>MAIN LAYOUT, first section after child</p>

<?php $this->stop() // first ?>

</div>

<div>

<?php $this->section('second') ?>

<p>MAIN LAYOUT, second section</p>

<?php $this->stop() // second ?>

</div>

<div>
<?= $this->buffer() ?>
</div>

</body>
</html>
6 changes: 6 additions & 0 deletions tests/_files/templates/partials/partial-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p>
I am another partial.
This: <?= $this->v('a_partial_var') ?> is a specific partial var.
This: &quot;<?= $this->test_me ?>&quot; is a var I share with template.
A shared var skipped: &quot;<?= $this->v('title') ?>&quot;.
</p>
10 changes: 10 additions & 0 deletions tests/_files/templates/partials/partial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php $this->section('another-section') ?>

<p>A SECTION defined in a PARTIAL</p>

<?php $this->stop() ?>

<p>
I am a partial. And this: &quot;<?= $this->test_me ?>&quot; is a var I share with template, but
this <?= $this->v('a_partial_var') ?> is a specific partial var.
</p>
Loading

0 comments on commit 9910b5a

Please sign in to comment.