1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-22 00:05:49 +02:00

Merge remote-tracking branch 'phpbb/develop' into ticket/9657

* phpbb/develop: (216 commits)
  [ticket/11626] Remove last reference to template in ldap
  [ticket/11626] Remove LDAP dependency on template
  [develop-olympus] Increment version number to 3.0.13-dev.
  [develop-olympus] Add changelog for 3.0.12 release.
  [develop-olympus] Bump version numbers for 3.0.12-RC1 release.
  [develop-olympus] Bumping version numbers to final for 3.0.12 releases.
  [ticket/11669] Fix PHP bug #55124 (recursive mkdir on /./)
  [ticket/11668] Run lint test at the end of the test suite
  [ticket/11548] Fix test errors in groups test on develop
  [ticket/11548] Check upload avatar URL the same way as in phpBB 3.0
  [ticket/11548] Fix incorrect usage of array_map on acp groups page
  [ticket/11665] Fix test class name
  [ticket/11664] Stop creating php.html file in root path in tests
  [ticket/11665] Can't change file names already sent to set_filenames
  [ticket/11662] Typos: occured -> occurred
  [ticket/11662] Typos: occured -> occurred
  [ticket/11660] Fix bugs from bugs in #11651 (missing vars, db->sql_connect)
  [feature/auth-refactor] Add parent::setUp() in setUp()
  [feature/auth-refactor] Changes
  [feature/auth-refactor] DataProvider for acp_board test
  ...
This commit is contained in:
Joas Schilling
2013-07-13 09:36:24 -04:00
122 changed files with 3601 additions and 2825 deletions

View File

@@ -0,0 +1,13 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
class phpbb_auth_provider_acp_board_invalid
{
}

View File

@@ -0,0 +1,16 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
class phpbb_auth_provider_acp_board_valid extends phpbb_auth_provider_base
{
public function login($username, $password)
{
return;
}
}

View File

@@ -0,0 +1,48 @@
<?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/acp/acp_board.php';
require_once dirname(__FILE__) . '/auth_provider/invalid.php';
require_once dirname(__FILE__) . '/auth_provider/valid.php';
class phpbb_acp_board_select_auth_method_test extends phpbb_test_case
{
protected $acp_board;
public static function select_auth_method_data()
{
return array(
array('acp_board_valid', '<option value="acp_board_valid" selected="selected">Acp_board_valid</option>'),
array('acp_board_invalid', '<option value="acp_board_valid">Acp_board_valid</option>'),
);
}
public function setUp()
{
parent::setUp();
global $phpbb_container;
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('auth.provider_collection', array(
'auth.provider.acp_board_valid' => new phpbb_auth_provider_acp_board_valid,
'auth.provider.acp_board_invalid' => new phpbb_auth_provider_acp_board_invalid,
));
$this->acp_board = new acp_board();
}
/**
* @dataProvider select_auth_method_data
*/
public function test_select_auth_method($selected, $expected)
{
$this->assertEquals($expected, $this->acp_board->select_auth_method($selected));
}
}

View File

@@ -45,15 +45,17 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
*/
public function test_helper_url($route, $params, $is_amp, $session_id, $expected, $description)
{
global $phpbb_dispatcher;
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($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, new phpbb_template_context());
$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');
$this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected);
}
}

View File

@@ -18,6 +18,11 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
{
$db = $this->new_dbal();
if (strpos($db->sql_layer, 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
{
$this->markTestSkipped('MySQL 5.6 fails to order things correctly. See also: http://tracker.phpbb.com/browse/PHPBB3-11571 http://bugs.mysql.com/bug.php?id=69005');
}
// http://tracker.phpbb.com/browse/PHPBB3-10507
// Test ORDER BY LOWER(style_name)
$db->sql_return_on_error(true);
@@ -58,7 +63,7 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
'style_parent_id' => 0,
'style_parent_tree' => '',
)
),
),
$db->sql_fetchrowset($result)
);
}

View File

