diff --git a/tests/controller/main_test.php b/tests/controller/main_test.php
index 620e462..760c58a 100644
--- a/tests/controller/main_test.php
+++ b/tests/controller/main_test.php
@@ -18,6 +18,8 @@
use phpbb\skeleton\ext;
use Symfony\Component\DependencyInjection\ContainerInterface;
+require_once __DIR__ . '/test_helpers.php';
+
class main_test extends \phpbb_test_case
{
/** @var \phpbb\template\template|\PHPUnit\Framework\MockObject\MockObject */
@@ -50,6 +52,9 @@ class main_test extends \phpbb_test_case
protected function setUp(): void
{
global $phpbb_root_path;
+ global $phpbb_skeleton_form_key_valid;
+
+ $phpbb_skeleton_form_key_valid = true;
// Mocks are dummy implementations that provide the API of components we depend on //
$this->template = $this->getMockBuilder('\phpbb\template\template')
@@ -272,6 +277,30 @@ public function test_handle_unauthorised()
$this->get_controller($this->packager_mock)->handle();
}
+ public function test_submit_invalid_form_key()
+ {
+ global $phpbb_skeleton_form_key_valid;
+
+ $this->user->data['is_bot'] = false;
+ $phpbb_skeleton_form_key_valid = false;
+
+ $this->request->expects($this->once())
+ ->method('is_set_post')
+ ->with('submit')
+ ->willReturn(true);
+
+ $this->packager_mock->expects($this->never())
+ ->method('create_extension');
+
+ $this->packager_mock->expects($this->never())
+ ->method('create_zip');
+
+ $this->expectException(http_exception::class);
+ $this->expectExceptionMessage('FORM_INVALID');
+
+ $this->get_controller($this->packager_mock)->handle();
+ }
+
public function test_submit_success()
{
$this->user->data['is_bot'] = false;
diff --git a/tests/controller/test_helpers.php b/tests/controller/test_helpers.php
new file mode 100644
index 0000000..fa5fb48
--- /dev/null
+++ b/tests/controller/test_helpers.php
@@ -0,0 +1,25 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\skeleton\controller;
+
+function add_form_key($form_name)
+{
+}
+
+function check_form_key($form_name)
+{
+ global $phpbb_skeleton_form_key_valid;
+
+ return $phpbb_skeleton_form_key_valid;
+}