File tree Expand file tree Collapse file tree 3 files changed +21
-25
lines changed Expand file tree Collapse file tree 3 files changed +21
-25
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class FileSystemMock
1717 public ?array $ testClasses = null ;
1818 public ?array $ routes = null ;
1919 public ?array $ factories = null ;
20+ public ?array $ translations = null ;
2021
2122 public function setStructure (): void
2223 {
@@ -106,6 +107,14 @@ public function setStructure(): void
106107 }
107108 }
108109
110+ if (!is_null ($ this ->translations )) {
111+ $ structure ['resources ' ]['lang ' ]['en ' ] = [];
112+
113+ foreach ($ this ->translations as $ translation => $ content ) {
114+ $ structure ['resources ' ]['lang ' ]['en ' ][$ translation ] = $ content ;
115+ }
116+ }
117+
109118 vfsStream::create ($ structure );
110119 }
111120}
Original file line number Diff line number Diff line change 22
33namespace RonasIT \Support \Tests \Support \Translation ;
44
5- use org \ bovigo \ vfs \ vfsStream ;
5+ use RonasIT \ Support \ Tests \ Support \ FileSystemMock ;
66use RonasIT \Support \Tests \Support \GeneratorMockTrait ;
7- use RonasIT \Support \Traits \MockTrait ;
87
98trait TranslationMockTrait
109{
11- use GeneratorMockTrait, MockTrait ;
10+ use GeneratorMockTrait;
1211
1312 public function mockFilesystem (): void
1413 {
15- $ structure = [
16- 'resources ' => [
17- 'lang ' => [
18- 'en ' => [],
19- ],
20- ],
21- ];
22-
23- vfsStream::create ($ structure );
14+ $ fileSystemMock = new FileSystemMock ;
15+
16+ $ fileSystemMock ->translations = [];
17+
18+ $ fileSystemMock ->setStructure ();
2419 }
2520
2621 public function mockFilesystemForAppend (): void
2722 {
2823 $ validation = file_get_contents (getcwd () . '/tests/Support/Translation/validation_without_exceptions.php ' );
2924
30- $ structure = [
31- 'resources ' => [
32- 'lang ' => [
33- 'en ' => [
34- 'validation.php ' => $ validation ,
35- ],
36- ],
37- ],
38- ];
39-
40- vfsStream::create ($ structure );
25+ $ fileSystemMock = new FileSystemMock ;
26+
27+ $ fileSystemMock ->translations = ['validation.php ' => $ validation ];
28+
29+ $ fileSystemMock ->setStructure ();
4130 }
4231}
Original file line number Diff line number Diff line change @@ -37,8 +37,6 @@ public function testCreateStubNotExist()
3737 {
3838 config (['entity-generator.stubs.validation ' => 'incorrect_stub ' ]);
3939
40- $ this ->mockFilesystem ();
41-
4240 app (TranslationsGenerator::class)
4341 ->setModel ('Post ' )
4442 ->generate ();
You can’t perform that action at this time.
0 commit comments