|
3 | 3 | namespace Tests\Commands; |
4 | 4 |
|
5 | 5 | use DragonCode\LaravelActions\Constants\Names; |
| 6 | +use DragonCode\Support\Facades\Filesystem\File; |
6 | 7 | use Tests\TestCase; |
7 | 8 |
|
8 | 9 | class MakeTest extends TestCase |
@@ -107,4 +108,34 @@ public function testNestedLeftSlashWithExtension() |
107 | 108 | file_get_contents($path) |
108 | 109 | ); |
109 | 110 | } |
| 111 | + |
| 112 | + public function testFromCustomizedStub() |
| 113 | + { |
| 114 | + $name = 'MakeExample'; |
| 115 | + |
| 116 | + $stubPath = base_path('stubs/action.stub'); |
| 117 | + |
| 118 | + $actionPath = $this->getActionsPath() . '/' . date('Y_m_d_His') . '_make_example.php'; |
| 119 | + |
| 120 | + $this->assertFileDoesNotExist($stubPath); |
| 121 | + |
| 122 | + File::copy(__DIR__ . '/../fixtures/app/stubs/customized.stub', $stubPath); |
| 123 | + |
| 124 | + $this->assertFileExists($stubPath); |
| 125 | + $this->assertFileDoesNotExist($actionPath); |
| 126 | + |
| 127 | + $this->artisan(Names::MAKE, compact('name'))->assertExitCode(0); |
| 128 | + |
| 129 | + $this->assertFileExists($actionPath); |
| 130 | + |
| 131 | + $content = file_get_contents($actionPath); |
| 132 | + |
| 133 | + $this->assertStringContainsString('Foo\\Bar\\Some', $content); |
| 134 | + $this->assertStringContainsString('extends Some', $content); |
| 135 | + |
| 136 | + $this->assertStringNotContainsString('DragonCode\\LaravelActions\\Action', $content); |
| 137 | + $this->assertStringNotContainsString('extends Action', $content); |
| 138 | + $this->assertStringNotContainsString('Run the actions.', $content); |
| 139 | + $this->assertStringNotContainsString('@return void', $content); |
| 140 | + } |
110 | 141 | } |
0 commit comments