@@ -40,11 +40,12 @@ class phpbb_di_container_test extends phpbb_test_case
public function test_phpbb_create_compiled_container()
{
$phpbb_root_path = __DIR__ . '/../../phpBB/';
$config_file = __DIR__ . '/fixtures/config.php';
$extensions = array(
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
new phpbb_di_extension_core($phpbb_root_path),
);
$container = phpbb_create_compiled_container($extensions, array(), $phpbb_root_path, 'php');
$container = phpbb_create_compiled_container($config_file, $extensions, array(), $phpbb_root_path, 'php');
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
$this->assertTrue($container->isFrozen());

View File

@@ -42,12 +42,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->user = new phpbb_user();
$this->table_prefix = 'phpbb_';
$this->template = new phpbb_template(
$this->template = new phpbb_template_twig(
$this->phpbb_root_path,
$this->phpEx,
$this->config,
$this->user,
new phpbb_style_resource_locator(),
new phpbb_template_context()
);

View File

@@ -36,6 +36,26 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
$this->add_lang(array('ucp', 'acp/groups'));
}
// Enable all avatars in the ACP
protected function enable_all_avatars()
{
$this->add_lang('acp/board');
$crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid);
// Check the default entries we should have
$this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text());
$this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text());
$this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text());
// Now start setting the needed settings
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$form['config[allow_avatar_local]']->select(1);
$form['config[allow_avatar_remote]']->select(1);
$form['config[allow_avatar_remote_upload]']->select(1);
$crawler = self::submit($form);
$this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text());
}
public function groups_manage_test_data()
{
return array(
@@ -60,4 +80,34 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
$crawler = self::submit($form);
$this->assertContains($this->lang($expected), $crawler->text());
}
public function group_avatar_min_max_data()
{
return array(
array('avatar_driver_upload', 'avatar_upload_url', 'foo', 'AVATAR_URL_INVALID'),
array('avatar_driver_upload', 'avatar_upload_url', 'foobar', 'AVATAR_URL_INVALID'),
array('avatar_driver_upload', 'avatar_upload_url', 'http://www.phpbb.com/' . str_repeat('f', 240) . '.png', 'TOO_LONG'),
array('avatar_driver_remote', 'avatar_remote_url', 'foo', 'AVATAR_URL_INVALID'),
array('avatar_driver_remote', 'avatar_remote_url', 'foobar', 'AVATAR_URL_INVALID'),
array('avatar_driver_remote', 'avatar_remote_url', 'http://www.phpbb.com/' . str_repeat('f', 240) . '.png', 'TOO_LONG'),
);
}
/**
* @dataProvider group_avatar_min_max_data
*/
public function test_group_avatar_min_max($avatar_type, $form_name, $input, $expected)
{
$this->login();
$this->admin_login();
$this->add_lang(array('ucp', 'acp/groups'));
$this->enable_all_avatars();
$crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$form['avatar_driver']->setValue($avatar_type);
$form[$form_name]->setValue($input);
$crawler = self::submit($form);
$this->assertContains($this->lang($expected), $crawler->text());
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_forum_style_test extends phpbb_functional_test_case
{
public function test_default_forum_style()
{
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
$this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1');
$this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
$this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
}
public function test_custom_forum_style()
{
$db = $this->get_db();
$this->add_style(2, 'test_style');
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2');
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
$this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1');
$this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
$this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2');
$this->delete_style(2, 'test_style');
}
}

View File

@@ -15,9 +15,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
$this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'includephp_relative.html.php';
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php", $cache_file);
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
@@ -27,9 +25,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
$this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'includephp_variables.html.php';
$this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php", $cache_file);
$this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_variables.html'));
$this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
@@ -37,11 +33,13 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
public function test_includephp_absolute()
{
$path_to_php = dirname(__FILE__) . '/templates/_dummy_include.php.inc';
global $phpbb_root_path;
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
$this->assertTrue(phpbb_is_absolute($path_to_php));
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
$cache_dir = dirname($this->template->cachepath) . '/';
$cache_dir = $phpbb_root_path . 'cache/';
$fp = fopen($cache_dir . 'includephp_absolute.html', 'w');
fputs($fp, $template_text);
fclose($fp);
@@ -49,9 +47,8 @@ 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(), '');
$cache_file = $this->template->cachepath . 'includephp_absolute.html.php';
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php", $cache_file);
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_absolute.html'));
$this->assertEquals("Path is absolute.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");

View File

@@ -1,87 +0,0 @@
<?php
/**
*
* @package testing
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__) . '/template_test_case.php';
class phpbb_template_invalid_constructs_test extends phpbb_template_template_test_case
{
public function template_data()
{
return array(
array(
'Unknown tag',
'invalid/unknown_tag.html',
array(),
array(),
array(),
'invalid/output/unknown_tag.html',
),
/*
* Produces a parse error which is fatal, therefore
* destroying the test suite.
array(
'ENDIF without IF',
'invalid/endif_without_if.html',
array(),
array(),
array(),
'invalid/output/endif_without_if.html',
),
*/
);
}
public function template_data_error()
{
return array(
array(
'Include a nonexistent file',
'invalid/include_nonexistent_file.html',
array(),
array(),
array(),
E_USER_ERROR,
'invalid/output/include_nonexistent_file.html',
),
);
}
/**
* @dataProvider template_data
*/
public function test_template($description, $file, $vars, $block_vars, $destroy, $expected)
{
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->assertFileNotExists($cache_file);
$expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected);
// apparently the template engine does not put
// the trailing newline into compiled templates
$expected = trim($expected);
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
}
/**
* @dataProvider template_data_error
*/
public function test_template_error($description, $file, $vars, $block_vars, $destroy, $error, $expected)
{
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->assertFileNotExists($cache_file);
$expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected);
// apparently the template engine does not put
// the trailing newline into compiled templates
$expected = trim($expected);
$this->setExpectedTriggerError($error, $expected);
$this->run_template($file, $vars, $block_vars, $destroy, '', $cache_file);
}
}

