1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00
psalm/tests/DocCommentTest.php
Kolja Zuelsdorf 08855c806f
Dont add newline before return (#2969)
* Added method to not add newline before return in docblock.

* Made setting of newline before return statically setable on docblock.

* Created psalter parameter for setting of newline before return in doc block annotation.

* Added tests to cover adding new line or not before return annotation in doc block via psalter.

* Psalm and style fixes.

* Changed flag for new lines between annotations to be considered for all annotations.

* Extended tests to reflect changed behavior for new lines between annotations in psalter.
2020-03-13 12:40:08 -04:00

122 lines
2.8 KiB
PHP

<?php
namespace Psalm\Tests;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Psalm\DocComment;
class DocCommentTest extends BaseTestCase
{
public function testNewLineIsAddedBetweenAnnotationsByDefault(): void
{
$docComment = [
'description' => 'some desc',
'specials' =>
[
'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
*/
';
$this->assertSame($expectedDoc, DocComment::render($docComment, ''));
}
public function testNewLineIsNotAddedBetweenAnnotationsIfDisabled(): void
{
DocComment::addNewLineBetweenAnnotations(false);
$docComment = [
'description' => 'some desc',
'specials' =>
[
'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
*/
';
$this->assertSame($expectedDoc, DocComment::render($docComment, ''));
}
public function testNewLineIsAddedBetweenAnnotationsIfEnabled(): void
{
DocComment::addNewLineBetweenAnnotations(true);
$docComment = [
'description' => 'some desc',
'specials' =>
[
'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
*/
';
$this->assertSame($expectedDoc, DocComment::render($docComment, ''));
}
}