1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00
psalm/tests/DocCommentTest.php

120 lines
2.6 KiB
PHP
Raw Normal View History

<?php
namespace Psalm\Tests;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Psalm\DocComment;
2020-05-29 04:14:41 +02:00
use Psalm\Internal\Scanner\ParsedDocblock;
class DocCommentTest extends BaseTestCase
{
public function testNewLineIsAddedBetweenAnnotationsByDefault(): void
{
2020-05-29 04:14:41 +02:00
$docComment = new ParsedDocblock(
'* some desc' . "\n*",
[
'param' =>
[
2 => 'string $bli',
3 => 'int $bla',
],
'throws' =>
[
0 => '\Exception',
],
'return' =>
[
0 => 'bool',
],
]
);
$expectedDoc = '/**
* some desc
*
* @param string $bli
* @param int $bla
*
* @throws \Exception
*
* @return bool
*/
';
2020-05-29 04:14:41 +02:00
$this->assertSame($expectedDoc, $docComment->render(''));
}
public function testNewLineIsNotAddedBetweenAnnotationsIfDisabled(): void
{
2020-05-29 04:14:41 +02:00
ParsedDocblock::addNewLineBetweenAnnotations(false);
2020-05-29 04:14:41 +02:00
$docComment = new ParsedDocblock(
'* some desc' . "\n*",
[
'param' =>
[
2 => 'string $bli',
3 => 'int $bla',
],
'throws' =>
[
0 => '\Exception',
],
'return' =>
[
0 => 'bool',
],
]
);
$expectedDoc = '/**
* some desc
*
* @param string $bli
* @param int $bla
* @throws \Exception
* @return bool
*/
';
2020-05-29 04:14:41 +02:00
$this->assertSame($expectedDoc, $docComment->render(''));
}
public function testNewLineIsAddedBetweenAnnotationsIfEnabled(): void
{
2020-05-29 04:14:41 +02:00
ParsedDocblock::addNewLineBetweenAnnotations(true);
2020-05-29 04:14:41 +02:00
$docComment = new ParsedDocblock(
'* some desc' . "\n*",
[
'param' =>
[
2 => 'string $bli',
3 => 'int $bla',
],
'throws' =>
[
0 => '\Exception',
],
'return' =>
[
0 => 'bool',
],
]
);
$expectedDoc = '/**
* some desc
*
* @param string $bli
* @param int $bla
*
* @throws \Exception
*
* @return bool
*/
';
2020-05-29 04:14:41 +02:00
$this->assertSame($expectedDoc, $docComment->render(''));
}
}