forked from barryvdh/laravel-ide-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: show that custom phpdoc tags without space afterwards are unex…
…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
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
tests/Console/ModelsCommand/CustomPhpdocTags/Models/Simple.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ModelsCommand/CustomPhpdocTags/__snapshots__/Test__testNoSpaceAfterCustomPhpdocTag__1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} |