[ticket/351] Use version_helper and json version file for version check

B3P-351
This commit is contained in:
Marc Alexander
2014-09-20 01:39:23 +02:00
parent d9ea2e4dda
commit 4e1bce320e
3 changed files with 90 additions and 115 deletions

View File

@@ -12,40 +12,71 @@ 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;
protected $template;
protected $config;
public function setUp()
{
global $phpbb_root_path, $phpEx;
$this->template = new \board3\portal\tests\mock\template($this);
include_once($phpbb_root_path . 'includes/functions.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
$version_data = array(
'author' => 'Saint_hh',
'title' => 'Board3 Portal',
'tag' => 'board3_portal_v2_dev',
$this->version_data = array(
'author' => 'Marc',
'version' => 'board3_portal_version',
'file' => array('board3.de', 'updatecheck', 'board3_portal.xml'),
'title' => 'Board3 Portal',
'file' => array('board3.de', '/updatecheck', 'board3_portal.json'),
);
$config = array('board3_portal_version' => '2.1.0');
$user = new \board3\portal\tests\mock\user;
$user->set(array(
$this->config = new \phpbb\config\config(array());
$this->user = new \board3\portal\tests\mock\user;
$this->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\version_check($version_data, $config, $phpbb_root_path, $phpEx, $this->template, $user);
$this->cache = $this->getMockBuilder('\phpbb\cache\service')
->disableOriginalConstructor()
->getMock();
}
public function test_version_check()
protected function get_version_helper($version)
{
$this->assertTrue(true);
$this->config->set('board3_portal_version', $version);
$this->template = new \board3\portal\tests\mock\template($this);
$version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\user('\phpbb\datetime'));
$this->version_check = new \board3\portal\includes\version_check($this->version_data, $this->config, $version_helper, $this->template, $this->user);
}
public function data_version_check()
{
return array(
array('2.1.0', array(
'CURRENT_VERSION' => '2.1.0',
'TITLE' => 'Board3 Portal',
'UP_TO_DATE' => 'UP_TO_DATE',
'S_UP_TO_DATE' => true,
'LATEST_VERSION' => '2.1.0',
)),
array('2.1.0-a1', array(
'CURRENT_VERSION' => '2.1.0-a1',
'TITLE' => 'Board3 Portal',
'UP_TO_DATE' => 'NOT_UP_TO_DATE',
'S_UP_TO_DATE' => false,
'LATEST_VERSION' => '2.1.0-b1',
)),
);
}
/**
* @dataProvider data_version_check
*/
public function test_version_up_to_date($version, $template_data)
{
$this->get_version_helper($version);
$this->assertEquals($version, $this->version_check->check(true));
$this->assertNull($this->version_check->check());
$this->assertEquals('2.1.0', $this->version_check->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');
$this->template->assert_equals($template_data, 'mods');
}
}