3 * @file tests/src/Util/Arrays.php
4 * @author Roland Haeder<https://f.haeder.net/profile/roland>
6 namespace Friendica\Test\src\Util;
8 use Friendica\Util\Arrays;
9 use PHPUnit\Framework\TestCase;
12 * @brief Array utility testing class
14 class ArraysTest extends TestCase
17 * @brief Tests if an empty array and an empty delimiter returns an empty string.
19 public function testEmptyArrayEmptyDelimiter()
21 $str = Arrays::recursiveImplode([], '');
22 $this->assertEmpty($str);
26 * @brief Tests if an empty array and a non-empty delimiter returns an empty string.
28 public function testEmptyArrayNonEmptyDelimiter()
30 $str = Arrays::recursiveImplode([], ',');
31 $this->assertEmpty($str);
35 * @brief Tests if a non-empty array and an empty delimiter returns the value (1).
37 public function testNonEmptyArrayEmptyDelimiter()
39 $str = Arrays::recursiveImplode([1], '');
40 $this->assertSame($str, '1');
44 * @brief Tests if a non-empty array and an empty delimiter returns the value (12).
46 public function testNonEmptyArray2EmptyDelimiter()
48 $str = Arrays::recursiveImplode([1, 2], '');
49 $this->assertSame($str, '12');
53 * @brief Tests if a non-empty array and a non-empty delimiter returns the value (1).
55 public function testNonEmptyArrayNonEmptyDelimiter()
57 $str = Arrays::recursiveImplode([1], ',');
58 $this->assertSame($str, '1');
62 * @brief Tests if a non-empty array and a non-empty delimiter returns the value (1,2).
64 public function testNonEmptyArray2NonEmptyDelimiter()
66 $str = Arrays::recursiveImplode([1, 2], ',');
67 $this->assertSame($str, '1,2');
71 * @brief Tests if a 2-dim array and an empty delimiter returns the expected string.
73 public function testEmptyMultiArray2EmptyDelimiter()
75 $str = Arrays::recursiveImplode([[1], []], '');
76 $this->assertSame($str, '{1}{}');
80 * @brief Tests if a 2-dim array and an empty delimiter returns the expected string.
82 public function testEmptyMulti2Array2EmptyDelimiter()
84 $str = Arrays::recursiveImplode([[1], [2]], '');
85 $this->assertSame($str, '{1}{2}');
89 * @brief Tests if a 2-dim array and a non-empty delimiter returns the expected string.
91 public function testEmptyMultiArray2NonEmptyDelimiter()
93 $str = Arrays::recursiveImplode([[1], []], ',');
94 $this->assertSame($str, '{1},{}');
98 * @brief Tests if a 2-dim array and a non-empty delimiter returns the expected string.
100 public function testEmptyMulti2Array2NonEmptyDelimiter()
102 $str = Arrays::recursiveImplode([[1], [2]], ',');
103 $this->assertSame($str, '{1},{2}');
107 * @brief Tests if a 3-dim array and a non-empty delimiter returns the expected string.
109 public function testEmptyMulti3Array2NonEmptyDelimiter()
111 $str = Arrays::recursiveImplode([[1], [2, [3]]], ',');
112 $this->assertSame($str, '{1},{2,{3}}');