annotate vendor/nikic/php-parser/test/PhpParser/CommentTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author |
Chris Cannam |
date |
Mon, 23 Apr 2018 09:33:26 +0100 |
parents |
4c8ae668cc8c |
children |
129ea1e6d783 |
rev |
line source |
Chris@13
|
1 <?php declare(strict_types=1);
|
Chris@0
|
2
|
Chris@0
|
3 namespace PhpParser;
|
Chris@0
|
4
|
Chris@13
|
5 use PHPUnit\Framework\TestCase;
|
Chris@13
|
6
|
Chris@13
|
7 class CommentTest extends TestCase
|
Chris@0
|
8 {
|
Chris@0
|
9 public function testGetSet() {
|
Chris@13
|
10 $comment = new Comment('/* Some comment */', 1, 10, 2);
|
Chris@0
|
11
|
Chris@0
|
12 $this->assertSame('/* Some comment */', $comment->getText());
|
Chris@0
|
13 $this->assertSame('/* Some comment */', (string) $comment);
|
Chris@0
|
14 $this->assertSame(1, $comment->getLine());
|
Chris@0
|
15 $this->assertSame(10, $comment->getFilePos());
|
Chris@13
|
16 $this->assertSame(2, $comment->getTokenPos());
|
Chris@0
|
17 }
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * @dataProvider provideTestReformatting
|
Chris@0
|
21 */
|
Chris@0
|
22 public function testReformatting($commentText, $reformattedText) {
|
Chris@0
|
23 $comment = new Comment($commentText);
|
Chris@0
|
24 $this->assertSame($reformattedText, $comment->getReformattedText());
|
Chris@0
|
25 }
|
Chris@0
|
26
|
Chris@0
|
27 public function provideTestReformatting() {
|
Chris@13
|
28 return [
|
Chris@13
|
29 ['// Some text' . "\n", '// Some text'],
|
Chris@13
|
30 ['/* Some text */', '/* Some text */'],
|
Chris@13
|
31 [
|
Chris@0
|
32 '/**
|
Chris@0
|
33 * Some text.
|
Chris@0
|
34 * Some more text.
|
Chris@0
|
35 */',
|
Chris@0
|
36 '/**
|
Chris@0
|
37 * Some text.
|
Chris@0
|
38 * Some more text.
|
Chris@0
|
39 */'
|
Chris@13
|
40 ],
|
Chris@13
|
41 [
|
Chris@0
|
42 '/*
|
Chris@0
|
43 Some text.
|
Chris@0
|
44 Some more text.
|
Chris@0
|
45 */',
|
Chris@0
|
46 '/*
|
Chris@0
|
47 Some text.
|
Chris@0
|
48 Some more text.
|
Chris@0
|
49 */'
|
Chris@13
|
50 ],
|
Chris@13
|
51 [
|
Chris@0
|
52 '/* Some text.
|
Chris@0
|
53 More text.
|
Chris@0
|
54 Even more text. */',
|
Chris@0
|
55 '/* Some text.
|
Chris@0
|
56 More text.
|
Chris@0
|
57 Even more text. */'
|
Chris@13
|
58 ],
|
Chris@13
|
59 [
|
Chris@0
|
60 '/* Some text.
|
Chris@0
|
61 More text.
|
Chris@0
|
62 Indented text. */',
|
Chris@0
|
63 '/* Some text.
|
Chris@0
|
64 More text.
|
Chris@0
|
65 Indented text. */',
|
Chris@13
|
66 ],
|
Chris@0
|
67 // invalid comment -> no reformatting
|
Chris@13
|
68 [
|
Chris@0
|
69 'hallo
|
Chris@0
|
70 world',
|
Chris@0
|
71 'hallo
|
Chris@0
|
72 world',
|
Chris@13
|
73 ],
|
Chris@13
|
74 ];
|
Chris@0
|
75 }
|
Chris@13
|
76 }
|