123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <?php
- /**
- * This file is part of phpDocumentor.
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
- * @license http://www.opensource.org/licenses/mit-license.php MIT
- * @link http://phpdoc.org
- */
- namespace phpDocumentor\Reflection\DocBlock;
- use Mockery as m;
- use phpDocumentor\Reflection\DocBlock;
- /**
- * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Serializer
- * @covers ::<private>
- */
- class SerializerTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @covers ::__construct
- * @covers ::getDocComment
- * @uses phpDocumentor\Reflection\DocBlock\Description
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
- * @uses phpDocumentor\Reflection\DocBlock
- * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
- */
- public function testReconstructsADocCommentFromADocBlock()
- {
- $expected = <<<'DOCCOMMENT'
- /**
- * This is a summary
- *
- * This is a description
- *
- * @unknown-tag Test description for the unknown tag
- */
- DOCCOMMENT;
- $fixture = new Serializer();
- $docBlock = new DocBlock(
- 'This is a summary',
- new Description('This is a description'),
- [
- new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
- ]
- );
- $this->assertSame($expected, $fixture->getDocComment($docBlock));
- }
- /**
- * @covers ::__construct
- * @covers ::getDocComment
- * @uses phpDocumentor\Reflection\DocBlock\Description
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
- * @uses phpDocumentor\Reflection\DocBlock
- * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
- */
- public function testAddPrefixToDocBlock()
- {
- $expected = <<<'DOCCOMMENT'
- aa/**
- aa * This is a summary
- aa *
- aa * This is a description
- aa *
- aa * @unknown-tag Test description for the unknown tag
- aa */
- DOCCOMMENT;
- $fixture = new Serializer(2, 'a');
- $docBlock = new DocBlock(
- 'This is a summary',
- new Description('This is a description'),
- [
- new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
- ]
- );
- $this->assertSame($expected, $fixture->getDocComment($docBlock));
- }
- /**
- * @covers ::__construct
- * @covers ::getDocComment
- * @uses phpDocumentor\Reflection\DocBlock\Description
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
- * @uses phpDocumentor\Reflection\DocBlock
- * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
- */
- public function testAddPrefixToDocBlockExceptFirstLine()
- {
- $expected = <<<'DOCCOMMENT'
- /**
- aa * This is a summary
- aa *
- aa * This is a description
- aa *
- aa * @unknown-tag Test description for the unknown tag
- aa */
- DOCCOMMENT;
- $fixture = new Serializer(2, 'a', false);
- $docBlock = new DocBlock(
- 'This is a summary',
- new Description('This is a description'),
- [
- new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
- ]
- );
- $this->assertSame($expected, $fixture->getDocComment($docBlock));
- }
- /**
- * @covers ::__construct
- * @covers ::getDocComment
- * @uses phpDocumentor\Reflection\DocBlock\Description
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
- * @uses phpDocumentor\Reflection\DocBlock
- * @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
- * @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
- */
- public function testWordwrapsAroundTheGivenAmountOfCharacters()
- {
- $expected = <<<'DOCCOMMENT'
- /**
- * This is a
- * summary
- *
- * This is a
- * description
- *
- * @unknown-tag
- * Test
- * description
- * for the
- * unknown tag
- */
- DOCCOMMENT;
- $fixture = new Serializer(0, '', true, 15);
- $docBlock = new DocBlock(
- 'This is a summary',
- new Description('This is a description'),
- [
- new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
- ]
- );
- $this->assertSame($expected, $fixture->getDocComment($docBlock));
- }
- /**
- * @covers ::__construct
- * @expectedException \InvalidArgumentException
- */
- public function testInitializationFailsIfIndentIsNotAnInteger()
- {
- new Serializer([]);
- }
- /**
- * @covers ::__construct
- * @expectedException \InvalidArgumentException
- */
- public function testInitializationFailsIfIndentStringIsNotAString()
- {
- new Serializer(0, []);
- }
- /**
- * @covers ::__construct
- * @expectedException \InvalidArgumentException
- */
- public function testInitializationFailsIfIndentFirstLineIsNotABoolean()
- {
- new Serializer(0, '', []);
- }
- /**
- * @covers ::__construct
- * @expectedException \InvalidArgumentException
- */
- public function testInitializationFailsIfLineLengthIsNotNullNorAnInteger()
- {
- new Serializer(0, '', false, []);
- }
- }
|