1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 14:30:32 +02:00

Merge remote-tracking branch 'github-prototech/ticket/11508' into develop-ascraeus

* github-prototech/ticket/11508:
  [ticket/11508] Fix build_url test.
  [ticket/11508] Add functional test for jumpbox.
  [ticket/11508] Use $phpbb_path_helper.
  [ticket/11508] Allow equal sign in parameter value.
  [ticket/11508] Remove unnecessary implode.
  [ticket/11508] Remove unnecessary isset check.
  [ticket/11508] Fix build_url test.
  [ticket/11508] Curly brace should be on its own line...
  [ticket/11508] The question mark is expected even if there are no parameters.
  [ticket/11508] Add tests.
  [ticket/11508] Do not add the '?' unless there are parameters.
  [ticket/11508] Change separator parameter to a simple true|false $is_amp.
  [ticket/11508] Move helper functions to path_helper class.
  [ticket/11508] Move the stripping param code to separate function as well.
  [ticket/11508] Build the jumpbox hidden fields using the _form action_
  [ticket/11508] Split parts of build_url() into reusable functions.
This commit is contained in:
Nils Adermann
2014-05-02 16:40:01 +02:00
6 changed files with 393 additions and 62 deletions

View File

@@ -0,0 +1,33 @@
<?php
/**
*
* @package testing
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_jumpbox_test extends phpbb_functional_test_case
{
public function test_jumpbox()
{
$this->login();
$crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
$form = $crawler->filter('#quickmodform')->selectButton($this->lang('GO'))->form(array(
'action' => 'merge_topic',
));
$crawler = self::submit($form);
$this->assertContains($this->lang('FORUM') . ': Your first forum', $crawler->filter('#cp-main h2')->text());
$form = $crawler->filter('#jumpbox')->selectButton($this->lang('GO'))->form(array(
'f' => 1,
));
$crawler = self::submit($form);
$this->assertContains($this->lang('FORUM') . ': Your first category', $crawler->filter('#cp-main h2')->text());
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
*
* @package testing
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_build_url_test extends phpbb_test_case
{
protected function setUp()
{
global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper;
parent::setUp();
$phpbb_container = new phpbb_mock_container_builder();
$user = new phpbb_mock_user();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
new \phpbb\filesystem(),
$phpbb_root_path,
'php'
);
$phpbb_container->set('path_helper', $path_helper);
}
public function build_url_test_data()
{
return array(
array(
'index.php',
false,
'phpBB/index.php?',
),
array(
'index.php',
't',
'phpBB/index.php?',
),
array(
'viewtopic.php?f=2&style=1&t=6',
'f',
'phpBB/viewtopic.php?style=1&amp;t=6',
),
array(
'viewtopic.php?f=2&style=1&t=6',
array('f', 'style', 't'),
'phpBB/viewtopic.php?',
),
array(
'http://test.phpbb.com/viewtopic.php?f=2&style=1&t=6',
array('f', 'style', 't'),
'http://test.phpbb.com/viewtopic.php?',
),
);
}
/**
* @dataProvider build_url_test_data
*/
public function test_build_url($page, $strip_vars, $expected)
{
global $user, $phpbb_root_path;
$user->page['page'] = $page;
$output = build_url($strip_vars);
$this->assertEquals($expected, $output);
}
}

View File

@@ -7,7 +7,7 @@
*
*/
class phpbb_path_helper_web_root_path_test extends phpbb_test_case
class phpbb_path_helper_test extends phpbb_test_case
{
protected $path_helper;
protected $phpbb_root_path = '';
@@ -176,4 +176,155 @@ class phpbb_path_helper_web_root_path_test extends phpbb_test_case
{
$this->assertEquals($expected, $this->path_helper->clean_url($input));
}
public function glue_url_params_data()
{
return array(
array(
array(),
'',
),
array(
array('test' => 'xyz'),
'test=xyz',
),
array(
array('test' => 'xyz', 'var' => 'value'),
'test=xyz&amp;var=value',
),
);
}
/**
* @dataProvider glue_url_params_data
*/
public function test_glue_url_params($params, $expected)
{
$this->assertEquals($expected, $this->path_helper->glue_url_params($params));
}
public function get_url_parts_data()
{
return array(
array(
'viewtopic.php',
true,
array('base' => 'viewtopic.php', 'params' => array()),
),
array(
'./viewtopic.php?t=5&amp;f=6',
true,
array('base' => './viewtopic.php', 'params' => array('t' => '5', 'f' => '6')),
),
array(
'viewtopic.php?t=5&f=6',
false,
array('base' => 'viewtopic.php', 'params' => array('t' => '5', 'f' => '6')),
),
array(
'https://phpbb.com/community/viewtopic.php?t=5&amp;f=6',
true,
array('base' => 'https://phpbb.com/community/viewtopic.php', 'params' => array('t' => '5', 'f' => '6')),
),
array(
'test.php?topic=post=5&amp;f=3',
true,
array('base' => 'test.php', 'params' => array('topic' => 'post=5', 'f' => '3')),
),
array(
'mcp.php?&amp;t=4&amp;f=3',
true,
array('base' => 'mcp.php', 'params' => array('t' => '4', 'f' => '3')),
),
array(
'mcp.php?=4&amp;f=3',
true,
array('base' => 'mcp.php', 'params' => array('f' => '3')),
),
);
}
/**
* @dataProvider get_url_parts_data
*/
public function test_get_url_parts($url, $is_amp, $expected)
{
$this->assertEquals($expected, $this->path_helper->get_url_parts($url, $is_amp));
}
public function strip_url_params_data()
{
return array(
array(
'viewtopic.php',
'sid',
false,
'viewtopic.php',
),
array(
'./viewtopic.php?t=5&amp;f=6',
'f',
true,
'./viewtopic.php?t=5',
),
array(
'viewtopic.php?t=5&f=6&sid=19adc288814103cbb4625e74e77455aa',
array('t'),
false,
'viewtopic.php?f=6&amp;sid=19adc288814103cbb4625e74e77455aa',
),
array(
'https://phpbb.com/community/viewtopic.php?t=5&amp;f=6',
array('t', 'f'),
true,
'https://phpbb.com/community/viewtopic.php',
),
);
}
/**
* @dataProvider strip_url_params_data
*/
public function test_strip_url_params($url, $strip, $is_amp, $expected)
{
$this->assertEquals($expected, $this->path_helper->strip_url_params($url, $strip, $is_amp));
}
public function append_url_params_data()
{
return array(
array(
'viewtopic.php',
array(),
false,
'viewtopic.php',
),
array(
'./viewtopic.php?t=5&amp;f=6',
array('t' => '7'),
true,
'./viewtopic.php?t=7&amp;f=6',
),
array(
'viewtopic.php?t=5&f=6&sid=19adc288814103cbb4625e74e77455aa',
array('p' => '5'),
false,
'viewtopic.php?t=5&amp;f=6&amp;p=5&amp;sid=19adc288814103cbb4625e74e77455aa',
),
array(
'https://phpbb.com/community/viewtopic.php',
array('t' => '7', 'f' => '8'),
true,
'https://phpbb.com/community/viewtopic.php?t=7&amp;f=8',
),
);
}
/**
* @dataProvider append_url_params_data
*/
public function test_append_url_params($url, $params, $is_amp, $expected)
{
$this->assertEquals($expected, $this->path_helper->append_url_params($url, $params, $is_amp));
}
}