aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Lib')
-rw-r--r--tests/unit/Lib/ActivityTest.php2
-rw-r--r--tests/unit/Lib/PermissionDescriptionTest.php20
-rw-r--r--tests/unit/Lib/ZotlibTest.php38
3 files changed, 39 insertions, 21 deletions
diff --git a/tests/unit/Lib/ActivityTest.php b/tests/unit/Lib/ActivityTest.php
index c9ce79d8c..0e2703f2b 100644
--- a/tests/unit/Lib/ActivityTest.php
+++ b/tests/unit/Lib/ActivityTest.php
@@ -19,7 +19,7 @@ class ActivityTest extends UnitTestCase {
/**
* Dataprovider for test_get_textfield.
*/
- private function get_textfield_provider(): array {
+ public static function get_textfield_provider(): array {
return [
'get content field' => [
['content' => 'Some content'],
diff --git a/tests/unit/Lib/PermissionDescriptionTest.php b/tests/unit/Lib/PermissionDescriptionTest.php
index fdd676f61..1e4b5292c 100644
--- a/tests/unit/Lib/PermissionDescriptionTest.php
+++ b/tests/unit/Lib/PermissionDescriptionTest.php
@@ -46,16 +46,6 @@ class PermissionDescriptionTest extends UnitTestCase {
}
public function testFromStandalonePermission() {
- // Create a stub for global function t()
- $t = $this->getFunctionMock('Zotlabs\Lib', 't');
- $t->expects($this->atLeastOnce())->willReturnCallback(
- function ($string) {
- return $string;
- }
- );
- // Create a mock for global function logger()
- $this->getFunctionMock('Zotlabs\Lib', 'logger');
-
$permDescUnknown = PermissionDescription::fromStandalonePermission(-1);
$permDescSelf = PermissionDescription::fromStandalonePermission(0);
@@ -113,16 +103,6 @@ class PermissionDescriptionTest extends UnitTestCase {
}
public function testGetPermissionDescription() {
- // Create a stub for global function t()
- $t = $this->getFunctionMock('Zotlabs\Lib', 't');
- $t->expects($this->atLeastOnce())->willReturnCallback(
- function ($string) {
- return $string;
- }
- );
- // Create a mock for global function logger()
- $this->getFunctionMock('Zotlabs\Lib', 'logger');
-
// Create a stub for the PermissionDescription class
$stub = $this->createMock(PermissionDescription::class);
$stub->method('get_permission_description')
diff --git a/tests/unit/Lib/ZotlibTest.php b/tests/unit/Lib/ZotlibTest.php
new file mode 100644
index 000000000..0ab89dc2f
--- /dev/null
+++ b/tests/unit/Lib/ZotlibTest.php
@@ -0,0 +1,38 @@
+<?php
+namespace Zotlabs\Tests\Unit\Lib;
+
+use Zotlabs\Tests\Unit\UnitTestCase;
+
+class ZotlibTest extends UnitTestCase {
+ /**
+ * Test the `get_rpost_path` function.
+ *
+ * @dataProvider get_rpost_path_provider
+ */
+ public function test_get_rpost_path(string $expected, string $xchan_url) : void {
+ $observer = [ 'xchan_url' => $xchan_url ];
+
+ $this->assertEquals($expected, \Zotlabs\Lib\Libzot::get_rpost_path($observer));
+ }
+
+ public static function get_rpost_path_provider() : array {
+ return [
+ 'xchan_url without port' => [
+ 'https://example.com/rpost?f=',
+ 'https://example.com'
+ ],
+ 'xchan_url with port' => [
+ 'https://example.com:666/rpost?f=',
+ 'https://example.com:666'
+ ],
+ 'xchan_url ignores path and args' => [
+ 'https://example.com/rpost?f=',
+ 'https://example.com/path?arg1=balle'
+ ],
+ 'xchan_url with no scheme should default to https' => [
+ 'https://example.com/rpost?f=',
+ 'example.com',
+ ],
+ ];
+ }
+}