1
1
<?php
2
2
3
- namespace Tests \Feature ;
3
+ namespace Tests \Feature \ Crud ;
4
4
5
5
use Tests \TestCase ;
6
6
use Tests \RefreshPacker ;
@@ -20,7 +20,7 @@ public function test_it_can_create_a_crud_for_a_json_file()
20
20
{
21
21
Artisan::call ('crud:json Test ' );
22
22
Artisan::call ('crud:make Test ' );
23
- $ this ->isFileExists ('src/Test.php ' );
23
+ $ this ->isFileExists ('src/Models/ Test.php ' );
24
24
$ this ->isFileExists ('src/database/factories/TestFactory.php ' );
25
25
$ this ->assertEquals (1 , count (glob ($ this ->_testPath () . 'src/database/migrations/*_create_tests_table.php ' )));
26
26
$ this ->isFileExists ('src/Http/controllers/TestController.php ' );
@@ -30,13 +30,14 @@ public function test_it_can_create_a_crud_for_a_json_file()
30
30
31
31
public function test_it_create_class_based_factory ()
32
32
{
33
- Artisan::call ('crud:json Test ' );
34
- Artisan::call ('crud:make Test ' );
35
- $ this ->isFileExists ('src/database/factories/TestFactory .php ' );
36
- $ content = file_get_contents ($ this ->_testPath () . 'src/database/factories/TestFactory .php ' );
37
- $ this ->assertStringContainsString ('protected $model = Test ::class; ' , $ content );
38
- $ this ->assertStringContainsString ('use Bitfumes\TestApp\Test ; ' , $ content );
33
+ Artisan::call ('crud:json User ' );
34
+ Artisan::call ('crud:make User ' );
35
+ $ this ->isFileExists ('src/database/factories/UserFactory .php ' );
36
+ $ content = file_get_contents ($ this ->_testPath () . 'src/database/factories/UserFactory .php ' );
37
+ $ this ->assertStringContainsString ('protected $model = User ::class; ' , $ content );
38
+ $ this ->assertStringContainsString ('use Bitfumes\TestApp\Models\User ; ' , $ content );
39
39
$ this ->assertStringContainsString ('namespace Bitfumes\TestApp\Database\Factories; ' , $ content );
40
+ $ this ->assertStringContainsString ('\'title \' => $this->faker->word ' , $ content );
40
41
}
41
42
42
43
public function test_it_create_tests_properly ()
@@ -46,6 +47,25 @@ public function test_it_create_tests_properly()
46
47
$ this ->isFileExists ('/tests/Feature/UserTest.php ' );
47
48
$ content = file_get_contents ($ this ->_testPath () . '/tests/Feature/UserTest.php ' );
48
49
$ this ->assertStringContainsString ('class UserTest ' , $ content );
50
+ $ this ->assertStringContainsString ('use Bitfumes\TestApp\Models\User; ' , $ content );
49
51
$ this ->assertStringContainsString ('User::factory()->count($num)->create($args); ' , $ content );;
50
52
}
53
+
54
+ public function test_it_create_model_on_models_dir_with_correct_namespace ()
55
+ {
56
+ Artisan::call ('crud:json User ' );
57
+ Artisan::call ('crud:make User ' );
58
+ $ this ->isFileExists ('src/models/User.php ' );
59
+ $ content = file_get_contents ($ this ->_testPath () . 'src/models/User.php ' );
60
+ $ this ->assertStringContainsString ('class User extends Model ' , $ content );
61
+ $ this ->assertStringContainsString ('namespace Bitfumes\TestApp\Models; ' , $ content );
62
+ }
63
+
64
+ public function test_it_add_resource_route ()
65
+ {
66
+ Artisan::call ('crud:json User ' );
67
+ Artisan::call ('crud:make User ' );
68
+ $ content = file_get_contents ($ this ->_testPath () . 'src/Http/routes.php ' );
69
+ $ this ->assertStringContainsString ("Route::apiResource('user','UserController::class); " , $ content );
70
+ }
51
71
}
0 commit comments