aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2024-12-10 22:45:56 +0100
committerMario Vavti <mario@mariovavti.com>2024-12-10 22:45:56 +0100
commite9222d0d9aed21816c8654fae074429afeda8f95 (patch)
tree8f1d56c375214d6347ea170e94e525ad0d549efc /tests
parent93f72a53f518f4c6fd9ebd29536e0d44da366baf (diff)
downloadvolse-hubzilla-e9222d0d9aed21816c8654fae074429afeda8f95.tar.gz
volse-hubzilla-e9222d0d9aed21816c8654fae074429afeda8f95.tar.bz2
volse-hubzilla-e9222d0d9aed21816c8654fae074429afeda8f95.zip
add test for item_forwardable()
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/includes/ItemsTest.php132
1 files changed, 132 insertions, 0 deletions
diff --git a/tests/unit/includes/ItemsTest.php b/tests/unit/includes/ItemsTest.php
new file mode 100644
index 000000000..1c2fb6725
--- /dev/null
+++ b/tests/unit/includes/ItemsTest.php
@@ -0,0 +1,132 @@
+<?php
+/**
+ * tests function from include/items.php
+ *
+ * @package test.util
+ */
+
+use Zotlabs\Tests\Unit\UnitTestCase;
+
+class ItemsTest extends UnitTestCase {
+ /**
+ * Data provider for item_forwardable function.
+ *
+ * @return array
+ */
+ public static function itemForwardableDataProvider()
+ {
+ return [
+ // Test case: item is unpublished
+ [
+ [
+ 'item_unpublished' => 1,
+ 'item_delayed' => 0,
+ 'item_blocked' => 0,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Create',
+ 'postopts' => '',
+ 'author' => ['xchan_network' => '']
+ ],
+ false // Expected result
+ ],
+ // Test case: item is delayed
+ [
+ [
+ 'item_unpublished' => 0,
+ 'item_delayed' => 1,
+ 'item_blocked' => 0,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Create',
+ 'postopts' => '',
+ 'author' => ['xchan_network' => '']
+ ],
+ false
+ ],
+ // Test case: item is blocked
+ [
+ [
+ 'item_unpublished' => 0,
+ 'item_delayed' => 0,
+ 'item_blocked' => 1,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Create',
+ 'postopts' => '',
+ 'author' => ['xchan_network' => '']
+ ],
+ false
+ ],
+ // Test case: verb is 'Follow' (forbidden verb)
+ [
+ [
+ 'item_unpublished' => 0,
+ 'item_delayed' => 0,
+ 'item_blocked' => 0,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Follow',
+ 'postopts' => '',
+ 'author' => ['xchan_network' => '']
+ ],
+ false
+ ],
+ // Test case: postopts contains 'nodeliver'
+ [
+ [
+ 'item_unpublished' => 0,
+ 'item_delayed' => 0,
+ 'item_blocked' => 0,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Create',
+ 'postopts' => 'nodeliver',
+ 'author' => ['xchan_network' => '']
+ ],
+ false
+ ],
+ // Test case: actor's network is 'rss' (restricted network)
+ [
+ [
+ 'item_unpublished' => 0,
+ 'item_delayed' => 0,
+ 'item_blocked' => 0,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Create',
+ 'postopts' => '',
+ 'author' => ['xchan_network' => 'rss']
+ ],
+ false
+ ],
+ // Test case: no conditions met (should forward)
+ [
+ [
+ 'item_unpublished' => 0,
+ 'item_delayed' => 0,
+ 'item_blocked' => 0,
+ 'item_hidden' => 0,
+ 'item_restrict' => 0,
+ 'verb' => 'Create',
+ 'postopts' => '',
+ 'author' => ['xchan_network' => 'other']
+ ],
+ true
+ ]
+ ];
+ }
+
+ /**
+ * Test item_forwardable with various data.
+ *
+ * @dataProvider itemForwardableDataProvider
+ */
+ public function testItemForwardable($item, $expected)
+ {
+ $this->assertSame($expected, item_forwardable($item));
+ }
+
+}
+
+