View File

@@ -1,31 +0,0 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
class phpbb_template_renderer_eval_test extends phpbb_test_case
{
public function test_eval()
{
$compiled_code = '<a href="<?php echo \'Test\'; ?>">';
$valid_code = '<a href="Test">';
$context = new phpbb_template_context();
$template = new phpbb_template_renderer_eval($compiled_code, NULL);
ob_start();
try
{
$template->render($context, array());
}
catch (Exception $exception)
{
ob_end_clean();
throw $exception;
}
$output = ob_get_clean();
$this->assertEquals($valid_code, $output);
}
}

View File

@@ -19,9 +19,7 @@ class phpbb_template_subdir_includephp_from_subdir_test extends phpbb_template_t
{
$this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'includephp_relative.html.php';
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php", $cache_file);
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");

View File

@@ -1,31 +0,0 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 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_template_template_compile_test extends phpbb_test_case
{
private $template_compile;
private $template_path;
protected function setUp()
{
$this->template_compile = new phpbb_template_compile(false, null, $this->style_resource_locator, '');
$this->template_path = dirname(__FILE__) . '/templates';
}
public function test_in_phpbb()
{
$output = $this->template_compile->compile_file($this->template_path . '/trivial.html');
$this->assertTrue(strlen($output) > 0);
$statements = explode(';', $output);
$first_statement = $statements[0];
$this->assertTrue(!!preg_match('#if.*defined.*IN_PHPBB.*exit#', $first_statement));
}
}

View File

@@ -54,11 +54,9 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
array(),
array(),
array(),
'Kappa test event in all
Omega test event in all
Zeta test event in all
Kappa test event in silver
Omega test event in silver',
'Kappa test event in silver
Omega test event in silver
Zeta test event in all',
),
array(
'Template event with inheritance - child',
@@ -68,10 +66,9 @@ Omega test event in silver',
array(),
array(),
array(),
'Kappa test event in all
Omega test event in all
Zeta test event in all
Kappa test event in silver_inherit',
'Kappa test event in silver_inherit
Omega test event in silver
Zeta test event in all',
),
array(
'Definition in parent style',
@@ -95,8 +92,7 @@ Kappa test event in silver_inherit',
$this->setup_engine_for_events($dataset, $style_names);
// Run test
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
$this->run_template($file, $vars, $block_vars, $destroy, $expected);
}
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
@@ -111,7 +107,7 @@ Kappa test event in silver_inherit',
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
dirname(__FILE__) . "/datasets/$dataset/"
);
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context, $this->extension_manager);
$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, '');

View File

@@ -0,0 +1,28 @@
<?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__) . '/template_test_case_with_tree.php';
class phpbb_template_template_includecss_test extends phpbb_template_template_test_case_with_tree
{
public function test_includecss_compilation()
{
// Reset the engine state
$this->setup_engine(array('assets_version' => 1));
// Prepare correct result
$scripts = array(
'<link href="' . $this->test_path . '/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
'<link href="' . $this->test_path . '/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
);
// Run test
$this->run_template('includecss.html', array(), array(), array(), implode('', $scripts));
}
}

View File

