Created
January 21, 2012 11:29
-
-
Save icambridge/1652436 to your computer and use it in GitHub Desktop.
Controller Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace app\tests\cases\controllers; | |
use app\controllers\ArticlesController; | |
use app\tests\mocks\controllers\MockArticlesController; | |
use lithium\action\Request; | |
class ArticlesControllerTest extends \lithium\test\Unit { | |
protected $_controller; | |
public function setUp() {} | |
public function tearDown() {} | |
public function testIndexList() { | |
$request = new Request(); | |
$articlesController = new MockArticlesController(compact('request')); | |
$articlesController->index(); | |
// Following comments is thanks to @mehlah with $this->_controller a MockArticlesController pre set up in $this->setUp() | |
// or $this->_controller(null, array('action' => 'index', 'args' => array())); | |
// that make use of PHP's callable syntax and yield to call `Controller::__invoke()` for dispatching requests to action methods. | |
// $this->_controller->__invoke(null, array('action' => 'index', 'args' => array())); | |
$render = $articlesController->access('_render'); | |
$viewVars = $render['data']; | |
$this->assertTrue(isset($viewVars['test']),"The index 'test' isn't set"); | |
$this->assertEqual("test",$viewVars['test'],"The string should be 'test'"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment