@@ -14,17 +14,16 @@ class ServiceGeneratorTest extends TestCase
1414{
1515 use GeneratorMockTrait;
1616
17- public function testMissingModel ()
17+ public function testMissingRepository ()
1818 {
1919 $ this ->mockClass (ServiceGenerator::class, [
2020 $ this ->classExistsMethodCall (['repositories ' , 'PostRepository ' ], false ),
21- $ this ->classExistsMethodCall (['models ' , 'Post ' ], false ),
2221 ]);
2322
2423 $ this ->assertExceptionThrew (
2524 className: ClassNotExistsException::class,
26- message: 'Cannot create PostService cause Post Model does not exists. '
27- . "Create a Post Model by himself or run command 'php artisan make:entity Post --only-model ' " ,
25+ message: 'Cannot create PostService cause PostRepository does not exists. '
26+ . "Create a PostRepository by himself or run command 'php artisan make:entity Post --only-repository ' " ,
2827 );
2928
3029 app (ServiceGenerator::class)
@@ -34,57 +33,7 @@ className: ClassNotExistsException::class,
3433 Event::assertNothingDispatched ();
3534 }
3635
37- public function testCreateWithTrait ()
38- {
39- $ this ->mockClass (ServiceGenerator::class, [
40- $ this ->classExistsMethodCall (['repositories ' , 'PostRepository ' ], false ),
41- $ this ->classExistsMethodCall (['models ' , 'Post ' ]),
42- ]);
43-
44- app (ServiceGenerator::class)
45- ->setRelations (new RelationsDTO (
46- hasMany: ['Comment ' ],
47- belongsTo: ['User ' ],
48- ))
49- ->setFields ([
50- 'integer-required ' => ['media_id ' ],
51- 'string-required ' => ['body ' ],
52- 'string ' => ['title ' ]
53- ])
54- ->setModel ('Post ' )
55- ->generate ();
56-
57- $ this ->assertGeneratedFileEquals ('service_with_trait.php ' , 'app/Services/PostService.php ' );
58-
59- $ this ->assertEventPushed (
60- className: SuccessCreateMessage::class,
61- message: 'Created a new Service: PostService ' ,
62- );
63- }
64-
65- public function testCreateWithTraitStubNotExist ()
66- {
67- config (['entity-generator.stubs.service_with_trait ' => 'incorrect_stub ' ]);
68-
69- $ this ->mockClass (ServiceGenerator::class, [
70- $ this ->classExistsMethodCall (['repositories ' , 'PostRepository ' ], false ),
71- $ this ->classExistsMethodCall (['models ' , 'Post ' ]),
72- ]);
73-
74- app (ServiceGenerator::class)
75- ->setFields ([])
76- ->setModel ('Post ' )
77- ->generate ();
78-
79- $ this ->assertFileDoesNotExist ('app/Services/PostService.php ' );
80-
81- $ this ->assertEventPushed (
82- className: WarningEvent::class,
83- message: 'Generation of service with trait has been skipped cause the view incorrect_stub from the config entity-generator.stubs.service_with_trait is not exists. Please check that config has the correct view name value. ' ,
84- );
85- }
86-
87- public function testCreateWithoutTrait ()
36+ public function testCreate ()
8837 {
8938 $ this ->mockClass (ServiceGenerator::class, [
9039 $ this ->classExistsMethodCall (['repositories ' , 'PostRepository ' ]),
@@ -104,15 +53,15 @@ public function testCreateWithoutTrait()
10453 ->setModel ('Post ' )
10554 ->generate ();
10655
107- $ this ->assertGeneratedFileEquals ('service_without_trait .php ' , 'app/Services/PostService.php ' );
56+ $ this ->assertGeneratedFileEquals ('service .php ' , 'app/Services/PostService.php ' );
10857
10958 $ this ->assertEventPushed (
11059 className: SuccessCreateMessage::class,
11160 message: 'Created a new Service: PostService ' ,
11261 );
11362 }
11463
115- public function testCreateWithoutTraitStubNotExist ()
64+ public function testCreateStubNotExist ()
11665 {
11766 config (['entity-generator.stubs.service ' => 'incorrect_stub ' ]);
11867
0 commit comments