Skip to content

Commit

Permalink
tests: show that custom phpdoc tags without space afterwards are unex…
Browse files Browse the repository at this point in the history
…pectedly changed

This adds a test for the (current bug) behaviour of barryvdh#666

If this ever gets fixed, this fails and needs to be adapted,
ensuring it won't break again.
  • Loading branch information
mfn committed Feb 16, 2024
1 parent 7783185 commit ba557cb
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Console/ModelsCommand/CustomPhpdocTags/Models/Simple.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomPhpdocTags\Models;

use Illuminate\Database\Eloquent\Model;

/**
* The `@SuppressWarnings` tag below contains no space before the `(` but when
* the class phpdoc is written back, one is inserted.
*
* @link https://github.com/barryvdh/laravel-ide-helper/issues/666
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class Simple extends Model
{
}
40 changes: 40 additions & 0 deletions tests/Console/ModelsCommand/CustomPhpdocTags/Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomPhpdocTags;

use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;

class Test extends AbstractModelsCommand
{
/**
* This test shows that, when adding custom phpdoc tags with a parameter
* but without a space, they're changed when writing break, possibly breaking
* tools.
*
* It is changed from
* - `@SuppressWarnings(PHPMD.ExcessiveClassComplexity)`
* to
* - `@SuppressWarnings (PHPMD.ExcessiveClassComplexity)`
*
* If this test fails because the issue has been fixed, please keep the
* test but adjust it and it's comments, to prevent this from every breaking
* again.
*
* @link https://github.com/barryvdh/laravel-ide-helper/issues/666
*/
public function testNoSpaceAfterCustomPhpdocTag(): void
{
$command = $this->app->make(ModelsCommand::class);

$tester = $this->runCommand($command, [
'--write' => true,
]);

$this->assertSame(0, $tester->getStatusCode());
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
$this->assertMatchesMockedSnapshot();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomPhpdocTags\Models;

use Illuminate\Database\Eloquent\Model;

/**
* The `@SuppressWarnings` tag below contains no space before the `(` but when
* the class phpdoc is written back, one is inserted.
*
* @link https://github.com/barryvdh/laravel-ide-helper/issues/666
* @SuppressWarnings (PHPMD.ExcessiveClassComplexity)
* @property integer $id
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Simple query()
* @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value)
* @mixin \Eloquent
*/
class Simple extends Model
{
}

0 comments on commit ba557cb

Please sign in to comment.