Skip to content

Commit bcc2332

Browse files
authored
[TEST] Show that custom phpdoc tags without space afterwards are unexpectedly changed (#981)
* tests: show that custom phpdoc tags without space afterwards are unexpectedly changed This adds a test for the (current bug) behaviour of #666 If this ever gets fixed, this fails and needs to be adapted, ensuring it won't break again. * test: adapt now that #666 has been fixed
1 parent 7783185 commit bcc2332

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomPhpdocTags\Models;
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
9+
/**
10+
* The `@SuppressWarnings` tag below contains no space before the `(` but when
11+
* the class phpdoc is written back, one is inserted.
12+
*
13+
* @link https://github.com/barryvdh/laravel-ide-helper/issues/666
14+
*
15+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
16+
*/
17+
class Simple extends Model
18+
{
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomPhpdocTags;
6+
7+
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
8+
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
9+
10+
class Test extends AbstractModelsCommand
11+
{
12+
/**
13+
* This test makes sure that custom phpdoc tags are not mangled, e.g.
14+
* there are no spaces inserted etc.
15+
*
16+
* @link https://github.com/barryvdh/laravel-ide-helper/issues/666
17+
*/
18+
public function testNoSpaceAfterCustomPhpdocTag(): void
19+
{
20+
$command = $this->app->make(ModelsCommand::class);
21+
22+
$tester = $this->runCommand($command, [
23+
'--write' => true,
24+
]);
25+
26+
$this->assertSame(0, $tester->getStatusCode());
27+
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
28+
$this->assertMatchesMockedSnapshot();
29+
}
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomPhpdocTags\Models;
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
9+
/**
10+
* The `@SuppressWarnings` tag below contains no space before the `(` but when
11+
* the class phpdoc is written back, one is inserted.
12+
*
13+
* @link https://github.com/barryvdh/laravel-ide-helper/issues/666
14+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
15+
* @property integer $id
16+
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
17+
* @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()
18+
* @method static \Illuminate\Database\Eloquent\Builder|Simple query()
19+
* @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value)
20+
* @mixin \Eloquent
21+
*/
22+
class Simple extends Model
23+
{
24+
}

0 commit comments

Comments
 (0)