array(
CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'View' . DS,
APP . 'Plugin' . DS . 'DebugKit' . DS . 'View' . DS,
CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'View' . DS
)
), true);
}
/**
* Tear Down Test Case
*/
public static function tearDownAfterClass() {
App::build();
}
/**
* Setup
*
* @return void
*/
public function setUp() {
parent::setUp();
Router::connect('/:controller/:action');
$request = new CakeRequest();
$request->addParams(array('controller' => 'pages', 'action' => 'display'));
$this->Controller = new Controller($request, new CakeResponse());
$this->View = new View($this->Controller);
$this->Toolbar = new ToolbarHelper($this->View, array('output' => 'DebugKit.HtmlToolbar'));
$this->Toolbar->HtmlToolbar = new HtmlToolbarHelper($this->View);
$this->Toolbar->HtmlToolbar->Html = new HtmlHelper($this->View);
$this->Toolbar->HtmlToolbar->Form = new FormHelper($this->View);
}
/**
* Tear Down
*
* @return void
*/
public function tearDown() {
parent::tearDown();
unset($this->Toolbar, $this->Controller);
}
/**
* Test makeNeatArray with basic types.
*
* @return void
*/
public function testMakeNeatArrayBasic() {
$in = false;
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'
assertTags($result, $expected);
$in = null;
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
$in = true;
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
$in = array();
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
}
/**
* Test that cyclic references can be printed.
*
* @return void
*/
public function testMakeNeatArrayCyclicObjects() {
$a = new StdClass;
$b = new StdClass;
$a->child = $b;
$b->parent = $a;
$in = array('obj' => $a);
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
array('ul' => array('class' => 'neat-array depth-0')),
' array('class' => 'neat-array depth-1')),
' array('class' => 'neat-array depth-2')),
'assertTags($result, $expected);
}
/**
* Test Neat Array formatting
*
* @return void
*/
public function testMakeNeatArray() {
$in = array('key' => 'value');
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
$in = array('key' => null);
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
$in = array('key' => 'value', 'foo' => 'bar');
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
$in = array(
'key' => 'value',
'foo' => array(
'this' => 'deep',
'another' => 'value'
)
);
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
' array('class' => 'neat-array depth-1')),
'assertTags($result, $expected);
$in = array(
'key' => 'value',
'foo' => array(
'this' => 'deep',
'another' => 'value'
),
'lotr' => array(
'gandalf' => 'wizard',
'bilbo' => 'hobbit'
)
);
$result = $this->Toolbar->makeNeatArray($in, 1);
$expected = array(
'ul' => array('class' => 'neat-array depth-0 expanded'),
' array('class' => 'neat-array depth-1')),
' array('class' => 'neat-array depth-1')),
'assertTags($result, $expected);
$result = $this->Toolbar->makeNeatArray($in, 2);
$expected = array(
'ul' => array('class' => 'neat-array depth-0 expanded'),
' array('class' => 'neat-array depth-1 expanded')),
' array('class' => 'neat-array depth-1 expanded')),
'assertTags($result, $expected);
$in = array('key' => 'value', 'array' => array());
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
'ul' => array('class' => 'neat-array depth-0'),
'assertTags($result, $expected);
}
/**
* Test makeNeatArray with object inputs.
*
* @return void
*/
public function testMakeNeatArrayObjects() {
$in = new StdClass();
$in->key = 'value';
$in->nested = new StdClass();
$in->nested->name = 'mark';
$result = $this->Toolbar->makeNeatArray($in);
$expected = array(
array('ul' => array('class' => 'neat-array depth-0')),
' array('class' => 'neat-array depth-1')),
'assertTags($result, $expected);
}
/**
* Test injection of toolbar
*
* @return void
*/
public function testInjectToolbar() {
$this->Controller->viewPath = 'Posts';
$request = new CakeRequest('/posts/index');
$request->addParams(Router::parse($request->url));
$request->addPaths(array(
'webroot' => '/',
'base' => '/',
'here' => '/posts/index',
));
$this->Controller->setRequest($request);
$this->Controller->helpers = array('Html', 'Js', 'Session', 'DebugKit.Toolbar');
$this->Controller->layout = 'default';
$this->Controller->uses = null;
$this->Controller->components = array('DebugKit.Toolbar');
$this->Controller->constructClasses();
$this->Controller->Components->trigger('startup', array($this->Controller));
$this->Controller->Components->trigger('beforeRender', array($this->Controller));
$result = $this->Controller->render();
$result = str_replace(array("\n", "\r"), '', $result);
$this->assertPattern('#.+
.*