@@ -11,23 +11,97 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
class phpbb_template_template_includejs_test extends phpbb_template_template_test_case_with_tree
{
public function test_includejs_compilation()
public function template_data()
{
return array(
/*
array(
// vars
// expected
),
*/
array(
array('TEST' => 1),
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
),
array(
array('TEST' => 2),
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=0&assets_version=1"></script>',
),
array(
array('TEST' => 3),
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1&assets_version=0&assets_version=1"></script>',
),
array(
array('TEST' => 4),
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1&amp;assets_version=0&assets_version=1"></script>',
),
array(
array('TEST' => 5),
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1;assets_version=0&assets_version=1"></script>',
),
array(
array('TEST' => 6),
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 7),
'<script type="text/javascript" src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 8),
'<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 9),
'<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 10),
'<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
),
array(
array('TEST' => 11),
'<script type="text/javascript" src="' . $this->test_path . '/templates/child_only.js?test1=1&amp;test2=2&assets_version=1#test3"></script>',
),
array(
array('TEST' => 12),
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1&amp;test2=2&assets_version=1#test3"></script>',
),
array(
array('TEST' => 13),
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1;test2=2&assets_version=1#test3"></script>',
),
array(
array('TEST' => 14),
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=&quot;&assets_version=1#test3"></script>',
),
array(
array('TEST' => 15),
'<script type="text/javascript" src="http://phpbb.com/b.js?c=d#f"></script>',
),
array(
array('TEST' => 16),
'<script type="text/javascript" src="http://phpbb.com/b.js?c=d&assets_version=1#f"></script>',
),
array(
array('TEST' => 17),
'<script type="text/javascript" src="//phpbb.com/b.js"></script>',
),
);
}
/**
* @dataProvider template_data
*/
public function test_includejs_compilation($vars, $expected)
{
// Reset the engine state
$this->setup_engine(array('assets_version' => 1));
// Prepare correct result
$scripts = array(
'<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
);
$this->template->assign_vars($vars);
// Run test
$cache_file = $this->template->cachepath . 'includejs.html.php';
$this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file);
$this->run_template('includejs.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected);
}
}

View File

@@ -50,15 +50,6 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t
*/
public function test_template($name, $file, array $vars, array $block_vars, array $destroy, $expected)
{
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->assertFileNotExists($cache_file);
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
// Reset the engine state
$this->setup_engine();
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
$this->run_template($file, $vars, $block_vars, $destroy, $expected);
}
}

View File

@@ -1,68 +0,0 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
class phpbb_template_template_locate_test extends phpbb_template_template_test_case_with_tree
{
public function template_data()
{
return array(
// First element of the array is test name - keep them distinct
array(
'simple inheritance - only parent template exists',
$this->test_path . '/parent_templates/parent_only.html',
'parent_only.html',
false,
true,
),
array(
'simple inheritance - only child template exists',
$this->test_path . '/templates/child_only.html',
'child_only.html',
false,
true,
),
array(
'simple inheritance - both parent and child templates exist',
$this->test_path . '/templates/parent_and_child.html',
'parent_and_child.html',
false,
true,
),
array(
'find first template - only child template exists in main style',
'child_only.html',
array('parent_only.html', 'child_only.html'),
false,
false,
),
array(
'find first template - both templates exist in main style',
'parent_and_child.html',
array('parent_and_child.html', 'child_only.html'),
false,
false,
),
);
}
/**
* @dataProvider template_data
*/
public function test_template($name, $expected, $files, $return_default, $return_full_path)
{
// Reset the engine state
$this->setup_engine();
// Locate template
$result = $this->style_resource_locator->get_first_template_location($files, $return_default, $return_full_path);
$this->assertSame($expected, $result);
}
}

View File

@@ -0,0 +1,29 @@
<?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';
require_once dirname(__FILE__) . '/template_test_case.php';
class phpbb_template_template_parser_test extends phpbb_template_template_test_case
{
public function test_set_filenames()
{
$this->template->set_filenames(array(
'basic' => 'basic.html',
));
$this->assertEquals("passpasspass<!-- DUMMY var -->", str_replace(array("\n", "\r", "\t"), '', $this->template->assign_display('basic')));
$this->template->set_filenames(array(
'basic' => 'if.html',
));
$this->assertEquals("03!false", str_replace(array("\n", "\r", "\t"), '', $this->template->assign_display('basic')));
}
}

View File

@@ -1,87 +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__) . '/template_test_case.php';
class phpbb_template_template_spacing_test extends phpbb_template_template_test_case
{
public function template_data()
{
return array(
/*
array(
'', // Description
'', // dataset
array(), // style names
'', // file
array(), // vars
array(), // block vars
array(), // destroy
'', // expected result
),
*/
array(
'Spacing in templates',
'ext_trivial',
array(),
'variable_spacing.html',
array(
'VARIABLE' => '{}',
),
array(),
array(),
'|{}|
{}|{}|
|{}
<div class="{}">test</div>',
),
);
}
/**
* @dataProvider template_data
*/
public function test_template($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected)
{
// Run test
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
}
/**
* @dataProvider template_data
*/
public function test_event($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected)
{
// Reset the engine state
$this->setup_engine_for_events($dataset, $style_names);
// Run test
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
}
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
{
global $phpbb_root_path, $phpEx, $user;
$defaults = $this->config_defaults();
$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($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, 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, '');
}
}

View File

