File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ protected function getPath(): string
5757
5858 protected function getStubFilepath (): string
5959 {
60+ // check for custom stub file
61+ if (File::exists (base_path ('stubs/one-time-operation.stub ' ))) {
62+ return File::get (base_path ('stubs/one-time-operation.stub ' ));
63+ }
64+
6065 if ($ this ->essential ) {
6166 return File::get (__DIR__ .'/../stubs/one-time-operation-essential.stub ' );
6267 }
Original file line number Diff line number Diff line change @@ -25,4 +25,22 @@ public function it_creates_an_operation_file_instance()
2525
2626 File::delete ($ filepath );
2727 }
28+
29+ /** @test */
30+ public function it_creates_an_operation_file_with_custom_stub ()
31+ {
32+ $ mockFile = File::partialMock ();
33+ $ mockFile ->allows ('exists ' )->with (base_path ('stubs/one-time-operation.stub ' ))->andReturnTrue ();
34+ $ mockFile ->allows ('get ' )->with (base_path ('stubs/one-time-operation.stub ' ))->andReturns ('This is a custom stub ' );
35+
36+ $ directory = Config::get ('one-time-operations.directory ' );
37+ $ filepath = base_path ($ directory ).DIRECTORY_SEPARATOR .'2015_10_21_072800_test_operation.php ' ;
38+
39+ OneTimeOperationCreator::createOperationFile ('TestOperation ' );
40+
41+ $ this ->assertFileExists ($ filepath );
42+ $ this ->assertStringContainsString ('This is a custom stub ' , File::get ($ filepath ));
43+
44+ File::delete ($ filepath );
45+ }
2846}
You can’t perform that action at this time.
0 commit comments