Test Failed
Push — master ( f85057...b192c0 )
by Dennis
04:02
created

makeCommandCreatesNewClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TildBJ\Seeder\Tests\Functional\Command;
5
6
use Nimut\TestingFramework\TestCase\UnitTestCase;
7
8
/**
9
 * Class SeederCommandControllerTest
10
 */
11
class SeederCommandControllerTest extends UnitTestCase
12
{
13
    protected $subject;
14
15
    public function setUp()
16
    {
17
        $this->subject = new \TildBJ\Seeder\Command\SeederCommandController();
18
        $output = $this->createMock(\TildBJ\Seeder\Utility\OutputUtility::class);
19
        $this->inject($this->subject, 'outputUtility', $output);
20
        $GLOBALS['TCA']['pages']['columns']['title'] = unserialize('a:2:{s:5:"label";s:36:"LLL:EXT:lang/locallang_tca.xlf:title";s:6:"config";a:4:{s:4:"type";s:5:"input";s:4:"size";s:2:"50";s:3:"max";s:3:"255";s:4:"eval";s:13:"trim,required";}}');
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function seedCommandThrowsExceptionIfTableConfigurationDoesNotExist()
27
    {
28
        $this->expectException(\InvalidArgumentException::class);
29
        $this->subject->seedCommand('SeedWhichNotExist');
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function makeCommandThrowsExceptionIfTableConfigurationDoesNotExist()
36
    {
37
        $this->expectException(\InvalidArgumentException::class);
38
        $this->subject->makeCommand('A', 'abc');
39
    }
40
41
    /**
42
     * @test
43
     */
44
    public function makeCommandThrowsExceptionIfClassAlreadyExist()
45
    {
46
        $this->expectException(\InvalidArgumentException::class);
47
        $this->subject->makeCommand('Image', 'pages');
48
    }
49
50
    /**
51
     * @test
52
     */
53
    public function makeCommandCreatesNewClass()
54
    {
55
        $file = realpath(dirname(__FILE__) . '/../../../Classes/Seeder/') . '/Test.php';
56
        $this->subject->makeCommand('Test', 'pages');
57
        $this->assertTrue(file_exists($file));
58
    }
59
60
    public function tearDown()
61
    {
62
        parent::tearDown();
63
        $file = realpath(dirname(__FILE__) . '/../../../Classes/Seeder/') . '/Test.php';
64
        if (file_exists($file)) {
65
            unlink($file);
66
        }
67
    }
68
}
69