@@ -46,28 +46,42 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
'03',
'03!false',
),
array(
'if.html',
array('S_VALUE' => true),
array(),
array(),
'1',
'1!false',
),
array(
'if.html',
array('S_VALUE' => true, 'S_OTHER_VALUE' => true),
array(),
array(),
'1',
'1!false',
),
array(
'if.html',
array('S_VALUE' => false, 'S_OTHER_VALUE' => true),
array(),
array(),
'2',
'2!false',
),
array(
'if.html',
array('S_TEST' => false),
array(),
array(),
'03false',
),
array(
'if.html',
array('S_TEST' => 0),
array(),
array(),
'03!false',
),
array(
'loop.html',
@@ -116,7 +130,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())),
array(),
"first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner\ninner loop",
"first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner",
),
array(
'loop_advanced.html',
@@ -125,6 +139,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
"101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
),
array(
'loop_nested2.html',
array(),
array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())),
array(),
"o0o1m01m11",
),
array(
'define.html',
array(),
@@ -139,13 +160,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
"abc\nzxc\ncde\nbcd",
),
array(
'define_unclosed.html',
array(),
array(),
array(),
"test",
),
array(
'expressions.html',
array(),
@@ -247,21 +261,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
"{ VARIABLE }\n{ 1_VARIABLE }\n{ VARIABLE }\n{ 1_VARIABLE }",
"VARIABLE\n1_VARIABLE\nVARIABLE\n1_VARIABLE",
),
array(
'lang.html',
array('L_VARIABLE' => "Value'", 'L_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
array(),
"Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
),
array(
'lang.html',
array('LA_VARIABLE' => "Value'", 'LA_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
"{ VARIABLE }\n{ 1_VARIABLE }\nValue'\n1 O'Clock",
array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"),
),
array(
'loop_nested_multilevel_ref.html',
@@ -275,7 +283,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
array(),
// I don't completely understand this output, hopefully it's correct
"top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
),
array(
@@ -283,7 +290,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
array(),
// I don't completely understand this output, hopefully it's correct
"top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
),
array(
@@ -303,6 +309,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"a\nb\nc\nd",
),
*/
array(
'twig.html',
array('VARIABLE' => 'FOObar',),
array(),
array(),
"13FOOBAR|foobar",
),
);
}
@@ -313,24 +326,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->template->set_filenames(array('test' => $filename));
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
$expecting = sprintf('style resource locator: File for handle test does not exist. Could not find: %s', $this->test_path . '/templates/' . $filename);
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
$this->setExpectedException('Twig_Error_Loader');
$this->display('test');
}
public function test_empty_file()
{
$expecting = 'style resource locator: set_filenames: Empty filename specified for test';
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
$this->template->set_filenames(array('test' => ''));
}
public function test_invalid_handle()
{
$expecting = 'No file specified for handle test';
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
$this->setExpectedException('Twig_Error_Loader');
$this->display('test');
}
@@ -338,49 +342,23 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
/**
* @dataProvider template_data
*/
public function test_template($file, array $vars, array $block_vars, array $destroy, $expected)
public function test_template($file, array $vars, array $block_vars, array $destroy, $expected, $lang_vars = array())
{
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->assertFileNotExists($cache_file);
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
// Reset the engine state
$this->setup_engine();
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $lang_vars);
}
/**
* @dataProvider template_data
*/
public function test_assign_display($file, array $vars, array $block_vars, array $destroy, $expected)
public function test_assign_display()
{
$this->run_template('basic.html', array(), array(), array(), "pass\npass\npass\n<!-- DUMMY var -->");
$this->template->set_filenames(array(
'test' => $file,
'container' => 'variable.html',
'test' => 'basic.html',
'container' => 'variable.html',
));
$this->template->assign_vars($vars);
foreach ($block_vars as $block => $loops)
{
foreach ($loops as $_vars)
{
$this->template->assign_block_vars($block, $_vars);
}
}
foreach ($destroy as $block)
{
$this->template->destroy_block_vars($block);
}
$this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)");
$this->template->assign_display('test', 'VARIABLE', false);
$this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)");
$this->assertEquals("pass\npass\npass\n<!-- DUMMY var -->", $this->display('container'), "Testing assign_display($file)");
}
public function test_append_var_without_assign_var()
@@ -391,7 +369,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$items = array('This ', 'is ', 'a ', 'test');
$expecting = implode('', $items);
foreach ($items as $word)
{
$this->template->append_var('VARIABLE', $word);
@@ -409,7 +387,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$start = 'This ';
$items = array('is ', 'a ', 'test');
$expecting = $start . implode('', $items);
$this->template->assign_var('VARIABLE', $start);
foreach ($items as $word)
{
@@ -421,13 +399,20 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
public function test_php()
{
global $phpbb_root_path;
$template_text = '<!-- PHP -->echo "test";<!-- ENDPHP -->';
$cache_dir = $phpbb_root_path . 'cache/';
$fp = fopen($cache_dir . 'php.html', 'w');
fputs($fp, $template_text);
fclose($fp);
$this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'php.html.php';
$this->style->set_custom_style('tests', $cache_dir, array(), '');
$this->assertFileNotExists($cache_file);
$this->run_template('php.html', array(), array(), array(), 'test', $cache_file);
$this->run_template('php.html', array(), array(), array(), 'test');
}
public function alter_block_array_data()
@@ -533,10 +518,40 @@ EOT
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$this->assertEquals("outer - 0\nmiddle - 0\nmiddle - 1\nouter - 1\nmiddle - 0\nmiddle - 1\nouter - 2\nmiddle - 0\nmiddle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->assertEquals("outer - 0middle - 0middle - 1outer - 1middle - 0middle - 1outer - 2middle - 0middle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->template->alter_block_array($alter_block, $vararray, $key, $mode);
$this->assertEquals($expect, $this->display('test'), $description);
$this->assertEquals(str_replace(array("\n", "\r", "\t"), '', $expect), str_replace(array("\n", "\r", "\t"), '', $this->display('test')), $description);
}
public function test_more_alter_block_array()
{
$this->template->set_filenames(array('test' => 'loop_nested.html'));
$this->template->assign_var('TEST_MORE', true);
// @todo Change this
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$expect = 'outer - 0[outer|3]middle - 0[middle|1]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification');
$this->template->alter_block_array('outer', array());
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after insertion');
$this->template->alter_block_array('outer', array('VARIABLE' => 'test'), 2, 'change');
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
}
}

