How catch all action output into a string?

Hi,

I want to write some tests for a controller.

Actions of the controller prints JSON.

I tried to use functional tests with Selenium.

But Selenium class hasn’t method get a content of a page.

Also I tried to use caching. But the get method returns nothing.


  'components'=>array(

    'cache' => array(

      'class'=>'system.caching.CDummyCache',

    ),

.....


    $this->c->beginCache('xxx');

    $this->c->actionGetinfo($this->cs->skey, 'ios', '2000-10-10');

    $this->c->endCache();


    echo "\nXXXXX\n" . Yii::app()->cache->get('xxx')  . "\nendxxx\n";



I’ve solved my problem.

There is my solution:

override Controller method afterRender

function afterRender($view, $output) {

$this->buffer = $output;

}

replace echo json_encode( array(…) )

to

class ClientController extends Controller {

public $layout = ‘//layout/json’;

$this->render(‘json’, array(‘answer’ => array …)));

views/client/json.php:

<?= CJSON::encode($answer); ?>

views/layout/json.php:

<?= $content; ?>