Skip to content

Instantly share code, notes, and snippets.

@fabriziomachado
Created October 19, 2011 15:58
Show Gist options
  • Save fabriziomachado/1298746 to your computer and use it in GitHub Desktop.
Save fabriziomachado/1298746 to your computer and use it in GitHub Desktop.
<?php
/**
* @group Helper
*/
class PartialsHelperTest extends CIUnit_TestCase
{
public function setUp()
{
$this->CI->load->helper('partials');
$this->people = (object) array((object) array('name'=>'John'), (object) array('name'=>'Michael'));
$this->locals_vars = array('people'=> $this->people,'say_hello'=> 'Hello World');
}
public function testReturnsAPartialOfAView()
{
$partial = TESTSPATH . 'fixtures/_list_people_view_fixt.php';
$expected_html = TESTSPATH . 'fixtures/_list_people_view_output.html';
$output_html = render_partial($partial, $this->locals_vars );
$this->assertStringEqualsFile( $expected_html , $output_html);
}
public function testReturnsAPartialForEachItemInTheCollection()
{
$partial = TESTSPATH . 'fixtures/_people_view_fixt.php';
$expected_html = TESTSPATH . 'fixtures/_people_view_output.html';
$output_html = render_partial($partial, $this->locals_vars, $this->peoples );
$this->assertStringEqualsFile( $expected_html , $output_html);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment