3 namespace Friendica\Test\src\Model;
5 use Friendica\Model\FileTag;
6 use PHPUnit\Framework\TestCase;
8 class FileTagTest extends TestCase
10 public function dataArrayToFile()
14 'array' => ['1', '2', '3', 'a', 'b', 'c'],
16 'file' => '<1><2><3><a><b><c>',
19 'array' => ['1', '2', '3', 'a', 'b', 'c'],
21 'file' => '[1][2][3][a][b][c]',
23 'chevron-category' => [
24 'array' => ['Left < Center > Right'],
26 'file' => '<Left %3c Center %3e Right>',
29 'array' => ['Glass [half-full]'],
31 'file' => '[Glass %5bhalf-full%5d]',
33 /** @see https://github.com/friendica/friendica/issues/7171 */
34 'bug-7171-category' => [
35 'array' => ['Science, Health, Medicine'],
37 'file' => '<Science, Health, Medicine>',
40 'array' => ['Science, Health, Medicine'],
42 'file' => '[Science, Health, Medicine]',
48 * Test convert saved folders arrays to a file/category field
49 * @dataProvider dataArrayToFile
55 public function testArrayToFile(array $array, string $type, string $file)
57 $this->assertEquals($file, FileTag::arrayToFile($array, $type));
60 public function dataFileToArray()
64 'file' => '<1><2><3><a><b><c>',
66 'array' => ['1', '2', '3', 'a', 'b', 'c'],
69 'file' => '[1][2][3][a][b][c]',
71 'array' => ['1', '2', '3', 'a', 'b', 'c'],
73 'combinedlist-category' => [
74 'file' => '[1][2][3]<a><b><c>',
76 'array' => ['a', 'b', 'c'],
78 'combinedlist-file' => [
79 'file' => '[1][2][3]<a><b><c>',
81 'array' => ['1', '2', '3'],
83 'chevron-category' => [
84 'file' => '<Left %3c Center %3e Right>',
86 'array' => ['Left < Center > Right'],
89 'file' => '[Glass %5bhalf-full%5d]',
91 'array' => ['Glass [half-full]'],
93 /** @see https://github.com/friendica/friendica/issues/7171 */
94 'bug-7171-category' => [
95 'file' => '<Science, Health, Medicine>',
97 'array' => ['Science, Health, Medicine'],
100 'file' => '[Science, Health, Medicine]',
102 'array' => ['Science, Health, Medicine'],
108 * Test convert different saved folders to a file/category field
109 * @dataProvider dataFileToArray
111 * @param string $file
112 * @param string $type
113 * @param array $array
115 public function testFileToArray(string $file, string $type, array $array)
117 $this->assertEquals($array, FileTag::fileToArray($file, $type));