-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathGeneratorBasicTest.php
More file actions
43 lines (35 loc) · 1.54 KB
/
GeneratorBasicTest.php
File metadata and controls
43 lines (35 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Bow\Tests\Console;
use Bow\Console\Generator;
class GeneratorBasicTest extends \PHPUnit\Framework\TestCase
{
public function test_generate_stubs()
{
$generator = new Generator(TESTING_RESOURCE_BASE_DIRECTORY, 'CreateUserCommand');
$content = $generator->makeStubContent('command', [
"namespace" => "",
"className" => "CreateUserCommand",
"baseNamespace" => "Generator\Testing",
]);
$this->assertNotNull($content);
$this->assertMatchesRegularExpression("@\nnamespace\sGenerator\\\Testing;\n@", $content);
$this->assertMatchesRegularExpression("@\nclass\sCreateUserCommand\sextends\sConsoleCommand\n@", $content);
}
public function test_generate_stub_without_data()
{
$generator = new Generator(TESTING_RESOURCE_BASE_DIRECTORY, 'CreateUserCommand');
$content = $generator->makeStubContent('command', []);
$this->assertNotNull($content);
$this->assertMatchesRegularExpression("@\nnamespace\s\{baseNamespace\}\{namespace\};\n@", $content);
$this->assertMatchesRegularExpression("@\nclass\s\{className\}\sextends\sConsoleCommand\n@", $content);
}
public function test_generate_by_writing_file()
{
$generator = new Generator(TESTING_RESOURCE_BASE_DIRECTORY, 'CreateUserCommand');
$result = $generator->write('command', [
"baseNamespace" => "Generator\Testing",
]);
$this->assertTrue($result);
$this->assertTrue(file_exists($generator->getPath()));
}
}