aboutsummaryrefslogtreecommitdiffstats
path: root/tests/help
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
commit8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch)
treee0db2bb4a012d5b06a633160b19f62f4868ecd28 /tests/help
parent36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff)
parent2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff)
downloadforums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'tests/help')
-rw-r--r--tests/help/manager_test.php184
1 files changed, 184 insertions, 0 deletions
diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php
new file mode 100644
index 0000000000..68534d9a32
--- /dev/null
+++ b/tests/help/manager_test.php
@@ -0,0 +1,184 @@
+<?php
+/**
+ *
+ * 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.
+ *
+ */
+
+class phpbb_help_manager_test extends phpbb_test_case
+{
+ /** @var \phpbb\help\manager */
+ protected $manager;
+ /** @var \phpbb\template\template */
+ protected $template;
+ /** @var \phpbb\language\language */
+ protected $language;
+
+ public function setUp()
+ {
+ $this->template = $this->getMockBuilder('\phpbb\template\template')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->language = $this->getMockBuilder('\phpbb\language\language')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->manager = new \phpbb\help\manager(
+ new \phpbb_mock_event_dispatcher(),
+ $this->language,
+ $this->template
+ );
+ }
+
+ public function add_block_data()
+ {
+ return array(
+ array('abc', false, array(), false),
+ array('def', true, array(), true),
+ array(
+ 'abc',
+ false,
+ array(
+ 'question1' => 'answer1',
+ 'question2' => 'answer2',
+ 'question3' => 'answer3',
+ ),
+ false
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider add_block_data
+ *
+ * @param string $block_name
+ * @param bool $switch
+ * @param array $questions
+ * @param bool $switch_expected
+ */
+ public function test_add_block($block_name, $switch, $questions, $switch_expected)
+ {
+ $this->language->expects($this->at(0))
+ ->method('lang')
+ ->with($block_name)
+ ->willReturn(strtoupper($block_name));
+ $lang_call_count = 1;
+ foreach ($questions as $question => $answer)
+ {
+ $this->language->expects($this->at($lang_call_count))
+ ->method('lang')
+ ->with($question)
+ ->willReturn(strtoupper($question));
+ $lang_call_count++;
+
+ $this->language->expects($this->at($lang_call_count))
+ ->method('lang')
+ ->with($answer)
+ ->willReturn(strtoupper($answer));
+ $lang_call_count++;
+ }
+
+ $this->template->expects($this->at(0))
+ ->method('assign_block_vars')
+ ->with('faq_block', array(
+ 'BLOCK_TITLE' => strtoupper($block_name),
+ 'SWITCH_COLUMN' => $switch_expected,
+ ));
+ $template_call_count = 1;
+ foreach ($questions as $question => $answer)
+ {
+ $this->template->expects($this->at($template_call_count))
+ ->method('assign_block_vars')
+ ->with('faq_block.faq_row', array(
+ 'FAQ_QUESTION' => strtoupper($question),
+ 'FAQ_ANSWER' => strtoupper($answer),
+ ));
+ $template_call_count++;
+ }
+
+ $this->manager->add_block($block_name, $switch, $questions);
+
+ $this->assertEquals($switch_expected, $this->manager->switched_column());
+ }
+
+ public function add_question_data()
+ {
+ return array(
+ array('abc', false, false),
+ array('def', true, true),
+ );
+ }
+
+ /**
+ * @dataProvider add_question_data
+ *
+ * @param string $question
+ * @param string $answer
+ */
+ public function test_add_question($question, $answer)
+ {
+ $this->language->expects($this->at(0))
+ ->method('lang')
+ ->with($question)
+ ->willReturn(strtoupper($question));
+ $this->language->expects($this->at(1))
+ ->method('lang')
+ ->with($answer)
+ ->willReturn(strtoupper($answer));
+
+ $this->template->expects($this->once())
+ ->method('assign_block_vars')
+ ->with('faq_block.faq_row', array(
+ 'FAQ_QUESTION' => strtoupper($question),
+ 'FAQ_ANSWER' => strtoupper($answer),
+ ));
+
+ $this->manager->add_question($question, $answer);
+ }
+
+ public function test_add_block_double_switch()
+ {
+ $block_name = 'abc';
+ $switch_expected = true;
+
+ $this->language->expects($this->at(0))
+ ->method('lang')
+ ->with($block_name)
+ ->willReturn(strtoupper($block_name));
+
+ $this->template->expects($this->at(0))
+ ->method('assign_block_vars')
+ ->with('faq_block', array(
+ 'BLOCK_TITLE' => strtoupper($block_name),
+ 'SWITCH_COLUMN' => $switch_expected,
+ ));
+
+ $this->manager->add_block($block_name, true);
+ $this->assertTrue($this->manager->switched_column());
+
+ // Add a second block with switch
+ $block_name = 'def';
+ $switch_expected = false;
+
+ $this->language->expects($this->at(0))
+ ->method('lang')
+ ->with($block_name)
+ ->willReturn(strtoupper($block_name));
+
+ $this->template->expects($this->at(0))
+ ->method('assign_block_vars')
+ ->with('faq_block', array(
+ 'BLOCK_TITLE' => strtoupper($block_name),
+ 'SWITCH_COLUMN' => $switch_expected,
+ ));
+
+ $this->manager->add_block($block_name, true);
+ $this->assertTrue($this->manager->switched_column());
+ }
+}