[feature/mod_version_check] Add newer mod version check service

This commit is contained in:
Marc Alexander
2013-10-30 00:14:44 +01:00
parent d2634566b8
commit 6747625a5c
5 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
/**
*
* @package testing
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
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');
}
}

46
tests/mock/template.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
/**
*
* @package testing
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\portal\tests\mock;
class template
{
protected $data = array();
protected $test_case;
public function __construct($test_case)
{
$this->test_case = $test_case;
}
public function assign_block_vars($row, $values)
{
$this->test_case->assertEquals(true, is_array($values));
if (!isset($this->data[$row]))
{
$this->data[$row] = array();
}
foreach ($values as $key => $column)
{
$this->test_case->assertArrayNotHasKey($key, $this->data[$row]);
$this->data[$row][$key] = $column;
}
}
public function assert_equals($data, $row)
{
foreach ($data as $key => $value)
{
$this->test_case->assertEquals($value, $this->data[$row][$key]);
}
}
}

25
tests/mock/user.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
/**
*
* @package testing
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\portal\tests\mock;
class user extends \PHPUnit_Framework_TestCase
{
public $lang = array();
public function set($data)
{
$this->assertTrue(is_array($data));
foreach ($data as $key => $column)
{
$this->lang[$key] = $column;
}
}
}