View File

@@ -16,6 +16,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected $template_path;
protected $style_resource_locator;
protected $style_provider;
protected $user;
protected $test_path = 'tests/template';
@@ -28,11 +29,11 @@ class phpbb_template_template_test_case extends phpbb_test_case
try
{
$this->assertTrue($this->template->display($handle, false));
$this->template->display($handle, false);
}
catch (Exception $exception)
{
// reset output buffering even when an error occured
// reset output buffering even when an error occurred
// PHPUnit turns trigger_error into exceptions as well
ob_end_clean();
throw $exception;
@@ -59,16 +60,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected function setup_engine(array $new_config = array())
{
global $phpbb_root_path, $phpEx, $user;
global $phpbb_root_path, $phpEx;
$defaults = $this->config_defaults();
$config = new phpbb_config(array_merge($defaults, $new_config));
$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($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, 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->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(), '');
}
@@ -77,43 +79,18 @@ class phpbb_template_template_test_case extends phpbb_test_case
// Test the engine can be used
$this->setup_engine();
$template_cache_dir = dirname($this->template->cachepath);
if (!is_writable($template_cache_dir))
{
$this->markTestSkipped("Template cache directory ({$template_cache_dir}) is not writable.");
}
$file_array = scandir($template_cache_dir);
$file_prefix = basename($this->template->cachepath);
foreach ($file_array as $file)
{
if (strpos($file, $file_prefix) === 0)
{
unlink($template_cache_dir . '/' . $file);
}
}
$this->setup_engine();
$this->template->clear_cache();
}
protected function tearDown()
{
if (is_object($this->template))
if ($this->template)
{
$template_cache_dir = dirname($this->template->cachepath);
$file_array = scandir($template_cache_dir);
$file_prefix = basename($this->template->cachepath);
foreach ($file_array as $file)
{
if (strpos($file, $file_prefix) === 0)
{
unlink($template_cache_dir . '/' . $file);
}
}
$this->template->clear_cache();
}
}
protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file)
protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $lang_vars = array())
{
$this->template->set_filenames(array('test' => $file));
$this->template->assign_vars($vars);
@@ -131,25 +108,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->template->destroy_block_vars($block);
}
try
// Previous functionality was $cachefile (string), which was removed, check to prevent errors
if (is_array($lang_vars))
{
$this->assertEquals($expected, $this->display('test'), "Testing $file");
$this->assertFileExists($cache_file);
}
catch (ErrorException $e)
{
if (file_exists($cache_file))
foreach ($lang_vars as $name => $value)
{
copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
$this->user->lang[$name] = $value;
}
throw $e;
}
// For debugging.
// When testing eval path the cache file may not exist.
if (self::PRESERVE_CACHE && file_exists($cache_file))
{
copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
}
$expected = str_replace(array("\n", "\r", "\t"), '', $expected);
$output = str_replace(array("\n", "\r", "\t"), '', $this->display('test'));
$this->assertEquals($expected, $output, "Testing $file");
}
}

View File

@@ -22,7 +22,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$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($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
$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(), '');
}

View File

View File

@@ -1,2 +0,0 @@
<!-- DEFINE $VALUE -->
test

