2015-11-07 16:13:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PlugQrcodeTest.php
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once 'plugins/qrcode/qrcode.php';
|
|
|
|
require_once 'application/Router.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class PlugQrcodeTest
|
|
|
|
* Unit test for the QR-Code plugin
|
|
|
|
*/
|
|
|
|
class PlugQrcodeTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Reset plugin path
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
PluginManager::$PLUGINS_PATH = 'plugins';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test render_linklist hook.
|
|
|
|
*/
|
|
|
|
function testQrcodeLinklist()
|
|
|
|
{
|
|
|
|
$str = 'http://randomstr.com/test';
|
|
|
|
$data = array(
|
|
|
|
'title' => $str,
|
|
|
|
'links' => array(
|
|
|
|
array(
|
2015-09-18 13:26:36 +02:00
|
|
|
'real_url' => $str,
|
2015-11-07 16:13:08 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$data = hook_qrcode_render_linklist($data);
|
|
|
|
$link = $data['links'][0];
|
|
|
|
// data shouldn't be altered
|
|
|
|
$this->assertEquals($str, $data['title']);
|
2015-09-18 13:26:36 +02:00
|
|
|
$this->assertEquals($str, $link['real_url']);
|
2015-11-07 16:13:08 +01:00
|
|
|
|
|
|
|
// plugin data
|
|
|
|
$this->assertEquals(1, count($link['link_plugin']));
|
|
|
|
$this->assertNotFalse(strpos($link['link_plugin'][0], $str));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test render_footer hook.
|
|
|
|
*/
|
|
|
|
function testQrcodeFooter()
|
|
|
|
{
|
|
|
|
$str = 'stuff';
|
|
|
|
$data = array($str => $str);
|
|
|
|
$data['_PAGE_'] = Router::$PAGE_LINKLIST;
|
|
|
|
|
|
|
|
$data = hook_qrcode_render_footer($data);
|
|
|
|
$this->assertEquals($str, $data[$str]);
|
|
|
|
$this->assertEquals(1, count($data['js_files']));
|
|
|
|
|
|
|
|
$data = array($str => $str);
|
|
|
|
$data['_PAGE_'] = $str;
|
|
|
|
$this->assertEquals($str, $data[$str]);
|
|
|
|
$this->assertArrayNotHasKey('js_files', $data);
|
|
|
|
}
|
|
|
|
}
|