File: ParseShaarliWithTabsAndSpacesTest.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 (73 lines) | stat: -rw-r--r-- 1,946 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
<?php

declare(strict_types=1);

namespace Shaarli\NetscapeBookmarkParser\Tests\Unit\Encoder;

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

class ParseShaarliWithTabsAndSpacesTest extends TestCase
{
    public const FIXTURE_DIRECTORY = __DIR__ . '/../../Fixtures/Encoder/';

    public const EXPECTED = [
        [
            'name' => 'Note: Code tests',
            'image'  => null,
            'url'   => '?KvNdlQ',
            'tags'  => ['dev'],
            'dateCreated'  => 1591456706,
            'public'   => false,
        ],
    ];

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

    /**
     * Parse flat Shaarli bookmarks (no directories).
     */
    public function testParseFlat(): void
    {
        $content = file_get_contents(self::FIXTURE_DIRECTORY . 'input/shaarli_with_tabs_and_spaces.htm');
        $result = $this->decoder->decode($content);

        $expected = [
            [
                'name' => 'Note: Code tests',
                'image'  => null,
                'url'   => '?KvNdlQ',
                'tags'  => ['dev'],
                'description'  => null,
                'dateCreated'  => 1591456706,
                'public'   => false,
            ],
        ];
        $expected[0]['description'] = trim(
            file_get_contents(self::FIXTURE_DIRECTORY . 'output/shaarli_with_tabs_and_spaces.txt')
        );

        $this->assertSame($expected, $result);
    }

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

    protected function setUp(): void
    {
        $context = [
            NetscapeBookmarkDecoder::KEEP_NESTED_TAGS => false,
        ];

        $this->decoder = new NetscapeBookmarkDecoder($context);
    }

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