annotate vendor/nikic/php-parser/test/PhpParser/CommentTest.php @ 2:92f882872392

Trusted hosts, + remove migration modules
author Chris Cannam
date Tue, 05 Dec 2017 09:26:43 +0000
parents 4c8ae668cc8c
children 5fb285c0d0e3
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace PhpParser;
Chris@0 4
Chris@0 5 class CommentTest extends \PHPUnit_Framework_TestCase
Chris@0 6 {
Chris@0 7 public function testGetSet() {
Chris@0 8 $comment = new Comment('/* Some comment */', 1, 10);
Chris@0 9
Chris@0 10 $this->assertSame('/* Some comment */', $comment->getText());
Chris@0 11 $this->assertSame('/* Some comment */', (string) $comment);
Chris@0 12 $this->assertSame(1, $comment->getLine());
Chris@0 13 $this->assertSame(10, $comment->getFilePos());
Chris@0 14 }
Chris@0 15
Chris@0 16 /**
Chris@0 17 * @dataProvider provideTestReformatting
Chris@0 18 */
Chris@0 19 public function testReformatting($commentText, $reformattedText) {
Chris@0 20 $comment = new Comment($commentText);
Chris@0 21 $this->assertSame($reformattedText, $comment->getReformattedText());
Chris@0 22 }
Chris@0 23
Chris@0 24 public function provideTestReformatting() {
Chris@0 25 return array(
Chris@0 26 array('// Some text' . "\n", '// Some text'),
Chris@0 27 array('/* Some text */', '/* Some text */'),
Chris@0 28 array(
Chris@0 29 '/**
Chris@0 30 * Some text.
Chris@0 31 * Some more text.
Chris@0 32 */',
Chris@0 33 '/**
Chris@0 34 * Some text.
Chris@0 35 * Some more text.
Chris@0 36 */'
Chris@0 37 ),
Chris@0 38 array(
Chris@0 39 '/*
Chris@0 40 Some text.
Chris@0 41 Some more text.
Chris@0 42 */',
Chris@0 43 '/*
Chris@0 44 Some text.
Chris@0 45 Some more text.
Chris@0 46 */'
Chris@0 47 ),
Chris@0 48 array(
Chris@0 49 '/* Some text.
Chris@0 50 More text.
Chris@0 51 Even more text. */',
Chris@0 52 '/* Some text.
Chris@0 53 More text.
Chris@0 54 Even more text. */'
Chris@0 55 ),
Chris@0 56 array(
Chris@0 57 '/* Some text.
Chris@0 58 More text.
Chris@0 59 Indented text. */',
Chris@0 60 '/* Some text.
Chris@0 61 More text.
Chris@0 62 Indented text. */',
Chris@0 63 ),
Chris@0 64 // invalid comment -> no reformatting
Chris@0 65 array(
Chris@0 66 'hallo
Chris@0 67 world',
Chris@0 68 'hallo
Chris@0 69 world',
Chris@0 70 ),
Chris@0 71 );
Chris@0 72 }
Chris@0 73 }