aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-11-19 11:10:49 +0100
committerHarald Eilertsen <haraldei@anduin.net>2024-11-19 11:10:49 +0100
commit5338793883107d8c53ee1bab9b483d3978830978 (patch)
tree7f54774c53b4a465249b545b828b1c18e32341f9 /tests/unit
parent9acc73b273bbe12b334703e3a0f4c1a6f16aef5b (diff)
downloadvolse-hubzilla-5338793883107d8c53ee1bab9b483d3978830978.tar.gz
volse-hubzilla-5338793883107d8c53ee1bab9b483d3978830978.tar.bz2
volse-hubzilla-5338793883107d8c53ee1bab9b483d3978830978.zip
Ubreak tests: update MagicTest for new behaviour of Magic module.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/Module/MagicTest.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/unit/Module/MagicTest.php b/tests/unit/Module/MagicTest.php
index 4d50412ee..4a03d9d57 100644
--- a/tests/unit/Module/MagicTest.php
+++ b/tests/unit/Module/MagicTest.php
@@ -17,13 +17,24 @@ use App;
class MagicTest extends TestCase {
public function test_init_with_no_args(): void {
- // Since no parameters are passed, nothing will really be done.
- // Neither the delegate nor the owa functionality will be invoked,
- // but at the end the code will try to redirect to an empty
- // URL.
+
+ // We expect the request to end with a status 400, as we do not
+ // pass any of the required params.
//
- // This should probably return a 400 Invalid Request instead.
- $this->expectRedirectTo('');
+ // To catch that, we have to mock the call to `http_status_exit`
+ // made by the code under test.
+ $this->getFunctionMock('Zotlabs\Module', 'http_status_exit')
+ ->expects($this->once()) // Expect the function to be called only once!
+ ->with( // ... with the following two arguments
+ $this->identicalTo(400),
+ $this->identicalTo('Bad Request')
+ )
+ ->willReturnCallback(function () { // Run this function instead when called
+ throw new KillmeException; // Throw an exception to terminate processing
+ });
+
+ // Tell the test system we excpect this exception to be thrown
+ $this->expectException(KillmeException::class);
$this->get('magic');
}