2012-04-01 14:27:21 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
2014-05-27 20:18:06 +02:00
|
|
|
* This file is part of the phpBB Forum Software package.
|
|
|
|
*
|
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see
|
|
|
|
* the docs/CREDITS.txt file.
|
2012-04-01 14:27:21 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/template_test_case.php';
|
|
|
|
|
|
|
|
class phpbb_template_template_events_test extends phpbb_template_template_test_case
|
|
|
|
{
|
2012-05-11 13:46:04 -04:00
|
|
|
public function template_data()
|
2012-04-01 14:27:21 +03:00
|
|
|
{
|
2012-05-11 13:46:04 -04:00
|
|
|
return array(
|
|
|
|
/*
|
|
|
|
array(
|
2013-04-25 14:13:21 -05:00
|
|
|
'', // Description
|
2012-11-08 20:38:01 -05:00
|
|
|
'', // dataset
|
|
|
|
array(), // style names
|
2013-04-25 14:13:21 -05:00
|
|
|
'', // file
|
2012-05-11 13:46:04 -04:00
|
|
|
array(), // vars
|
|
|
|
array(), // block vars
|
|
|
|
array(), // destroy
|
2012-11-08 20:38:01 -05:00
|
|
|
'', // expected result
|
2012-05-11 13:46:04 -04:00
|
|
|
),
|
|
|
|
*/
|
|
|
|
array(
|
|
|
|
'Simple template event',
|
2012-11-08 20:17:44 -05:00
|
|
|
'ext_trivial',
|
2012-11-08 20:38:01 -05:00
|
|
|
array(),
|
2012-05-11 13:46:04 -04:00
|
|
|
'event_simple.html',
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
"Simple in trivial extension.",
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Universal template event ("all" style)',
|
2012-11-08 20:17:44 -05:00
|
|
|
'ext_trivial',
|
2012-11-08 20:38:01 -05:00
|
|
|
array(),
|
2012-05-11 13:46:04 -04:00
|
|
|
'event_universal.html',
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
"Universal in trivial extension.",
|
|
|
|
),
|
2012-11-08 20:38:01 -05:00
|
|
|
array(
|
|
|
|
'Template event with inheritance - parent',
|
|
|
|
'event_inheritance',
|
|
|
|
array('silver'),
|
|
|
|
'event_test.html',
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
array(),
|
2013-06-25 19:22:23 -05:00
|
|
|
'Kappa test event in silver
|
|
|
|
Omega test event in silver
|
|
|
|
Zeta test event in all',
|
2012-11-08 20:38:01 -05:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Template event with inheritance - child',
|
|
|
|
'event_inheritance',
|
|
|
|
array('silver_inherit', 'silver'),
|
|
|
|
'event_test.html',
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
array(),
|
2013-06-25 19:22:23 -05:00
|
|
|
'Kappa test event in silver_inherit
|
|
|
|
Omega test event in silver
|
|
|
|
Zeta test event in all',
|
2012-11-08 20:38:01 -05:00
|
|
|
),
|
2012-11-08 20:53:24 -05:00
|
|
|
array(
|
|
|
|
'Definition in parent style',
|
|
|
|
'event_inheritance',
|
|
|
|
array('silver_inherit', 'silver'),
|
|
|
|
'event_two.html',
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
array(),
|
|
|
|
'two in silver in omega',
|
|
|
|
),
|
2013-07-19 13:25:53 -05:00
|
|
|
array(
|
|
|
|
'EVENT in loop',
|
|
|
|
'ext_trivial',
|
|
|
|
array('silver'),
|
|
|
|
'event_loop.html',
|
|
|
|
array(),
|
|
|
|
array('event_loop' => array(array(), array(), array())),
|
|
|
|
array(),
|
|
|
|
'event_loop0|event_loop1|event_loop2',
|
|
|
|
),
|
2014-04-10 16:06:00 +02:00
|
|
|
array(
|
|
|
|
'EVENT with subloop in loop',
|
|
|
|
'ext_trivial',
|
|
|
|
array('silver'),
|
|
|
|
'event_subloop.html',
|
|
|
|
array(),
|
|
|
|
array(
|
|
|
|
'event_loop' => array(array()),
|
|
|
|
'event_loop.subloop' => array(array()),
|
|
|
|
),
|
|
|
|
array(),
|
|
|
|
'event_loop[0[subloop:0]]',
|
|
|
|
),
|
2012-05-11 13:46:04 -04:00
|
|
|
);
|
2012-05-11 13:39:38 -04:00
|
|
|
}
|
|
|
|
|
2012-05-11 13:46:04 -04:00
|
|
|
/**
|
|
|
|
* @dataProvider template_data
|
|
|
|
*/
|
2014-04-14 18:56:34 +02:00
|
|
|
public function test_event($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected, $incomplete_message = '')
|
2012-05-11 13:39:38 -04:00
|
|
|
{
|
2014-04-14 18:56:34 +02:00
|
|
|
if ($incomplete_message)
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete($incomplete_message);
|
|
|
|
}
|
|
|
|
|
2012-05-11 13:39:38 -04:00
|
|
|
// Reset the engine state
|
2012-11-08 20:38:01 -05:00
|
|
|
$this->setup_engine_for_events($dataset, $style_names);
|
2012-05-11 13:39:38 -04:00
|
|
|
|
|
|
|
// Run test
|
2013-06-25 19:22:23 -05:00
|
|
|
$this->run_template($file, $vars, $block_vars, $destroy, $expected);
|
2012-04-01 14:27:21 +03:00
|
|
|
}
|
|
|
|
|
2012-11-08 20:38:01 -05:00
|
|
|
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
|
2012-04-01 14:27:21 +03:00
|
|
|
{
|
|
|
|
global $phpbb_root_path, $phpEx, $user;
|
|
|
|
|
|
|
|
$defaults = $this->config_defaults();
|
2013-09-10 14:01:09 +02:00
|
|
|
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
|
2012-04-01 14:27:21 +03:00
|
|
|
|
2012-11-08 20:31:12 -05:00
|
|
|
$this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template";
|
2012-11-08 20:17:44 -05:00
|
|
|
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
|
|
|
|
dirname(__FILE__) . "/datasets/$dataset/"
|
2012-05-11 13:39:38 -04:00
|
|
|
);
|
2013-09-26 15:34:44 +02:00
|
|
|
$path_helper = new \phpbb\path_helper(
|
2013-09-17 17:12:41 +02:00
|
|
|
new \phpbb\symfony_request(
|
2013-09-13 10:58:03 -05:00
|
|
|
new phpbb_mock_request()
|
|
|
|
),
|
2013-09-26 15:34:44 +02:00
|
|
|
new \phpbb\filesystem(),
|
2014-04-21 19:53:46 +02:00
|
|
|
$this->getMock('\phpbb\request\request'),
|
2013-09-13 10:58:03 -05:00
|
|
|
$phpbb_root_path,
|
|
|
|
$phpEx
|
|
|
|
);
|
2013-09-26 15:34:44 +02:00
|
|
|
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager);
|
2013-07-24 13:25:20 -05:00
|
|
|
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
|
2012-04-01 14:27:21 +03:00
|
|
|
}
|
|
|
|
}
|