Passed
Push — main ( a4aaf2...4acb8c )
by Mohammad
05:43 queued 02:51
created

GenerateFilesTest::testGenerateMCROnly()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Shamaseen\Repository\Tests\Feature;
4
5
use Shamaseen\Repository\PathResolver;
6
use Shamaseen\Repository\Tests\TestCase;
7
8
class GenerateFilesTest extends TestCase
9
{
10
    /**
11
     * @var mixed
12
     */
13
    private PathResolver $pathResolver;
14
15
    private array $filesToGenerate = ['Controller', 'Repository', 'Model', 'Request', 'Resource', 'Collection', 'Policy'];
16
17
    protected string $modelName = 'Test';
18
    protected string $userPath = 'Tests';
19
20
    /**
21
     * @param string $dataName
22
     */
23
    public function __construct(?string $name = null, array $data = [], $dataName = '')
24
    {
25
        parent::__construct($name, $data, $dataName);
26
    }
27
28
    public function setUp(): void
29
    {
30
        parent::setUp();
31
        $this->pathResolver = new PathResolver($this->modelName, $this->userPath, config('repository.base_path'));
32
    }
33
34
    public function testGenerate()
35
    {
36
        $this->artisan("generate:repository $this->userPath/$this->modelName -f");
37
38
        foreach ($this->filesToGenerate as $type) {
39
            $absolutePath = $this->pathResolver->absolutePath($type);
40
41
            $this->assertFileExists($absolutePath);
42
        }
43
    }
44
45
    public function testGenerateMCROnly()
46
    {
47
        $this->artisan("generate:repository $this->userPath/$this->modelName -f -mrc");
48
49
        $filesToGenerate = ['Controller', 'Repository', 'Model'];
50
        foreach ($filesToGenerate as $type) {
51
            $absolutePath = $this->pathResolver->absolutePath($type);
52
53
            $this->assertFileExists($absolutePath);
54
        }
55
    }
56
}
57