[ticket/634] Add more tests
B3P-634
This commit is contained in:
@@ -68,12 +68,12 @@ class listener_test extends \phpbb_template_template_test_case
|
||||
|
||||
$this->config = new \phpbb\config\config(array(
|
||||
'enable_mod_rewrite' => '1',
|
||||
'board3_portal_enable' => '1',
|
||||
'board3_enable' => '1',
|
||||
));
|
||||
$provider = new \phpbb\controller\provider();
|
||||
$provider->find_routing_files($finder);
|
||||
$provider->find(dirname(__FILE__) . '/');
|
||||
$this->controller_helper = new \phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, new \phpbb\symfony_request($request), $request, new \phpbb\filesystem(), '', 'php', dirname(__FILE__) . '/');
|
||||
$this->controller_helper = new mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, new \phpbb\symfony_request($request), $request, new \phpbb\filesystem(), '', 'php', dirname(__FILE__) . '/');
|
||||
|
||||
$this->path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
@@ -85,14 +85,13 @@ class listener_test extends \phpbb_template_template_test_case
|
||||
$this->php_ext
|
||||
);
|
||||
|
||||
$this->auth = new \phpbb\auth\auth();
|
||||
$userdata = array(
|
||||
'user_id' => 2,
|
||||
);
|
||||
$this->auth->acl($userdata);
|
||||
// Pretend to allow downloads
|
||||
$this->auth->acl_options['global']['u_view_portal'] = 0;
|
||||
$this->auth->acl[0][0] = true;
|
||||
$this->auth = $this->getMockBuilder('\phpbb\auth\auth')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->auth->expects($this->any())
|
||||
->method('acl_get')
|
||||
->with($this->anything())
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->controller = $this->getMockBuilder('\board3\portal\controller\main')
|
||||
->disableOriginalConstructor()
|
||||
@@ -160,14 +159,30 @@ class listener_test extends \phpbb_template_template_test_case
|
||||
|
||||
$this->assertEmpty($result);
|
||||
|
||||
$this->user->data['session_page'] = '/app.php/portal';
|
||||
$this->controller_helper->set_current_url('/app.php/portal');
|
||||
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
|
||||
|
||||
$this->assertEmpty($result);
|
||||
|
||||
// Make sure user shouldn't see link
|
||||
unset($this->auth->cache[0]['u_view_portal']);
|
||||
$this->auth->acl[0][0] = false;
|
||||
$this->config->set('board3_enable', 0);
|
||||
$this->controller_helper->set_current_url('');
|
||||
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
|
||||
|
||||
$this->assertEmpty($result);
|
||||
$this->config->set('board3_enable', 1);
|
||||
}
|
||||
|
||||
public function test_check_portal_all()
|
||||
{
|
||||
$this->phpbb_dispatcher->addListener('core.page_header', array($this->listener, 'add_portal_link'));
|
||||
|
||||
$this->controller_helper->set_current_url('');
|
||||
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
|
||||
|
||||
$this->assertEmpty($result);
|
||||
|
||||
$this->config->set('board3_show_all_pages', true);
|
||||
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
|
||||
|
||||
$this->assertEmpty($result);
|
||||
@@ -196,3 +211,18 @@ class listener_test extends \phpbb_template_template_test_case
|
||||
)), $result['lang_set_ext']);
|
||||
}
|
||||
}
|
||||
|
||||
class mock_controller_helper extends \phpbb_mock_controller_helper
|
||||
{
|
||||
protected $current_url = '';
|
||||
|
||||
public function set_current_url($url)
|
||||
{
|
||||
$this->current_url = $url;
|
||||
}
|
||||
|
||||
public function get_current_url()
|
||||
{
|
||||
return $this->current_url;
|
||||
}
|
||||
}
|
||||
|
||||
39
tests/unit/modules/search_test.php
Normal file
39
tests/unit/modules/search_test.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\modules;
|
||||
|
||||
class phpbb_unit_modules_search_test extends \board3\portal\tests\testframework\test_case
|
||||
{
|
||||
/** @var \board3\portal\tests\mock\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \board3\portal\modules\search */
|
||||
protected $search;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->template = new \board3\portal\tests\mock\template($this);
|
||||
$this->search = new \board3\portal\modules\search($this->template, '', '');
|
||||
}
|
||||
|
||||
public function test_get_template_side()
|
||||
{
|
||||
$this->assertSame('search_side.html', $this->search->get_template_side(5));
|
||||
}
|
||||
|
||||
public function test_get_template_acp()
|
||||
{
|
||||
$acp_template = $this->search->get_template_acp(5);
|
||||
$this->assertNotEmpty($acp_template);
|
||||
$this->assertEmpty($acp_template['vars']);
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,7 @@ class phpbb_unit_modules_welcome_test extends \board3\portal\tests\testframework
|
||||
$this->request->overwrite('submit', true, \phpbb\request\request_interface::POST);
|
||||
$this->request->overwrite('welcome_message', '');
|
||||
$this->setExpectedTriggerError(E_USER_WARNING);
|
||||
self::$form_key_valid = true;
|
||||
$this->welcome->update_welcome('foobar', 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user