[ticket/248] Move unit tests to unit folder
B3P-248
This commit is contained in:
41
tests/unit/functions/check_file_src_test.php
Normal file
41
tests/unit/functions/check_file_src_test.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
|
||||
|
||||
class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
global $db, $phpbb_root_path, $phpEx, $user;
|
||||
$user = new phpbb_mock_user();
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/styles.xml');
|
||||
}
|
||||
|
||||
public function test_check_file_src()
|
||||
{
|
||||
$this->assertFalse(check_file_src('portal_attach.png', '', 15, false));
|
||||
$this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15, false));
|
||||
}
|
||||
|
||||
public function test_check_file_src_error()
|
||||
{
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->setExpectedTriggerError(E_USER_WARNING);
|
||||
$this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15));
|
||||
}
|
||||
}
|
||||
21
tests/unit/functions/fixtures/styles.xml
Normal file
21
tests/unit/functions/fixtures/styles.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_styles">
|
||||
<column>style_path</column>
|
||||
<column>style_name</column>
|
||||
<column>style_active</column>
|
||||
<column>style_parent_tree</column>
|
||||
<row>
|
||||
<value>subsilver2</value>
|
||||
<value>subsilver2</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>prosilver</value>
|
||||
<value>prosilver</value>
|
||||
<value>1</value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
||||
19
tests/unit/functions/simple_test.php
Normal file
19
tests/unit/functions/simple_test.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
|
||||
class phpbb_functions_simple_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_ap_validate()
|
||||
{
|
||||
$this->assertEquals('<br/>woot<br/><ul><li>test</li></ul>', ap_validate('<br />woot<br/><ul><li>test</li><br /></ul>'));
|
||||
}
|
||||
|
||||
}
|
||||
51
tests/unit/functions/version_check_test.php
Normal file
51
tests/unit/functions/version_check_test.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
|
||||
|
||||
class phpbb_functions_version_check_test extends \board3\portal\tests\testframework\test_case
|
||||
{
|
||||
protected $version_check;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$this->template = new \board3\portal\tests\mock\template($this);
|
||||
|
||||
$version_data = array(
|
||||
'author' => 'Saint_hh',
|
||||
'title' => 'Board3 Portal',
|
||||
'tag' => 'board3_portal_v2_dev',
|
||||
'version' => 'board3_portal_version',
|
||||
'file' => array('board3.de', 'updatecheck', 'board3_portal.xml'),
|
||||
);
|
||||
$config = array('board3_portal_version' => '2.1.0');
|
||||
$user = new \board3\portal\tests\mock\user;
|
||||
$user->set(array(
|
||||
'NO_INFO' => 'NO_INFO',
|
||||
'NOT_UP_TO_DATE' => 'NOT_UP_TO_DATE',
|
||||
'UP_TO_DATE' => 'UP_TO_DATE',
|
||||
));
|
||||
$this->version_check = new \board3\portal\includes\mod_version_check($version_data, $config, $phpbb_root_path, $phpEx, $this->template, $user);
|
||||
}
|
||||
|
||||
public function test_version_check()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
$this->assertNull($this->version_check->version_check());
|
||||
$this->assertEquals('2.1.0', $this->version_check->version_check(true));
|
||||
$this->template->assert_equals(array(
|
||||
'CURRENT_VERSION' => '2.1.0',
|
||||
'TITLE' => 'Board3 Portal',
|
||||
'UP_TO_DATE' => 'UP_TO_DATE',
|
||||
'S_UP_TO_DATE' => true,
|
||||
), 'mods');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user