Skip to content

Commit

Permalink
loop view tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-deluna committed Jul 13, 2014
1 parent e91ae70 commit e1c2a9c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/orbit/CCUnit/views/builder/each.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% each $items as $item %}{{$item}}, {% endeach %}
5 changes: 5 additions & 0 deletions src/orbit/CCUnit/views/builder/each_user.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul>
{% each $users as $user %}
<li>{{$user.name}}</li>
{% endeach %}
</ul>
1 change: 1 addition & 0 deletions src/orbit/CCUnit/views/builder/loop.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% loop 10 %}{{$i}}{% endloop %}
44 changes: 44 additions & 0 deletions tests/Core/CCView/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,48 @@ public function test_echo()

$this->assertEquals( $expected_output, $output );
}

/**
* tests Builder loop
*/
public function test_loop()
{
$output = CCView::create( 'CCUnit::builder/loop.view' )->render();

$expected_output = "0123456789";

$this->assertEquals( $expected_output, $output );
}

/**
* tests Builder loop
*/
public function test_each()
{
$output = CCView::create( 'CCUnit::builder/each.view', array(
'items' => array( 'foo', 'bar', 'jep' ),
))->render();

$expected_output = "foo, bar, jep, ";

$this->assertEquals( $expected_output, $output );
}

/**
* tests Builder loop
*/
public function test_array_access()
{
$output = CCView::create( 'CCUnit::builder/each_user.view', array(
'users' => array(
array( 'name' => 'jeff' ),
array( 'name' => 'john' ),
array( 'name' => 'jack' ),
),
))->render();

$expected_output = "<ul>\n\t<li>jeff</li>\n\t<li>john</li>\n\t<li>jack</li>\n</ul>";

$this->assertEquals( $expected_output, $output );
}
}

0 comments on commit e1c2a9c

Please sign in to comment.