From 62aefadc27002f9d47f391b15520a82d5c3d6ecc Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 18 May 2024 11:30:29 +0200 Subject: Module\Rpost: Add basic test and fix session access. Just a basic test to ensure that the module `get()` method behaves somewhat reasonable when no query params are given. Had to make a small change to the Rpost module itself. Since the `$_SESSION` superglobal may not always be set (and is not in the test), use `isset` instead of `array_key_exists` to check if we have saved query params in the session. In general, isset is safer than array_key_exists if there's a chance that the array itself may not exist. --- tests/unit/Module/RpostTest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/unit/Module/RpostTest.php (limited to 'tests') diff --git a/tests/unit/Module/RpostTest.php b/tests/unit/Module/RpostTest.php new file mode 100644 index 000000000..796901520 --- /dev/null +++ b/tests/unit/Module/RpostTest.php @@ -0,0 +1,31 @@ +getFunctionMock('Zotlabs\Module', 'local_channel') + ->expects($this->any()) + ->willReturn(42); + + // Set basic access controls to keep AccessList happy. + \App::$channel = [ + 'channel_allow_cid' => null, + 'channel_allow_gid' => null, + 'channel_deny_cid' => null, + 'channel_deny_gid' => null, + ]; + + $this->get('rpost'); + + $this->assertPageContains('
assertPageContains('