Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / vendor / nikic / php-parser / test / PhpParser / CommentTest.php
1 <?php declare(strict_types=1);
2
3 namespace PhpParser;
4
5 use PHPUnit\Framework\TestCase;
6
7 class CommentTest extends TestCase
8 {
9     public function testGetSet() {
10         $comment = new Comment('/* Some comment */', 1, 10, 2);
11
12         $this->assertSame('/* Some comment */', $comment->getText());
13         $this->assertSame('/* Some comment */', (string) $comment);
14         $this->assertSame(1, $comment->getLine());
15         $this->assertSame(10, $comment->getFilePos());
16         $this->assertSame(2, $comment->getTokenPos());
17     }
18
19     /**
20      * @dataProvider provideTestReformatting
21      */
22     public function testReformatting($commentText, $reformattedText) {
23         $comment = new Comment($commentText);
24         $this->assertSame($reformattedText, $comment->getReformattedText());
25     }
26
27     public function provideTestReformatting() {
28         return [
29             ['// Some text' . "\n", '// Some text'],
30             ['/* Some text */', '/* Some text */'],
31             [
32                 '/**
33      * Some text.
34      * Some more text.
35      */',
36                 '/**
37  * Some text.
38  * Some more text.
39  */'
40             ],
41             [
42                 '/*
43         Some text.
44         Some more text.
45     */',
46                 '/*
47     Some text.
48     Some more text.
49 */'
50             ],
51             [
52                 '/* Some text.
53        More text.
54        Even more text. */',
55                 '/* Some text.
56    More text.
57    Even more text. */'
58             ],
59             [
60                 '/* Some text.
61        More text.
62          Indented text. */',
63                 '/* Some text.
64    More text.
65      Indented text. */',
66             ],
67             // invalid comment -> no reformatting
68             [
69                 'hallo
70     world',
71                 'hallo
72     world',
73             ],
74         ];
75     }
76 }