aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-09-06 09:08:53 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-09-06 09:08:53 -0500
commit65f52d7575a8a7fe83cbfe7c5f35215ef8fba5b0 (patch)
tree840e0dc69209f7d73764483bfac68f4c238d37ef /tests
parent11317ef261c7811ea137d19ee38593d289ea6150 (diff)
parentdd86e8d0ae0179cf50076cdb1a8020266b6432a5 (diff)
downloadforums-65f52d7575a8a7fe83cbfe7c5f35215ef8fba5b0.tar
forums-65f52d7575a8a7fe83cbfe7c5f35215ef8fba5b0.tar.gz
forums-65f52d7575a8a7fe83cbfe7c5f35215ef8fba5b0.tar.bz2
forums-65f52d7575a8a7fe83cbfe7c5f35215ef8fba5b0.tar.xz
forums-65f52d7575a8a7fe83cbfe7c5f35215ef8fba5b0.zip
Merge branch 'develop' of github.com:phpbb/phpbb3 into ticket/11816
# By David King (16) and others # Via David King (13) and others * 'develop' of github.com:phpbb/phpbb3: (67 commits) [ticket/11825] Move schema_data.php into includes/ instead of phpbb/ [ticket/11215] Remove unnecessary comment [ticket/11755] MySQL upgrader out of date [prep-release-3.0.12] Update Changelog for 3.0.12-RC3 release. [prep-release-3.0.12] Bumping version number for 3.0.12-RC3. [ticket/11823] Set up nginx server to match PHP files with characters after .php [ticket/11812] Fix empty define [ticket/11818] Update Symfony dependencies to 2.3.* [ticket/11791] Load adm/ events from styles/adm/event/ [ticket/11215] Fix helper_url_test.php tests [ticket/11215] Add newline back to .htaccess, fix wording [ticket/11215] Update comment in .htaccess [ticket/11215] Uncomment rewrite rules in .htaccess [ticket/11215] Make controller helper url() method use correct format [ticket/11215] Add commented-out URL rewrite capability to .htaccess [ticket/11821] Fix comma usage next to "You are receiving this notification". [ticket/11769] Allow using 0 as poster name [ticket/11769] Allow '0' as username [ticket/11215] Use new URL structure for controllers [ticket/11215] Everything appears to be working... ... Conflicts: phpBB/phpbb/template/twig/lexer.php tests/template/template_test.php
Diffstat (limited to 'tests')
-rw-r--r--tests/controller/helper_url_test.php36
-rw-r--r--tests/extension/style_path_provider_test.php50
-rw-r--r--tests/extension/subdir/style_path_provider_test.php18
-rw-r--r--tests/functional/extension_controller_test.php10
-rw-r--r--tests/mock/auth_provider.php34
-rw-r--r--tests/template/includephp_test.php2
-rw-r--r--tests/template/template_events_test.php5
-rw-r--r--tests/template/template_test.php11
-rw-r--r--tests/template/template_test_case.php8
-rw-r--r--tests/template/template_test_case_with_tree.php5
-rw-r--r--tests/template/templates/define.html2
-rw-r--r--tests/template/templates/if.html2
12 files changed, 41 insertions, 142 deletions
diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php
index 6686b77e8f..49635332a7 100644
--- a/tests/controller/helper_url_test.php
+++ b/tests/controller/helper_url_test.php
@@ -15,28 +15,28 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
public function helper_url_data()
{
return array(
- array('foo/bar?t=1&amp;f=2', false, true, false, 'app.php?t=1&amp;f=2&amp;controller=foo/bar', 'parameters in url-argument'),
- array('foo/bar', 't=1&amp;f=2', true, false, 'app.php?controller=foo/bar&amp;t=1&amp;f=2', 'parameters in params-argument using amp'),
- array('foo/bar', 't=1&f=2', false, false, 'app.php?controller=foo/bar&t=1&f=2', 'parameters in params-argument using &'),
- array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'app.php?controller=foo/bar&amp;t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('foo/bar?t=1&amp;f=2', false, true, false, 'foo/bar?t=1&amp;f=2', 'parameters in url-argument'),
+ array('foo/bar', 't=1&amp;f=2', true, false, 'foo/bar?t=1&amp;f=2', 'parameters in params-argument using amp'),
+ array('foo/bar', 't=1&f=2', false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument using &'),
+ array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('foo/bar', 't=1&amp;f=2', true, 'custom-sid', 'app.php?controller=foo/bar&amp;t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
+ array('foo/bar', 't=1&amp;f=2', true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
// Testing anchors
- array('foo/bar?t=1&amp;f=2#anchor', false, true, false, 'app.php?t=1&amp;f=2&amp;controller=foo/bar#anchor', 'anchor in url-argument'),
- array('foo/bar', 't=1&amp;f=2#anchor', true, false, 'app.php?controller=foo/bar&amp;t=1&amp;f=2#anchor', 'anchor in params-argument'),
- array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php?controller=foo/bar&amp;t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('foo/bar?t=1&amp;f=2#anchor', false, true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in url-argument'),
+ array('foo/bar', 't=1&amp;f=2#anchor', true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument'),
+ array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('foo/bar?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'app.php?t=1&amp;f=2&amp;controller=foo/bar&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
- array('foo/bar', 't=1&amp;f=2#anchor', true, 'custom-sid', 'app.php?controller=foo/bar&amp;t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
- array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php?controller=foo/bar&amp;t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('foo/bar?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
+ array('foo/bar', 't=1&amp;f=2#anchor', true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
+ array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp;
- array('foo/bar', false, true, false, 'app.php?controller=foo/bar', 'no params using bool false'),
- array('foo/bar', '', true, false, 'app.php?controller=foo/bar', 'no params using empty string'),
- array('foo/bar', array(), true, false, 'app.php?controller=foo/bar', 'no params using empty array'),
+ array('foo/bar', false, true, false, 'foo/bar', 'no params using bool false'),
+ array('foo/bar', '', true, false, 'foo/bar', 'no params using empty string'),
+ array('foo/bar', array(), true, false, 'foo/bar', 'no params using empty array'),
);
}
@@ -48,14 +48,12 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->style_resource_locator = new phpbb_style_resource_locator();
$this->user = $this->getMock('phpbb_user');
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context());
- $this->style_resource_locator = new phpbb_style_resource_locator();
- $this->style_provider = new phpbb_style_path_provider();
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->style_resource_locator, $this->style_provider, $this->template);
- $helper = new phpbb_controller_helper($this->template, $this->user, '', 'php');
+
+ $request = new phpbb_mock_request($_GET, $_POST, $_COOKIE, $_SERVER, false, $_FILES);
+ $helper = new phpbb_controller_helper($this->template, $this->user, $request, '', 'php');
$this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected);
}
}
diff --git a/tests/extension/style_path_provider_test.php b/tests/extension/style_path_provider_test.php
deleted file mode 100644
index e1021c20ac..0000000000
--- a/tests/extension/style_path_provider_test.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2013 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_extension_style_path_provider_test extends phpbb_test_case
-{
- protected $relative_root_path;
- protected $root_path;
-
- public function setUp()
- {
- $this->relative_root_path = './';
- $this->root_path = dirname(__FILE__) . '/';
- }
-
- public function test_find()
- {
- $phpbb_style_path_provider = new phpbb_style_path_provider();
- $phpbb_style_path_provider->set_styles(array($this->relative_root_path . 'styles/prosilver'));
- $phpbb_style_extension_path_provider = new phpbb_style_extension_path_provider(new phpbb_mock_extension_manager(
- $this->root_path,
- array(
- 'foo' => array(
- 'ext_name' => 'foo',
- 'ext_active' => '1',
- 'ext_path' => 'ext/foo/',
- ),
- 'bar' => array(
- 'ext_name' => 'bar',
- 'ext_active' => '1',
- 'ext_path' => 'ext/bar/',
- ),
- )), $phpbb_style_path_provider, $this->relative_root_path);
-
- $this->assertEquals(array(
- 'style' => array(
- $this->relative_root_path . 'styles/prosilver',
- ),
- 'bar' => array(
- $this->root_path . 'ext/bar/styles/prosilver',
- ),
- ), $phpbb_style_extension_path_provider->find());
- }
-}
diff --git a/tests/extension/subdir/style_path_provider_test.php b/tests/extension/subdir/style_path_provider_test.php
deleted file mode 100644
index 1b5ce62e5f..0000000000
--- a/tests/extension/subdir/style_path_provider_test.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-require_once dirname(__FILE__) . '/../style_path_provider_test.php';
-
-class phpbb_extension_subdir_style_path_provider_test extends phpbb_extension_style_path_provider_test
-{
- public function setUp()
- {
- $this->relative_root_path = '../';
- $this->root_path = dirname(__FILE__) . '/../';
- }
-}
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 7d29f0000c..dc6d9c0f65 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -52,7 +52,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_foo_bar()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = self::request('GET', 'app.php?controller=foo/bar', array(), false);
+ $crawler = self::request('GET', 'app.php/foo/bar', array(), false);
self::assert_response_status_code();
$this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
@@ -64,7 +64,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_controller_with_template()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = self::request('GET', 'app.php?controller=foo/template');
+ $crawler = self::request('GET', 'app.php/foo/template');
$this->assertContains("I am a variable", $crawler->filter('#content')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -76,7 +76,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_missing_argument()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = self::request('GET', 'app.php?controller=foo/baz', array(), false);
+ $crawler = self::request('GET', 'app.php/foo/baz', array(), false);
$this->assert_response_html(500);
$this->assertContains('Missing value for argument #1: test in class phpbb_ext_foo_bar_controller:baz', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
@@ -88,7 +88,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_exception_should_result_in_500_status_code()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = self::request('GET', 'app.php?controller=foo/exception', array(), false);
+ $crawler = self::request('GET', 'app.php/foo/exception', array(), false);
$this->assert_response_html(500);
$this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
@@ -105,7 +105,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
*/
public function test_error_ext_disabled_or_404()
{
- $crawler = self::request('GET', 'app.php?controller=does/not/exist', array(), false);
+ $crawler = self::request('GET', 'app.php/does/not/exist', array(), false);
$this->assert_response_html(404);
$this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
}
diff --git a/tests/mock/auth_provider.php b/tests/mock/auth_provider.php
index 9d002334d6..a576ef6b67 100644
--- a/tests/mock/auth_provider.php
+++ b/tests/mock/auth_provider.php
@@ -10,14 +10,9 @@
/**
* Mock auth provider class with basic functions to help test sessions.
*/
-class phpbb_mock_auth_provider implements phpbb_auth_provider_interface
+class phpbb_mock_auth_provider extends phpbb_auth_provider_base
{
- function init()
- {
- return null;
- }
-
- function login($username, $password)
+ public function login($username, $password)
{
return array(
'status' => "",
@@ -25,29 +20,4 @@ class phpbb_mock_auth_provider implements phpbb_auth_provider_interface
'user_row' => "",
);
}
-
- function autologin()
- {
- return array();
- }
-
- function acp()
- {
- return array();
- }
-
- function logout($data, $new_session)
- {
- return null;
- }
-
- function validate_session($user)
- {
- return null;
- }
-
- public function get_acp_template($new_config)
- {
- return null;
- }
}
diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php
index ff7b890d11..a0dd8368cf 100644
--- a/tests/template/includephp_test.php
+++ b/tests/template/includephp_test.php
@@ -46,7 +46,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
$this->setup_engine(array('tpl_allow_php' => true));
- $this->style->set_custom_style('tests', $cache_dir, array(), '');
+ $this->template->set_custom_style('tests', $cache_dir);
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php");
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index d3b65e763a..4280a7e7ff 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -113,13 +113,10 @@ Zeta test event in all',
$config = new phpbb_config(array_merge($defaults, $new_config));
$this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template";
- $this->style_resource_locator = new phpbb_style_resource_locator();
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
dirname(__FILE__) . "/datasets/$dataset/"
);
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager);
- $this->style_provider = new phpbb_style_path_provider();
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
- $this->style->set_custom_style('silver', array($this->template_path), $style_names, '');
+ $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
}
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index b41193d59e..bd5d997c09 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -64,6 +64,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
),
array(
'if.html',
+ array('S_OTHER_OTHER_VALUE' => true),
+ array(),
+ array(),
+ '|S_OTHER_OTHER_VALUE|!false',
+ ),
+ array(
+ 'if.html',
array('S_VALUE' => false, 'S_OTHER_VALUE' => true),
array(),
array(),
@@ -151,7 +158,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
array(),
- "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?",
+ "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]",
),
array(
'define_advanced.html',
@@ -410,7 +417,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->setup_engine(array('tpl_allow_php' => true));
- $this->style->set_custom_style('tests', $cache_dir, array(), '');
+ $this->template->set_custom_style('tests', $cache_dir);
$this->run_template('php.html', array(), array(), array(), 'test');
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 6d87e5ebc0..91895502ad 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -11,11 +11,8 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_template_template_test_case extends phpbb_test_case
{
- protected $style;
protected $template;
protected $template_path;
- protected $style_resource_locator;
- protected $style_provider;
protected $user;
protected $test_path = 'tests/template';
@@ -67,11 +64,8 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->user = new phpbb_user;
$this->template_path = $this->test_path . '/templates';
- $this->style_resource_locator = new phpbb_style_resource_locator();
- $this->style_provider = new phpbb_style_path_provider();
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context());
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, $this->style_provider, $this->template);
- $this->style->set_custom_style('tests', $this->template_path, array(), '');
+ $this->template->set_custom_style('tests', $this->template_path);
}
protected function setUp()
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index 4b8cbada45..477192c28a 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -20,10 +20,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$this->template_path = $this->test_path . '/templates';
$this->parent_template_path = $this->test_path . '/parent_templates';
- $this->style_resource_locator = new phpbb_style_resource_locator();
- $this->style_provider = new phpbb_style_path_provider();
$this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context());
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
- $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), '');
+ $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
}
diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html
index a56fece912..8405ea55fb 100644
--- a/tests/template/templates/define.html
+++ b/tests/template/templates/define.html
@@ -23,3 +23,5 @@ $VALUE == 'abc'
{$VALUE}
<!-- DEFINE $VALUE = 'test!@#$%^&*()_-=+{}[]:;",<.>/?' -->
{$VALUE}
+<!-- DEFINE $VALUE = '' -->
+[{$VALUE}]
diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html
index c010aff7fa..f6ab6e575a 100644
--- a/tests/template/templates/if.html
+++ b/tests/template/templates/if.html
@@ -2,6 +2,8 @@
1
<!-- ELSEIF S_OTHER_VALUE -->
2
+<!-- ELSE IF S_OTHER_OTHER_VALUE -->
+|S_OTHER_OTHER_VALUE|
<!-- ELSE -->
03
<!-- ENDIF -->