Passed
Push — main ( d769d8...effbf8 )
by Mohammad
03:41
created

GenerateFilesTest::test_ungenerate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Shamaseen\Repository\Tests\Feature;
4
5
use App\Models\Tests\Test;
0 ignored issues
show
Bug introduced by
The type App\Models\Tests\Test was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Shamaseen\Repository\PathResolver;
7
use Shamaseen\Repository\Tests\TestCase;
8
9
class GenerateFilesTest extends TestCase
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private PathResolver $pathResolver;
15
16
    private array $filesToGenerate = ['Controller', 'Repository', 'Model', 'Request', 'Resource', 'Collection', 'Policy'];
17
18
    protected string $modelName = 'Test';
19
    protected string $userPath = 'Tests';
20
21
    /**
22
     * @param string $dataName
23
     */
24
    public function __construct(?string $name = null, array $data = [], $dataName = '')
25
    {
26
        parent::__construct($name, $data, $dataName);
27
    }
28
29
    public function setUp(): void
30
    {
31
        parent::setUp();
32
        $this->pathResolver = new PathResolver($this->modelName, $this->userPath, config('repository.base_path'));
33
    }
34
35
    public function test_generate()
36
    {
37
        $this->artisan("generate:repository $this->userPath/$this->modelName -f");
38
39
        foreach ($this->filesToGenerate as $type) {
40
            $absolutePath = $this->pathResolver->absolutePath($type);
41
42
            $this->assertFileExists($absolutePath);
43
        }
44
    }
45
}
46