unit test for addlink_toolbar + coding style
This commit is contained in:
parent
1b2b44f4bd
commit
ff5bda8238
2 changed files with 111 additions and 2 deletions
tests/plugins
100
tests/plugins/PluginAddlinkTest.php
Normal file
100
tests/plugins/PluginAddlinkTest.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PluginPlayvideosTest.php
|
||||
*/
|
||||
|
||||
require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
|
||||
require_once 'application/Router.php';
|
||||
|
||||
/**
|
||||
* Class PluginAddlinkTest
|
||||
* Unit test for the Addlink toolbar plugin
|
||||
*/
|
||||
class PluginAddlinkTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Reset plugin path.
|
||||
*/
|
||||
function setUp()
|
||||
{
|
||||
PluginManager::$PLUGINS_PATH = 'plugins';
|
||||
}
|
||||
|
||||
/**
|
||||
* Test render_header hook while logged in.
|
||||
*/
|
||||
function testAddlinkHeaderLoggedIn()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data['_PAGE_'] = Router::$PAGE_LINKLIST;
|
||||
$data['_LOGGEDIN_'] = true;
|
||||
|
||||
$data = hook_addlink_toolbar_render_header($data);
|
||||
$this->assertEquals($str, $data[$str]);
|
||||
$this->assertEquals(1, count($data['fields_toolbar']));
|
||||
|
||||
$data = array($str => $str);
|
||||
$data['_PAGE_'] = $str;
|
||||
$data['_LOGGEDIN_'] = true;
|
||||
$data = hook_addlink_toolbar_render_header($data);
|
||||
$this->assertEquals($str, $data[$str]);
|
||||
$this->assertArrayNotHasKey('fields_toolbar', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test render_header hook while logged out.
|
||||
*/
|
||||
function testAddlinkHeaderLoggedOut()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data['_PAGE_'] = Router::$PAGE_LINKLIST;
|
||||
$data['_LOGGEDIN_'] = false;
|
||||
|
||||
$data = hook_addlink_toolbar_render_header($data);
|
||||
$this->assertEquals($str, $data[$str]);
|
||||
$this->assertArrayNotHasKey('fields_toolbar', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test render_includes hook while logged in.
|
||||
*/
|
||||
function testAddlinkIncludesLoggedIn()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data['_PAGE_'] = Router::$PAGE_LINKLIST;
|
||||
$data['_LOGGEDIN_'] = true;
|
||||
|
||||
$data = hook_addlink_toolbar_render_includes($data);
|
||||
$this->assertEquals($str, $data[$str]);
|
||||
$this->assertEquals(1, count($data['css_files']));
|
||||
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data['_PAGE_'] = $str;
|
||||
$data['_LOGGEDIN_'] = true;
|
||||
|
||||
$data = hook_addlink_toolbar_render_includes($data);
|
||||
$this->assertEquals($str, $data[$str]);
|
||||
$this->assertArrayNotHasKey('css_files', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test render_includes hook.
|
||||
* Should not affect css files while logged out.
|
||||
*/
|
||||
function testAddlinkIncludesLoggedOut()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data['_PAGE_'] = Router::$PAGE_LINKLIST;
|
||||
$data['_LOGGEDIN_'] = false;
|
||||
|
||||
$data = hook_addlink_toolbar_render_includes($data);
|
||||
$this->assertEquals($str, $data[$str]);
|
||||
$this->assertArrayNotHasKey('css_files', $data);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue