PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/vendor/nikic/php-parser/test/PhpParser/CommentTest.php

https://bitbucket.org/alan_cordova/api-sb-map
PHP | 73 lines | 64 code | 5 blank | 4 comment | 0 complexity | 6479db8ab07c7fa53c19914ce58aab3f MD5 | raw file
 1<?php
 2
 3namespace PhpParser;
 4
 5class CommentTest extends \PHPUnit_Framework_TestCase
 6{
 7    public function testGetSet() {
 8        $comment = new Comment('/* Some comment */', 1, 10);
 9
10        $this->assertSame('/* Some comment */', $comment->getText());
11        $this->assertSame('/* Some comment */', (string) $comment);
12        $this->assertSame(1, $comment->getLine());
13        $this->assertSame(10, $comment->getFilePos());
14    }
15
16    /**
17     * @dataProvider provideTestReformatting
18     */
19    public function testReformatting($commentText, $reformattedText) {
20        $comment = new Comment($commentText);
21        $this->assertSame($reformattedText, $comment->getReformattedText());
22    }
23
24    public function provideTestReformatting() {
25        return array(
26            array('// Some text' . "\n", '// Some text'),
27            array('/* Some text */', '/* Some text */'),
28            array(
29                '/**
30     * Some text.
31     * Some more text.
32     */',
33                '/**
34 * Some text.
35 * Some more text.
36 */'
37            ),
38            array(
39                '/*
40        Some text.
41        Some more text.
42    */',
43                '/*
44    Some text.
45    Some more text.
46*/'
47            ),
48            array(
49                '/* Some text.
50       More text.
51       Even more text. */',
52                '/* Some text.
53   More text.
54   Even more text. */'
55            ),
56            array(
57                '/* Some text.
58       More text.
59         Indented text. */',
60                '/* Some text.
61   More text.
62     Indented text. */',
63            ),
64            // invalid comment -> no reformatting
65            array(
66                'hallo
67    world',
68                'hallo
69    world',
70            ),
71        );
72    }
73}