diff --git a/acp/main_info.php b/acp/main_info.php
index 8520446..bc55667 100644
--- a/acp/main_info.php
+++ b/acp/main_info.php
@@ -1,28 +1,32 @@
'\acme\demo\acp\main_module',
'title' => 'ACP_DEMO_TITLE',
- 'modes' => array(
- 'settings' => array(
+ 'modes' => [
+ 'settings' => [
'title' => 'ACP_DEMO',
'auth' => 'ext_acme/demo && acl_a_board',
- 'cat' => array('ACP_DEMO_TITLE')
- ),
- ),
- );
+ 'cat' => ['ACP_DEMO_TITLE'],
+ ],
+ ],
+ ];
}
}
diff --git a/acp/main_module.php b/acp/main_module.php
index 3eb9bfb..5dacf69 100644
--- a/acp/main_module.php
+++ b/acp/main_module.php
@@ -1,42 +1,48 @@
add_lang('acp/common');
- $this->tpl_name = 'demo_body';
- $this->page_title = $user->lang('ACP_DEMO_TITLE');
- add_form_key('acme/demo');
+ /** @var \acme\demo\controller\acp_controller $acp_controller */
+ $acp_controller = $phpbb_container->get('acme.demo.controller.acp');
- if ($request->is_set_post('submit'))
- {
- if (!check_form_key('acme/demo'))
- {
- trigger_error('FORM_INVALID');
- }
+ // Load a template from adm/style for our ACP page
+ $this->tpl_name = 'acp_demo_body';
- $config->set('acme_demo_goodbye', $request->variable('acme_demo_goodbye', 0));
+ // Set the page title for our ACP page
+ $this->page_title = 'ACP_DEMO_TITLE';
- trigger_error($user->lang('ACP_DEMO_SETTING_SAVED') . adm_back_link($this->u_action));
- }
+ // Make the $u_action url available in our ACP controller
+ $acp_controller->set_page_url($this->u_action);
- $template->assign_vars(array(
- 'U_ACTION' => $this->u_action,
- 'ACME_DEMO_GOODBYE' => $config['acme_demo_goodbye'],
- ));
+ // Load the display options handle in our ACP controller
+ $acp_controller->display_options();
}
}
diff --git a/adm/style/acp_demo_body.html b/adm/style/acp_demo_body.html
new file mode 100644
index 0000000..7aa0732
--- /dev/null
+++ b/adm/style/acp_demo_body.html
@@ -0,0 +1,33 @@
+{% include 'overall_header.html' %}
+
+
{{ lang('ACP_DEMO_TITLE') }}
+
+{% if S_ERROR %}
+
+
{{ lang('WARNING') }}
+
{{ ERROR_MSG }}
+
+{% endif %}
+
+
+
+{% include 'overall_footer.html' %}
diff --git a/adm/style/demo_body.html b/adm/style/demo_body.html
deleted file mode 100644
index 393aa0d..0000000
--- a/adm/style/demo_body.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-{L_SETTINGS}
-
-
-
-
diff --git a/composer.json b/composer.json
index d267dec..8f16f26 100644
--- a/composer.json
+++ b/composer.json
@@ -1,28 +1,27 @@
{
"name": "acme/demo",
"type": "phpbb-extension",
- "description": "Acme Demo Extension for phpBB 3.1",
+ "description": "Acme Demo Extension for phpBB 3.3",
"homepage": "https://github.com/phpbb/phpbb-ext-acme-demo",
- "version": "0.1.0",
+ "version": "0.2.0",
"time": "2013-11-05",
- "license": "GPL-2.0",
- "authors": [{
+ "license": "GPL-2.0-only",
+ "authors": [
+ {
"name": "Joas Schilling",
"email": "nickvergessen@gmx.de",
"homepage": "https://github.com/nickvergessen/",
"role": "Lead Developer"
- }],
+ }
+ ],
"require": {
- "php": ">=5.3.3",
- "composer/installers": "~1.0"
- },
- "require-dev": {
- "phpbb/epv": "dev-master"
+ "php": ">=7.2",
+ "composer/installers": "^1.0 || ^2.0"
},
"extra": {
"display-name": "Acme Demo Extension",
"soft-require": {
- "phpbb/phpbb": ">=3.1.0-RC2,<3.2@dev"
+ "phpbb/phpbb": ">=3.3.0"
}
}
}
diff --git a/config/parameters.yml b/config/parameters.yml
new file mode 100644
index 0000000..280c280
--- /dev/null
+++ b/config/parameters.yml
@@ -0,0 +1,2 @@
+parameters:
+ acme.demo.tables.demo_table: '%core.table_prefix%acme_demo_table'
diff --git a/config/routing.yml b/config/routing.yml
index 6f81992..0fa5356 100644
--- a/config/routing.yml
+++ b/config/routing.yml
@@ -1,3 +1,3 @@
acme_demo_controller:
path: /demo/{name}
- defaults: { _controller: acme.demo.controller:handle }
+ defaults: { _controller: acme.demo.controller.main:handle }
diff --git a/config/services.yml b/config/services.yml
index 046a393..f36715e 100644
--- a/config/services.yml
+++ b/config/services.yml
@@ -1,15 +1,37 @@
+imports:
+ - { resource: parameters.yml }
+
services:
- acme.demo.controller:
- class: acme\demo\controller\main
+ acme.demo.controller.main:
+ class: acme\demo\controller\main_controller
arguments:
- '@config'
- '@controller.helper'
- '@template'
+ - '@language'
+
+ acme.demo.controller.acp:
+ class: acme\demo\controller\acp_controller
+ arguments:
+ - '@config'
+ - '@language'
+ - '@log'
+ - '@request'
+ - '@template'
+ - '@user'
+
+ acme.demo.service:
+ class: acme\demo\service
+ arguments:
- '@user'
+ - '%acme.demo.tables.demo_table%'
+
acme.demo.listener:
class: acme\demo\event\main_listener
arguments:
+ - '@language'
- '@controller.helper'
- '@template'
+ - '%core.php_ext%'
tags:
- { name: event.listener }
diff --git a/controller/acp_controller.php b/controller/acp_controller.php
new file mode 100644
index 0000000..9fe3dce
--- /dev/null
+++ b/controller/acp_controller.php
@@ -0,0 +1,122 @@
+config = $config;
+ $this->language = $language;
+ $this->log = $log;
+ $this->request = $request;
+ $this->template = $template;
+ $this->user = $user;
+ }
+
+ /**
+ * Display the options a user can configure for this extension.
+ *
+ * @return void
+ */
+ public function display_options()
+ {
+ // Add our common language file
+ $this->language->add_lang('common', 'acme/demo');
+
+ // Create a form key for preventing CSRF attacks
+ add_form_key('acme_demo_acp');
+
+ // Create an array to collect errors that will be output to the user
+ $errors = [];
+
+ // Is the form being submitted to us?
+ if ($this->request->is_set_post('submit'))
+ {
+ // Test if the submitted form is valid
+ if (!check_form_key('acme_demo_acp'))
+ {
+ $errors[] = $this->language->lang('FORM_INVALID');
+ }
+
+ // If no errors, process the form data
+ if (empty($errors))
+ {
+ // Set the options the user configured
+ $this->config->set('acme_demo_goodbye', $this->request->variable('acme_demo_goodbye', 0));
+
+ // Add option settings change action to the admin log
+ $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_ACP_DEMO_SETTINGS');
+
+ // Option settings have been updated and logged
+ // Confirm this to the user and provide link back to previous page
+ trigger_error($this->language->lang('ACP_DEMO_SETTING_SAVED') . adm_back_link($this->u_action));
+ }
+ }
+
+ $s_errors = !empty($errors);
+
+ // Set output variables for display in the template
+ $this->template->assign_vars([
+ 'S_ERROR' => $s_errors,
+ 'ERROR_MSG' => $s_errors ? implode('
', $errors) : '',
+
+ 'U_ACTION' => $this->u_action,
+
+ 'ACME_DEMO_GOODBYE' => (bool) $this->config['acme_demo_goodbye'],
+ ]);
+ }
+
+ /**
+ * Set custom form action.
+ *
+ * @param string $u_action Custom form action
+ * @return void
+ */
+ public function set_page_url($u_action)
+ {
+ $this->u_action = $u_action;
+ }
+}
diff --git a/controller/main.php b/controller/main.php
deleted file mode 100644
index 430ed1a..0000000
--- a/controller/main.php
+++ /dev/null
@@ -1,55 +0,0 @@
-config = $config;
- $this->helper = $helper;
- $this->template = $template;
- $this->user = $user;
- }
-
- /**
- * Demo controller for route /demo/{name}
- *
- * @param string $name
- * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
- */
- public function handle($name)
- {
- $l_message = !$this->config['acme_demo_goodbye'] ? 'DEMO_HELLO' : 'DEMO_GOODBYE';
- $this->template->assign_var('DEMO_MESSAGE', $this->user->lang($l_message, $name));
-
- return $this->helper->render('demo_body.html', $name);
- }
-}
diff --git a/controller/main_controller.php b/controller/main_controller.php
new file mode 100644
index 0000000..d0f7d4b
--- /dev/null
+++ b/controller/main_controller.php
@@ -0,0 +1,60 @@
+config = $config;
+ $this->helper = $helper;
+ $this->template = $template;
+ $this->language = $language;
+ }
+
+ /**
+ * Controller handler for route /demo/{name}
+ *
+ * @param string $name
+ *
+ * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
+ */
+ public function handle($name)
+ {
+ $l_message = !$this->config['acme_demo_goodbye'] ? 'DEMO_HELLO' : 'DEMO_GOODBYE';
+ $this->template->assign_var('DEMO_MESSAGE', $this->language->lang($l_message, $name));
+
+ return $this->helper->render('@acme_demo/demo_body.html', $name);
+ }
+}
diff --git a/event/main_listener.php b/event/main_listener.php
index 56ce044..dcd5c06 100644
--- a/event/main_listener.php
+++ b/event/main_listener.php
@@ -1,64 +1,117 @@
'load_language_on_setup',
- 'core.page_header' => 'add_page_header_link',
- );
+ return [
+ 'core.user_setup' => 'load_language_on_setup',
+ 'core.page_header' => 'add_page_header_link',
+ 'core.viewonline_overwrite_location' => 'viewonline_page',
+ 'core.display_forums_modify_template_vars' => 'display_forums_modify_template_vars',
+ ];
}
+ /* @var \phpbb\language\language */
+ protected $language;
+
/* @var \phpbb\controller\helper */
protected $helper;
/* @var \phpbb\template\template */
protected $template;
+ /** @var string phpEx */
+ protected $php_ext;
+
/**
- * Constructor
- *
- * @param \phpbb\controller\helper $helper Controller helper object
- * @param \phpbb\template\template $template Template object
- */
- public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template)
+ * Constructor
+ *
+ * @param \phpbb\language\language $language Language object
+ * @param \phpbb\controller\helper $helper Controller helper object
+ * @param \phpbb\template\template $template Template object
+ * @param string $php_ext phpEx
+ */
+ public function __construct(\phpbb\language\language $language, \phpbb\controller\helper $helper, \phpbb\template\template $template, $php_ext)
{
- $this->helper = $helper;
+ $this->language = $language;
+ $this->helper = $helper;
$this->template = $template;
+ $this->php_ext = $php_ext;
}
+ /**
+ * Load common language files during user setup
+ *
+ * @param \phpbb\event\data $event Event object
+ */
public function load_language_on_setup($event)
{
$lang_set_ext = $event['lang_set_ext'];
- $lang_set_ext[] = array(
+ $lang_set_ext[] = [
'ext_name' => 'acme/demo',
'lang_set' => 'common',
- );
+ ];
$event['lang_set_ext'] = $lang_set_ext;
}
- public function add_page_header_link($event)
+ /**
+ * Add a link to the controller in the forum navbar
+ */
+ public function add_page_header_link()
+ {
+ $this->template->assign_vars([
+ 'U_DEMO_PAGE' => $this->helper->route('acme_demo_controller', ['name' => 'world']),
+ ]);
+ }
+
+ /**
+ * Show users viewing Acme Demo Extension page on the Who Is Online page
+ *
+ * @param \phpbb\event\data $event Event object
+ */
+ public function viewonline_page($event)
+ {
+ if ($event['on_page'][1] === 'app' && strrpos($event['row']['session_page'], 'app.' . $this->php_ext . '/demo') === 0)
+ {
+ $event['location'] = $this->language->lang('VIEWING_ACME_DEMO');
+ $event['location_url'] = $this->helper->route('acme_demo_controller', ['name' => 'world']);
+ }
+ }
+
+ /**
+ * A sample PHP event
+ * Modifies the names of the forums on index
+ *
+ * @param \phpbb\event\data $event Event object
+ */
+ public function display_forums_modify_template_vars($event)
{
- $this->template->assign_vars(array(
- 'U_DEMO_PAGE' => $this->helper->route('acme_demo_controller', array('name' => 'world')),
- ));
+ $forum_row = $event['forum_row'];
+ $forum_row['FORUM_NAME'] .= $this->language->lang('DEMO_EVENT');
+ $event['forum_row'] = $forum_row;
}
}
diff --git a/ext.php b/ext.php
index 7a5e969..62b9f48 100644
--- a/ext.php
+++ b/ext.php
@@ -1,20 +1,17 @@
'Demo',
+// DEVELOPERS PLEASE NOTE
+//
+// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
+//
+// Placeholders can now contain order information, e.g. instead of
+// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
+// translators to re-order the output of data while ensuring it remains correct
+//
+// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
+// equally where a string contains only two placeholders which are used to wrap text
+// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
+//
+// Some characters you may want to copy&paste:
+// ’ » “ ” …
+//
+
+$lang = array_merge($lang, [
+
'DEMO_HELLO' => 'Hello %s!',
'DEMO_GOODBYE' => 'Goodbye %s!',
- 'ACP_DEMO_TITLE' => 'Demo Module',
- 'ACP_DEMO' => 'Settings',
+ 'DEMO_EVENT' => ' :: Demo Event :: ',
+
'ACP_DEMO_GOODBYE' => 'Should say goodbye?',
'ACP_DEMO_SETTING_SAVED' => 'Settings have been saved successfully!',
-));
+
+ 'DEMO_PAGE' => 'Demo Page',
+ 'VIEWING_ACME_DEMO' => 'Viewing Acme Demo Extension page',
+
+]);
diff --git a/language/en/info_acp_demo.php b/language/en/info_acp_demo.php
new file mode 100644
index 0000000..03badf8
--- /dev/null
+++ b/language/en/info_acp_demo.php
@@ -0,0 +1,42 @@
+ 'Acme Demo Extension Module',
+ 'ACP_DEMO' => 'Acme Demo Extension Settings',
+
+ 'LOG_ACP_DEMO_SETTINGS' => 'Acme Demo Extension settings updated',
+]);
diff --git a/migrations/install_acp_module.php b/migrations/install_acp_module.php
new file mode 100644
index 0000000..c4f4fd3
--- /dev/null
+++ b/migrations/install_acp_module.php
@@ -0,0 +1,45 @@
+config['acme_demo_goodbye']);
+ }
+
+ public static function depends_on()
+ {
+ return ['\phpbb\db\migration\data\v320\v320'];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.add', ['acme_demo_goodbye', 0]],
+
+ ['module.add', [
+ 'acp',
+ 'ACP_CAT_DOT_MODS',
+ 'ACP_DEMO_TITLE'
+ ]],
+ ['module.add', [
+ 'acp',
+ 'ACP_DEMO_TITLE',
+ [
+ 'module_basename' => '\acme\demo\acp\main_module',
+ 'modes' => ['settings'],
+ ],
+ ]],
+ ];
+ }
+}
diff --git a/migrations/install_sample_schema.php b/migrations/install_sample_schema.php
new file mode 100644
index 0000000..44a7661
--- /dev/null
+++ b/migrations/install_sample_schema.php
@@ -0,0 +1,95 @@
+db_tools->sql_column_exists($this->table_prefix . 'users', 'user_demo');
+ }
+
+ public static function depends_on()
+ {
+ return ['\phpbb\db\migration\data\v320\v320'];
+ }
+
+ /**
+ * Update database schema.
+ *
+ * add_tables: Add tables
+ * drop_tables: Drop tables
+ * add_columns: Add columns to a table
+ * drop_columns: Removing/Dropping columns
+ * change_columns: Column changes (only type, not name)
+ * add_primary_keys: adding primary keys
+ * add_unique_index: adding an unique index
+ * add_index: adding an index (can be column:index_size if you need to provide size)
+ * drop_keys: Dropping keys
+ *
+ * This sample migration adds a new column to the users table.
+ * It also adds an example of a new table that can hold new data.
+ *
+ * @return array Array of schema changes
+ */
+ public function update_schema()
+ {
+ return [
+ 'add_tables' => [
+ $this->table_prefix . 'acme_demo_table' => [
+ 'COLUMNS' => [
+ 'demo_id' => ['UINT', null, 'auto_increment'],
+ 'demo_name' => ['VCHAR:255', ''],
+ ],
+ 'PRIMARY_KEY' => 'demo_id',
+ ],
+ ],
+ 'add_columns' => [
+ $this->table_prefix . 'users' => [
+ 'user_demo' => ['UINT', 0],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Revert database schema changes. This method is almost always required
+ * to revert the changes made above by update_schema.
+ *
+ * add_tables: Add tables
+ * drop_tables: Drop tables
+ * add_columns: Add columns to a table
+ * drop_columns: Removing/Dropping columns
+ * change_columns: Column changes (only type, not name)
+ * add_primary_keys: adding primary keys
+ * add_unique_index: adding an unique index
+ * add_index: adding an index (can be column:index_size if you need to provide size)
+ * drop_keys: Dropping keys
+ *
+ * This sample migration removes the column that was added the users table in update_schema.
+ * It also removes the table that was added in update_schema.
+ *
+ * @return array Array of schema changes
+ */
+ public function revert_schema()
+ {
+ return [
+ 'drop_columns' => [
+ $this->table_prefix . 'users' => [
+ 'user_demo',
+ ],
+ ],
+ 'drop_tables' => [
+ $this->table_prefix . 'acme_demo_table',
+ ],
+ ];
+ }
+}
diff --git a/migrations/release_1_0_0.php b/migrations/release_1_0_0.php
deleted file mode 100644
index 3402143..0000000
--- a/migrations/release_1_0_0.php
+++ /dev/null
@@ -1,44 +0,0 @@
-config['acme_demo_goodbye']);
- }
-
- public static function depends_on()
- {
- return array('\phpbb\db\migration\data\v310\alpha2');
- }
-
- public function update_data()
- {
- return array(
- array('config.add', array('acme_demo_goodbye', 0)),
-
- array('module.add', array(
- 'acp',
- 'ACP_CAT_DOT_MODS',
- 'ACP_DEMO_TITLE'
- )),
- array('module.add', array(
- 'acp',
- 'ACP_DEMO_TITLE',
- array(
- 'module_basename' => '\acme\demo\acp\main_module',
- 'modes' => array('settings'),
- ),
- )),
- );
- }
-}
diff --git a/migrations/release_1_0_1.php b/migrations/release_1_0_1.php
deleted file mode 100644
index 76639a7..0000000
--- a/migrations/release_1_0_1.php
+++ /dev/null
@@ -1,57 +0,0 @@
-db_tools->sql_column_exists($this->table_prefix . 'users', 'user_acme');
- }
-
- public static function depends_on()
- {
- return array('\acme\demo\migrations\release_1_0_0');
- }
-
- public function update_schema()
- {
- return array(
- 'add_tables' => array(
- $this->table_prefix . 'acme_demo' => array(
- 'COLUMNS' => array(
- 'acme_id' => array('UINT', null, 'auto_increment'),
- 'acme_name' => array('VCHAR:255', ''),
- ),
- 'PRIMARY_KEY' => 'acme_id',
- ),
- ),
- 'add_columns' => array(
- $this->table_prefix . 'users' => array(
- 'user_acme' => array('UINT', 0),
- ),
- ),
- );
- }
-
- public function revert_schema()
- {
- return array(
- 'drop_columns' => array(
- $this->table_prefix . 'users' => array(
- 'user_acme',
- ),
- ),
- 'drop_tables' => array(
- $this->table_prefix . 'acme_demo',
- ),
- );
- }
-}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 289449d..574c6b9 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
- syntaxCheck="false"
verbose="true"
bootstrap="../../../../tests/bootstrap.php"
>
@@ -18,14 +17,11 @@
./tests/functional
- ./tests/functional/
+ ./tests/functional/
-
- ./tests/
-
./
diff --git a/styles/prosilver/template/demo_body.html b/styles/prosilver/template/demo_body.html
index cfa2944..86abc76 100644
--- a/styles/prosilver/template/demo_body.html
+++ b/styles/prosilver/template/demo_body.html
@@ -1,5 +1,5 @@
-
+{% include 'overall_header.html' %}
-{DEMO_MESSAGE}
+{{ DEMO_MESSAGE }}
-
+{% include 'overall_footer.html' %}
diff --git a/styles/prosilver/template/event/overall_header_navigation_prepend.html b/styles/prosilver/template/event/overall_header_navigation_prepend.html
index 4cb6255..fe61ed7 100644
--- a/styles/prosilver/template/event/overall_header_navigation_prepend.html
+++ b/styles/prosilver/template/event/overall_header_navigation_prepend.html
@@ -1 +1,5 @@
-{L_DEMO_PAGE}
+
+
+ {{ lang('DEMO_PAGE') }}
+
+
diff --git a/tests/controller/main_test.php b/tests/controller/main_test.php
index e09e71b..a036568 100644
--- a/tests/controller/main_test.php
+++ b/tests/controller/main_test.php
@@ -1,24 +1,34 @@
disableOriginalConstructor()
->getMock();
- /** @var \phpbb\user $user Mock the user class */
- $user = $this->getMockBuilder('\phpbb\user', array(), array('\phpbb\datetime'))
+ /** @var \phpbb\language\language|\PHPUnit\Framework\MockObject\MockObject $language Mock the language class */
+ $language = $this->getMockBuilder('\phpbb\language\language')
->disableOriginalConstructor()
->getMock();
- /** @var \phpbb\controller\helper $controller_helper Mock the controller helper class */
+ // Set language->lang() to return any arguments sent to it
+ $language->method('lang')
+ ->will($this->returnArgument(0));
+
+ /** @var \phpbb\controller\helper|\PHPUnit\Framework\MockObject\MockObject $controller_helper Mock the controller helper class */
$controller_helper = $this->getMockBuilder('\phpbb\controller\helper')
->disableOriginalConstructor()
->getMock();
// Set the expected output of the controller_helper->render() method
- $controller_helper->expects($this->any())
+ $controller_helper->expects($this->once())
->method('render')
->willReturnCallback(function ($template_file, $page_title = '', $status_code = 200, $display_online_list = false) {
return new \Symfony\Component\HttpFoundation\Response($template_file, $status_code);
});
- // Instantiate the acme demo controller
- $controller = new \acme\demo\controller\main(
- new \phpbb\config\config(array()),
+ // Instantiate the controller
+ $controller = new \acme\demo\controller\main_controller(
+ new \phpbb\config\config([]),
$controller_helper,
$template,
- $user
+ $language
);
$response = $controller->handle('test');
diff --git a/tests/dbal/simple_test.php b/tests/dbal/simple_test.php
index 080b264..2d5d758 100644
--- a/tests/dbal/simple_test.php
+++ b/tests/dbal/simple_test.php
@@ -1,35 +1,56 @@
createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ return $this->createXMLDataSet(__DIR__ . '/fixtures/config.xml');
}
+ /**
+ * A simple test checking to see if the database users table was correctly updated
+ */
public function test_column()
{
$this->db = $this->new_dbal();
- $factory = new \phpbb\db\tools\factory();
- $db_tools = $factory->get(method_exists($this, 'new_doctrine_dbal') ? $this->new_doctrine_dbal() : $this->db);
- $this->assertTrue($db_tools->sql_column_exists(USERS_TABLE, 'user_acme'), 'Asserting that column "user_acme" exists');
- $this->assertFalse($db_tools->sql_column_exists(USERS_TABLE, 'user_acme_demo'), 'Asserting that column "user_acme_demo" does not exist');
+
+ if (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<'))
+ {
+ // This is how to instantiate db_tools in phpBB 3.1
+ $db_tools = new \phpbb\db\tools($this->db);
+ }
+ else
+ {
+ // This is how to instantiate db_tools in phpBB 3.2
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($this->db);
+ }
+
+ $this->assertTrue($db_tools->sql_column_exists(USERS_TABLE, 'user_demo'), 'Asserting that column "user_demo" exists');
+ $this->assertFalse($db_tools->sql_column_exists(USERS_TABLE, 'user_demo_void'), 'Asserting that column "user_demo_void" does not exist');
}
}
diff --git a/tests/functional/demo_test.php b/tests/functional/demo_test.php
deleted file mode 100644
index 7ddd97b..0000000
--- a/tests/functional/demo_test.php
+++ /dev/null
@@ -1,48 +0,0 @@
-controller = phpbb_version_compare(PHPBB_VERSION, '4.0.0-a1', '>=') ? 'index' : 'app';
- }
-
- public function test_demo_acme()
- {
- $crawler = self::request('GET', $this->controller . '.php/demo/acme');
- $this->assertStringContainsString('acme', $crawler->filter('h2')->text());
-
- $this->add_lang_ext('acme/demo', 'common');
- $this->assertStringContainsString($this->lang('DEMO_HELLO', 'acme'), $crawler->filter('h2')->text());
- $this->assertStringNotContainsString($this->lang('DEMO_GOODBYE', 'acme'), $crawler->filter('h2')->text());
-
- $this->assertNotContainsLang('ACP_DEMO', $crawler->filter('h2')->text());
- }
-
- public function test_demo_world()
- {
- $crawler = self::request('GET', $this->controller . '.php/demo/world');
- $this->assertStringNotContainsString('acme', $crawler->filter('h2')->text());
- $this->assertStringContainsString('world', $crawler->filter('h2')->text());
- }
-}
diff --git a/tests/functional/view_test.php b/tests/functional/view_test.php
new file mode 100644
index 0000000..df0c9ae
--- /dev/null
+++ b/tests/functional/view_test.php
@@ -0,0 +1,52 @@
+assertStringContainsString('foo', $crawler->filter('h2')->text());
+
+ $this->add_lang_ext('acme/demo', 'common');
+ $this->assertStringContainsString($this->lang('DEMO_HELLO', 'foo'), $crawler->filter('h2')->text());
+ $this->assertStringNotContainsString($this->lang('DEMO_GOODBYE', 'foo'), $crawler->filter('h2')->text());
+
+ $this->assertNotContainsLang('ACP_DEMO_GOODBYE', $crawler->filter('h2')->text());
+ }
+
+ /**
+ * Test crawls the extension's page route /demo/ again with a new variable: bar
+ * Asserts that only the expected text "bar" is found and that "foo" is no longer present.
+ */
+ public function test_view_bar()
+ {
+ $crawler = self::request('GET', 'app.php/demo/bar');
+ $this->assertStringNotContainsString('foo', $crawler->filter('h2')->text());
+ $this->assertStringContainsString('bar', $crawler->filter('h2')->text());
+ }
+}