File: ParseScuttleBookmarksTest.php

package info (click to toggle)
php-netscape-bookmark-parser 4.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: php: 3,592; makefile: 49; sh: 3
file content (124 lines) | stat: -rw-r--r-- 4,316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php

declare(strict_types=1);

namespace Shaarli\NetscapeBookmarkParser\Tests\Unit\Encoder;

use Shaarli\NetscapeBookmarkParser\Encoder\NetscapeBookmarkDecoder;
use PHPUnit\Framework\TestCase;

/**
 * Ensure Scuttle exports are properly parsed.
 *
 * @see https://sourceforge.net/projects/scuttle/
 */
class ParseScuttleBookmarksTest extends TestCase
{
    public const FIXTURE_DIRECTORY = __DIR__ . '/../../Fixtures/Encoder/';

    // phpcs:disable Generic.Files.LineLength
    public const EXPECTED_1 = [
        [
            'name' => 'EuroVoc Thesaurus',
            'image'  => null,
            'url'   => 'http://eurovoc.europa.eu/drupal/?q=navigation&amp;cl=en',
            'tags'  => [
                'dictionary',
            ],
            'description'  => 'Multilingual Thesaurus of the European Union',
            'dateCreated'  => 1298020913,
            'public'   => null,
        ],
        [
            'name' => "IATE - The EU's multilingual term base",
            'image'  => null,
            'url'   => 'http://iate.europa.eu/iatediff/SearchByQueryLoad.do?method=load',
            'tags'  => [
                'dictionary',
            ],
            'description'  => null,
            'dateCreated'  => 1290688452,
            'public'   => null,
        ],
        [
            'name' => 'Linguee - Das Web als Wörterbuch - EN/DE, EN/FR, EN/SP, EN/POR',
            'image'  => null,
            'url'   => 'http://www.linguee.de/deutsch-englisch/search',
            'tags'  => [
                'dictionary',
            ],
            'description'  => '&quot;Durchsuchen Sie Millionen von Sätzen, die von anderen Menschen übersetzt wurden.&quot;',
            'dateCreated'  => 1290691589,
            'public'   => null,
        ],
        [
            'name' => 'UN Terminology in German, English (&amp; French &amp; Spanish)',
            'image'  => null,
            'url'   => 'http://unterm.un.org/dgaacs/gts_term.nsf',
            'tags'  => [
                'dictionary',
            ],
            'description'  => "Database of the United Nation's German Translation Section. Every record contains at least one German term and a corresponding term usually in English. Most records also contain a French equivalent, some also a Spanish version. Not necessarily official.",
            'dateCreated'  => 1210915553,
            'public'   => null,
        ],
    ];

    public const EXPECTED_2 = [
        [
            'name' => 'Funky16Corners',
            'image'  => null,
            'url'   => 'http://funky16corners.com',
            'tags'  => [
                'funk',
                'musik',
                'blog',
            ],
            'description'  => 'The best in funk, soul, jazz and rare groove vinyl<br>I have been writing about music in various forms (zines, newspapers, e-zines, blogs) since the mid-80’s. The Funky16Corners blog started in November of 2004 to focus on funk and soul vinyl. Since mid-2006, in addition to individual MP3 tracks, I have been posting mixes under the title Funky16Corners radio. Most MP3s and mixes will be available for a few weeks.',
            'dateCreated'  => 1491107880,
            'public'   => null,
        ],
    ];
    // phpcs:enable

    /**
     * @var NetscapeBookmarkDecoder|null
     */
    private $decoder;

    /**
     * Parse bookmarks as exported by Scuttle.
     */
    public function testParse(): void
    {
        $content = \file_get_contents(self::FIXTURE_DIRECTORY . 'input/scuttle.htm');
        $result = $this->decoder->decode($content);

        $this->assertSame(self::EXPECTED_1, $result);
    }

    /**
     * Parse bookmarks as exported by Scuttle.
     */
    public function testParseWithNewLine(): void
    {
        $content = \file_get_contents(self::FIXTURE_DIRECTORY . 'input/scuttle_new_line.htm');
        $result = $this->decoder->decode($content);

        $this->assertSame(self::EXPECTED_2, $result);
    }

    // --------------------------------------------------
    // Setup / Tear Down
    // --------------------------------------------------

    protected function setUp(): void
    {
        $this->decoder = new NetscapeBookmarkDecoder();
    }

    protected function tearDown(): void
    {
        $this->decoder = null;
    }
}