Location: PHPKode > scripts > RogePHP > RoguePHP-0.9.4/RoguePHP-0.9.4/tests/views/TestConditionals.php
<?php

//define ('LIB_CACHE_ENABLE', true);
define ('VIEW_DIR', dirname(__FILE__) . '/');
require '/usr/local/etc/tm.php';
define ('ROGUE_DIR', '/code/rogue');

define('XHTML_EOL', "");
define('XHTML_EOT', "");
define('XHTML_DEBUG', true);
/**
 * Description of TestConditionals
 *
 * @author cory
 */
class TestConditionals extends PHPUnit_Framework_TestCase
{

    public function testConditionalOnList_notset()
    {
        $view = new XhtmlView('listConditional.xhtml');
        $view->add('baz', array(array('bar' => 'foobar')));
        $result = $view->render('body', 'test1');
        $this->assertEquals("<div>  </div>", $result);
    }

    public function testConditionalOnList_setfalse()
    {
        $view = new XhtmlView('listConditional.xhtml');
        $view->add('foo', false);
        $view->add('baz', array(array('bar' => 'foobar')));
        $result = $view->render('body', 'test1');
        $this->assertEquals("<div>  </div>", $result);
    }

    public function testConditionalOnList_works()
    {
        $view = new XhtmlView('listConditional.xhtml');
        $view->add('foo', true);
        $view->add('baz', array(array('bar' => 'foobar')));
        $result = $view->render('body', 'test1');
        $this->assertEquals('<div> <p><ul><li>foobar</li></ul></p> </div>', $result);
    }

    public function testConditionalOnError_fail()
    {
        $view = new XhtmlView('listConditional.xhtml');
        $result = $view->render('body', 'test2');
        $this->assertEquals("<div> pre  post </div>", $result);
    }

    public function testConditionalOnError_works()
    {
        $view = new XhtmlView('listConditional.xhtml');
        $view->add('error', "detail");
        $result = $view->render('body', 'test2');
        $this->assertEquals("<div> pre <span>error</span> post </div>", $result);
    }

    public function testConditionalAfterList_works()
    {
        $view = new XhtmlView('listConditional.xhtml');
        $view->add('baz', array(array('bar' => 'foobar')));
        $view->add('foo', true);
        $result = $view->render('body', 'test3');
        echo $result;
    }
}
?>
Return current item: RogePHP