View File

@@ -9,3 +9,11 @@
<!-- IF S_VALUE and S_OTHER_VALUE and (S_VALUE > S_OTHER_VALUE) -->
04
<!-- ENDIF -->
<!-- IF S_TEST === false -->
false
<!-- ENDIF -->
<!-- IF S_TEST !== false -->
!false
<!-- ENDIF -->

View File

@@ -0,0 +1,3 @@
<!-- INCLUDECSS child_only.css -->
<!-- INCLUDECSS parent_only.css -->
{$STYLESHEETS}

View File

@@ -1,8 +1,38 @@
<!-- INCLUDEJS parent_and_child.js -->
<!-- INCLUDEJS {PARENT} -->
<!-- DEFINE $TEST = 'child_only.js' -->
<!-- INCLUDEJS {$TEST} -->
<!-- INCLUDEJS subdir/{PARENT} -->
<!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
{SCRIPTS}
<!-- IF TEST === 1 -->
<!-- INCLUDEJS parent_and_child.js -->
<!-- ELSEIF TEST === 2 -->
<!-- INCLUDEJS parent_and_child.js?assets_version=0 -->
<!-- ELSEIF TEST === 3 -->
<!-- INCLUDEJS parent_and_child.js?test=1&assets_version=0 -->
<!-- ELSEIF TEST === 4 -->
<!-- INCLUDEJS parent_and_child.js?test=1&amp;assets_version=0 -->
<!-- ELSEIF TEST === 5 -->
<!-- INCLUDEJS parent_and_child.js?test=1;assets_version=0 -->
<!-- ELSEIF TEST === 6 -->
<!-- INCLUDEJS {PARENT} -->
<!-- ELSEIF TEST === 7 -->
<!-- DEFINE $TEST = 'child_only.js' -->
<!-- INCLUDEJS {$TEST} -->
<!-- ELSEIF TEST === 8 -->
<!-- INCLUDEJS subdir/{PARENT} -->
<!-- ELSEIF TEST === 9 -->
<!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
<!-- ELSEIF TEST === 10 -->
<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
<!-- ELSEIF TEST === 11 -->
<!-- DEFINE $TEST = 'child_only.js?test1=1&amp;test2=2#test3' -->
<!-- INCLUDEJS {$TEST} -->
<!-- ELSEIF TEST === 12 -->
<!-- INCLUDEJS parent_only.js?test1=1&amp;test2=2#test3 -->
<!-- ELSEIF TEST === 13 -->
<!-- INCLUDEJS parent_only.js?test1=1;test2=2#test3 -->
<!-- ELSEIF TEST === 14 -->
<!-- INCLUDEJS parent_only.js?test1=&quot;#test3 -->
<!-- ELSEIF TEST === 15 -->
<!-- INCLUDEJS http://phpbb.com/b.js?c=d#f -->
<!-- ELSEIF TEST === 16 -->
<!-- INCLUDEJS http://phpbb.com/b.js?c=d&assets_version=1#f -->
<!-- ELSEIF TEST === 17 -->
<!-- INCLUDEJS //phpbb.com/b.js -->
<!-- ENDIF -->
{$SCRIPTS}

View File

@@ -1 +0,0 @@
<!-- INCLUDE nonexistent.html -->

View File

@@ -1 +0,0 @@
<!-- UNKNOWNTAG variable.html -->

View File

@@ -1,6 +1,6 @@
<!-- BEGIN outer -->
outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
<!-- BEGIN middle -->
middle - {middle.S_ROW_COUNT}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
<!-- END middle -->
outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.S_BLOCK_NAME}|{outer.S_NUM_ROWS}]<!-- ENDIF -->
<!-- BEGIN middle -->
middle - {outer.middle.S_ROW_COUNT}<!-- IF outer.middle.VARIABLE --> - {outer.middle.VARIABLE}<!-- ENDIF --><!-- IF TEST_MORE -->[{outer.middle.S_BLOCK_NAME}|{outer.middle.S_NUM_ROWS}]<!-- ENDIF -->
<!-- END middle -->
<!-- END outer -->

View File

@@ -0,0 +1,6 @@
<!-- BEGIN outer -->
o{outer.S_ROW_COUNT}
<!-- BEGIN middle -->
m{outer.middle.S_ROW_COUNT}{outer.S_ROW_COUNT}
<!-- END middle -->
<!-- END outer -->

View File

@@ -36,4 +36,4 @@
<!-- BEGIN loop -->
in loop
<!-- END -->
<!-- END loop -->

View File

@@ -2,7 +2,7 @@
loop
<!-- BEGINELSE -->
noloop
<!-- END loop -->
<!-- END _underscore_loop -->
<!-- IF ._underscore_loop -->
loop

