You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.7 KiB
63 lines
1.7 KiB
<?php
|
|
|
|
/*
|
|
* @copyright NetMonsters <team@netmonsters.ru>
|
|
* @link http://netmonsters.ru
|
|
* @package Majestic
|
|
* @subpackage UnitTests
|
|
* @since 2011-11-1
|
|
*
|
|
* Unit tests for AjaxAction class
|
|
*/
|
|
|
|
require_once dirname(__FILE__) . '/Action_TestCase.php';
|
|
require_once dirname(__FILE__) . '/../../app/AjaxAction.php';
|
|
|
|
class AjaxActionTest extends Action_TestCase
|
|
{
|
|
|
|
/**
|
|
* @runInSeparateProcess
|
|
*/
|
|
public function testConstruct()
|
|
{
|
|
|
|
Config::set('DEBUG', false);
|
|
Env::setParams(array('ajax' => 'AjaxTemplate', 'param2' => 'value2'));
|
|
$action = $this->getMockForAbstractClass('AjaxAction' );
|
|
$this->assertAttributeEquals('ajax', 'template', $action);
|
|
}
|
|
|
|
/**
|
|
* @runInSeparateProcess
|
|
*/
|
|
public function testFetchWithEncode()
|
|
{
|
|
|
|
Config::set('DEBUG', false);
|
|
$controller = FrontController::getInstance();
|
|
$controller->setView('SomeView');
|
|
$action = $this->getMockForAbstractClass('AjaxAction' );
|
|
$action->data = array('var' => 'val');
|
|
$result = $action->fetch();
|
|
$this->assertSame('/actions//ajax', $result['template']);
|
|
$this->assertSame('{"var":"val"}', $result['data']);
|
|
}
|
|
|
|
/**
|
|
* @runInSeparateProcess
|
|
*/
|
|
public function testFetchNoEncode()
|
|
{
|
|
|
|
Config::set('DEBUG', false);
|
|
Env::setParams(array('json_encode' => false));
|
|
$controller = FrontController::getInstance();
|
|
$controller->setView('SomeView');
|
|
$action = $this->getMockForAbstractClass('AjaxAction' );
|
|
$action->data = array('var' => 'val');
|
|
$result = $action->fetch();
|
|
$this->assertSame('/actions//ajax', $result['template']);
|
|
$this->assertSame( $action->data, $result['data']);
|
|
}
|
|
}
|