Passed
Push — main ( a090f0...c348a6 )
by Mohammad
11:53
created

UngenerateFilesTest::testUngenerate()   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 Shamaseen\Repository\PathResolver;
6
use Shamaseen\Repository\Tests\TestCase;
7
8
class UngenerateFilesTest 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 testUngenerate()
35
    {
36
        $this->artisan("ungenerate:repository $this->userPath/$this->modelName")
37
            ->expectsConfirmation('This will delete Test files and folder, Do you want to continue ?', 'yes');
38
39
        foreach ($this->filesToGenerate as $type) {
40
            $outputPath = $this->pathResolver->absolutePath($type);
41
            $this->assertFileDoesNotExist($outputPath);
42
        }
43
    }
44
}
45