View File

@@ -11,4 +11,3 @@ last
<!-- IF inner.S_LAST_ROW and inner.S_ROW_COUNT and inner.S_NUM_ROWS -->last inner<!-- ENDIF -->
<!-- END inner -->
<!-- END loop -->
<!-- IF .loop.inner -->inner loop<!-- ENDIF -->

View File

@@ -0,0 +1,6 @@
<!-- EXTENDS "twig_parent.html" -->
<!-- BLOCK overwritten -->
3{VARIABLE|upper}|{VARIABLE|lower}
<!-- ENDBLOCK -->

View File

@@ -0,0 +1,7 @@
<!-- BLOCK notoverwritten -->
1
<!-- ENDBLOCK -->
<!-- BLOCK overwritten -->
2
<!-- ENDBLOCK -->

View File

@@ -357,6 +357,109 @@ class phpbb_functional_test_case extends phpbb_test_case
$db_conn_mgr->recreate_db();
}
/**
* Creates a new style
*
* @param string $style_id Style ID
* @param string $style_path Style directory
* @param string $parent_style_id Parent style id. Default = 1
* @param string $parent_style_path Parent style directory. Default = 'prosilver'
*/
protected function add_style($style_id, $style_path, $parent_style_id = 1, $parent_style_path = 'prosilver')
{
global $phpbb_root_path;
$db = $this->get_db();
if (version_compare(PHPBB_VERSION, '3.1.0-dev', '<'))
{
$sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'style_id' => $style_id,
'style_name' => $style_path,
'style_copyright' => '',
'style_active' => 1,
'template_id' => $style_id,
'theme_id' => $style_id,
'imageset_id' => $style_id,
));
$db->sql_query($sql);
$sql = 'INSERT INTO ' . STYLES_IMAGESET_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'imageset_id' => $style_id,
'imageset_name' => $style_path,
'imageset_copyright' => '',
'imageset_path' => $style_path,
));
$db->sql_query($sql);
$sql = 'INSERT INTO ' . STYLES_TEMPLATE_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'template_id' => $style_id,
'template_name' => $style_path,
'template_copyright' => '',
'template_path' => $style_path,
'bbcode_bitfield' => 'kNg=',
'template_inherits_id' => $parent_style_id,
'template_inherit_path' => $parent_style_path,
));
$db->sql_query($sql);
$sql = 'INSERT INTO ' . STYLES_THEME_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'theme_id' => $style_id,
'theme_name' => $style_path,
'theme_copyright' => '',
'theme_path' => $style_path,
'theme_storedb' => 0,
'theme_mtime' => 0,
'theme_data' => '',
));
$db->sql_query($sql);
if ($style_path != 'prosilver' && $style_path != 'subsilver2')
{
@mkdir($phpbb_root_path . 'styles/' . $style_path, 0777);
@mkdir($phpbb_root_path . 'styles/' . $style_path . '/template', 0777);
}
}
else
{
$db->sql_multi_insert(STYLES_TABLE, array(
'style_id' => $style_id,
'style_name' => $style_path,
'style_copyright' => '',
'style_active' => 1,
'style_path' => $style_path,
'bbcode_bitfield' => 'kNg=',
'style_parent_id' => $parent_style_id,
'style_parent_tree' => $parent_style_path,
));
}
}
/**
* Remove temporary style created by add_style()
*
* @param string $style_id Style ID
* @param string $style_path Style directory
*/
protected function delete_style($style_id, $style_path)
{
global $phpbb_root_path;
$db = $this->get_db();
$db->sql_query('DELETE FROM ' . STYLES_TABLE . ' WHERE style_id = ' . $style_id);
if (version_compare(PHPBB_VERSION, '3.1.0-dev', '<'))
{
$db->sql_query('DELETE FROM ' . STYLES_IMAGESET_TABLE . ' WHERE imageset_id = ' . $style_id);
$db->sql_query('DELETE FROM ' . STYLES_TEMPLATE_TABLE . ' WHERE template_id = ' . $style_id);
$db->sql_query('DELETE FROM ' . STYLES_THEME_TABLE . ' WHERE theme_id = ' . $style_id);
if ($style_path != 'prosilver' && $style_path != 'subsilver2')
{
@rmdir($phpbb_root_path . 'styles/' . $style_path . '/template');
@rmdir($phpbb_root_path . 'styles/' . $style_path);
}
}
}
/**
* Creates a new user with limited permissions
*

View File

@@ -94,6 +94,9 @@ class phpbb_test_case_helpers
public function makedirs($path)
{
// PHP bug #55124 (fixed in 5.4.0)
$path = str_replace('/./', '/', $path);
mkdir($path, 0777, true);
}