aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Module/TestCase.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-05-15 08:28:19 +0000
committerMario <mario@mariovavti.com>2024-05-15 08:28:19 +0000
commit5da0cc138f4330fd07e9c117b3f4261dc1bcbc19 (patch)
tree8efc921f3ce182f1cfb781c7a4c3dabca1c6fc43 /tests/unit/Module/TestCase.php
parent960354b16cab06915a2f85fcc5e55d380765d858 (diff)
downloadvolse-hubzilla-5da0cc138f4330fd07e9c117b3f4261dc1bcbc19.tar.gz
volse-hubzilla-5da0cc138f4330fd07e9c117b3f4261dc1bcbc19.tar.bz2
volse-hubzilla-5da0cc138f4330fd07e9c117b3f4261dc1bcbc19.zip
Refactor and cleanup Rbmark module + add tests
Diffstat (limited to 'tests/unit/Module/TestCase.php')
-rw-r--r--tests/unit/Module/TestCase.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit/Module/TestCase.php b/tests/unit/Module/TestCase.php
index aa09e0596..5ad213e81 100644
--- a/tests/unit/Module/TestCase.php
+++ b/tests/unit/Module/TestCase.php
@@ -12,10 +12,19 @@ class TestCase extends \Zotlabs\Tests\Unit\UnitTestCase {
*
* @param string $uri The URI to request. Typically this will be the module
* name, followed by any req args separated by slashes.
+ *
+ * @param array $query Assciative array of query args, with the parameters
+ * as keys.
*/
- protected function get(string $uri): void {
+ protected function get(string $uri, array $query = []): void {
$_GET['q'] = $uri;
+
+ if (!empty($query)) {
+ $_GET = array_merge($_GET, $query);
+ }
+
$_SERVER['REQUEST_METHOD'] = 'GET';
+ $_REQUEST = $_GET;
\App::init();
\App::$page['content'] = '';
@@ -25,6 +34,15 @@ class TestCase extends \Zotlabs\Tests\Unit\UnitTestCase {
}
/**
+ * Helper to simplify asserting contents in the rendered page.
+ *
+ * @param string $needle The expected string to find.
+ */
+ protected function assertPageContains(string $needle): void {
+ $this->assertStringContainsString($needle, \App::$page['content']);
+ }
+
+ /**
* Stub out the `killme` function.
*
* Usefule for modules that call this function directly.