mshamaseen /
laravel-repositories
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Shamaseen\Repository\Tests\Feature; |
||||
| 4 | |||||
| 5 | use Shamaseen\Repository\PathResolver; |
||||
| 6 | use Shamaseen\Repository\Tests\TestCase; |
||||
| 7 | |||||
| 8 | class UngenerateFilesTest extends TestCase |
||||
| 9 | { |
||||
| 10 | private array $filesToGenerate = ['Controller', 'Repository', 'Model', 'Request', 'Resource', 'Collection', 'Policy', 'Test']; |
||||
| 11 | |||||
| 12 | protected string $modelName = 'Test'; |
||||
| 13 | protected string $userPath = 'Tests'; |
||||
| 14 | |||||
| 15 | /** |
||||
| 16 | * @param string $dataName |
||||
| 17 | */ |
||||
| 18 | public function __construct(?string $name = null, array $data = [], $dataName = '') |
||||
| 19 | { |
||||
| 20 | parent::__construct($name, $data, $dataName); |
||||
|
0 ignored issues
–
show
It seems like
$name can also be of type null; however, parameter $name of PHPUnit\Framework\TestCase::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 21 | } |
||||
| 22 | |||||
| 23 | public function testUngenerate() |
||||
| 24 | { |
||||
| 25 | $this->artisan("ungenerate:repository $this->userPath/$this->modelName") |
||||
| 26 | ->expectsConfirmation('This will delete Test files and folder, Do you want to continue ?', 'yes'); |
||||
| 27 | |||||
| 28 | foreach ($this->filesToGenerate as $type) { |
||||
| 29 | $outputPath = $this->generator->absolutePath($this->pathResolver->outputPath($type)); |
||||
| 30 | $this->assertFileDoesNotExist($outputPath); |
||||
| 31 | } |
||||
| 32 | } |
||||
| 33 | } |
||||
| 34 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.