Skip to content

Commit 3fc7139

Browse files
committed
Update tests due to last changes
1 parent 9b0fc12 commit 3fc7139

File tree

5 files changed

+28
-42
lines changed

5 files changed

+28
-42
lines changed

.github/workflows/fix-php-code-style-issues.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/run-tests.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
os: [ ubuntu-latest, windows-latest ]
16-
php: [ 8.1 ]
17-
laravel: [ 10.*, 9.* ]
16+
php: [ 8.2 ]
17+
laravel: [ 11.* ]
1818
stability: [ prefer-stable ]
1919
include:
20-
- laravel: 9.*
21-
testbench: 7.*
22-
carbon: ^2.63
23-
- laravel: 10.*
24-
testbench: 8.*
20+
- laravel: 11.*
21+
testbench: 9.*
2522
carbon: ^2.63
2623

2724
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

build/report.junit.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<testsuites>
3-
<testsuite name="C:\laragon\www\custom-packages\laravel-api-resource-generator\phpunit.xml.dist" tests="3" assertions="5" errors="0" failures="0" skipped="0" time="0.209040">
4-
<testsuite name="Alibori Test Suite" tests="3" assertions="5" errors="0" failures="0" skipped="0" time="0.209040">
5-
<testsuite name="Tests\Feature\Test" file="tests\Feature\Test.php" tests="3" assertions="5" errors="0" failures="0" skipped="0" time="0.209040">
6-
<testcase name="it database users table has been created" file="tests\Feature\Test.php::it database users table has been created" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="1" time="0.159758"/>
7-
<testcase name="it can generate a resource" file="tests\Feature\Test.php::it can generate a resource" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="1" time="0.030781"/>
8-
<testcase name="it can generate a resource for multiple models" file="tests\Feature\Test.php::it can generate a resource for multiple models" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="3" time="0.018500"/>
3+
<testsuite name="C:\laragon\www\custom-packages\laravel-api-resource-generator\phpunit.xml.dist" tests="4" assertions="9" errors="0" failures="0" skipped="0" time="0.213201">
4+
<testsuite name="Alibori Test Suite" tests="4" assertions="9" errors="0" failures="0" skipped="0" time="0.213201">
5+
<testsuite name="Tests\Feature\Test" file="tests\Feature\Test.php" tests="4" assertions="9" errors="0" failures="0" skipped="0" time="0.213201">
6+
<testcase name="it database users table has been created" file="tests\Feature\Test.php::it database users table has been created" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="1" time="0.150717"/>
7+
<testcase name="it database posts table has been created" file="tests\Feature\Test.php::it database posts table has been created" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="1" time="0.008764"/>
8+
<testcase name="it can generate a resource" file="tests\Feature\Test.php::it can generate a resource" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="1" time="0.033379"/>
9+
<testcase name="it can generate a resource for multiple models" file="tests\Feature\Test.php::it can generate a resource for multiple models" class="Tests\Feature\Test" classname="Tests.Feature.Test" assertions="6" time="0.020341"/>
910
</testsuite>
1011
</testsuite>
1112
</testsuite>

database/migrations/create_users_table.php.stub

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ class CreateUsersTable extends Migration
1616

1717
$table->timestamps();
1818
});
19+
20+
Schema::create('posts', function (Blueprint $table) {
21+
$table->bigIncrements('id');
22+
23+
$table->string('title');
24+
25+
$table->timestamps();
26+
});
1927
}
2028
}

tests/Feature/Test.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
use Alibori\LaravelApiResourceGenerator\Console\GenerateApiResourceCommand;
88
use Illuminate\Support\Facades\DB;
99

10-
// Test to check if the migration is running well
10+
// Test to check if the migrations are running well
1111
it('database users table has been created', function (): void {
1212
expect(DB::table('users')->get())->toBeEmpty();
1313
});
1414

15+
it('database posts table has been created', function (): void {
16+
expect(DB::table('posts')->get())->toBeEmpty();
17+
});
18+
1519
// Test to check if GenerateApiResourceCommand is working well
1620
it('can generate a resource', function (): void {
1721
$command = $this->app->make(GenerateApiResourceCommand::class);
@@ -31,7 +35,10 @@
3135

3236
expect(file_exists(__DIR__.'/../../app/Http/Resources/UserResource.php'))->toBeTrue()
3337
->and(file_get_contents(__DIR__.'/../../app/Http/Resources/UserResource.php'))->toContain('string $email')
34-
->and(file_exists(__DIR__.'/../../app/Http/Resources/PostResource.php'))->toBeTrue();
38+
->and(file_get_contents(__DIR__.'/../../app/Http/Resources/UserResource.php'))->not->toContain('string $title')
39+
->and(file_exists(__DIR__.'/../../app/Http/Resources/PostResource.php'))->toBeTrue()
40+
->and(file_get_contents(__DIR__.'/../../app/Http/Resources/PostResource.php'))->toContain('string $title')
41+
->and(file_get_contents(__DIR__.'/../../app/Http/Resources/PostResource.php'))->not->toContain('string $name');
3542

3643
unlink(__DIR__.'/../../app/Http/Resources/UserResource.php');
3744
unlink(__DIR__.'/../../app/Http/Resources/PostResource.php');

0 commit comments

Comments
 (0)