Skip to content

Commit f1e0b71

Browse files
committed
- Resolved dependencies issues in base TestCase class
- Added .gitignore
1 parent 376e99a commit f1e0b71

File tree

3 files changed

+74
-5
lines changed

3 files changed

+74
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/*
22
composer.lock
3-
.idea/*
3+
.idea/*
4+
.phpunit.result.cache

examples/tests/TestCase.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,34 @@
22

33
namespace Tests;
44

5+
use Illuminate\Contracts\Config\Repository;
6+
use Illuminate\Foundation\Application;
7+
use Illuminate\Support\Facades\Route;
8+
use Illuminate\Support\ServiceProvider;
9+
use Luezoid\Http\Controllers\MinionController;
10+
require_once __DIR__.'/../Controllers/MinionController.php';
11+
require_once __DIR__.'/../Repositories/MinionRepository.php';
12+
require_once __DIR__.'/../Requests/MinionCreateRequest.php';
13+
514
class TestCase extends \Orchestra\Testbench\TestCase
615
{
7-
use \Illuminate\Foundation\Testing\RefreshDatabase;
16+
/**
17+
* Get package providers.
18+
*
19+
* @param Application $app
20+
*
21+
* @return array<int, class-string<ServiceProvider>>
22+
*/
23+
protected function getPackageProviders($app): array
24+
{
25+
return [
26+
'Luezoid\Laravelcore\CoreServiceProvider',
27+
];
28+
}
29+
830
public function defineEnvironment($app)
931
{
10-
tap($app->make('config'), function (\Illuminate\Contracts\Config\Repository $config) {
32+
tap($app->make('config'), function (Repository $config) {
1133
$config->set('database.default', 'testbench');
1234
$config->set('database.connections.testbench', [
1335
'driver' => 'sqlite',
@@ -19,7 +41,7 @@ public function defineEnvironment($app)
1941

2042
protected function defineRoutes($router)
2143
{
22-
\Illuminate\Support\Facades\Route::resource('api/minions', 'MinionController', ['parameters' => ['minions' => 'id']]);
44+
Route::resource('api/minions', MinionController::class, ['parameters' => ['minions' => 'id']]);
2345
}
2446

2547
protected function defineDatabaseMigrations()

examples/tests/suite/PostAPISuccessTest.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
use Tests\TestCase;
66

7-
require_once __DIR__.'/../TestCase.php';
7+
require_once __DIR__ . '/../TestCase.php';
8+
require_once __DIR__ . '/../../Models/Minion.php';
89

910
class PostAPISuccessTest extends TestCase
1011
{
@@ -32,4 +33,49 @@ public function test_post_api()
3233
]);
3334
}
3435

36+
/*public function test_list_api()
37+
{
38+
$response = $this->get('/api/minions');
39+
$response->assertStatus(200);
40+
$response->assertJson([
41+
"message" => null,
42+
"data" => [
43+
"items" => [
44+
[
45+
"id" => 1,
46+
"name" => "Lucifer",
47+
"totalEyes" => 0,
48+
"favouriteSound" => "Luuuuuuu",
49+
"hasHairs" => true,
50+
"missions" => [],
51+
"leadingMission" => null
52+
]
53+
],
54+
"page" => 1,
55+
"total" => 1,
56+
"pages" => 1,
57+
"perpage" => 15
58+
],
59+
"type" => null
60+
]);
61+
}*/
62+
63+
/*public function test_show_api()
64+
{
65+
$response = $this->get('/api/minions/1');
66+
$response->assertStatus(200);
67+
$response->assertJson([
68+
"message" => null,
69+
"data" => [
70+
"id" => 1,
71+
"name" => "Lucifer",
72+
"totalEyes" => 0,
73+
"favouriteSound" => "Luuuuuuu",
74+
"hasHairs" => true,
75+
"missions" => [],
76+
"leadingMission" => null
77+
],
78+
"type" => null
79+
]);
80+
}*/
3581
}

0 commit comments

Comments
 (0)