Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit dbb55d1

Browse files
author
Carlos Villavicencio
committed
Add memory based testing
1 parent 6cdbdb2 commit dbb55d1

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

.github/workflows/laravel.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@ jobs:
2626
- name: Copy .env
2727
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
2828
- name: Install Dependencies
29-
run: composer install
29+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
3030
- name: Generate key
3131
run: php artisan key:generate --force
3232
- name: Directory Permissions
3333
run: chmod -R 777 storage bootstrap/cache
34-
- name: Create Database
35-
run: touch database/database-test.sqlite
3634
- name: Execute tests (Unit and Feature tests) via PHPUnit
3735
env:
3836
DB_CONNECTION: sqlite
3937
DB_DATABASE: database/database.sqlite
40-
run: |
41-
php artisan migrate --database=testing --force
42-
vendor/bin/phpunit
38+
run: vendor/bin/phpunit

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
install:
22
touch database/database.sqlite
3-
touch database/database-test.sqlite
43
composer install
54
php artisan key:generate --force
65
php artisan migrate --force

config/database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
'testing' => [
5656
'driver' => 'sqlite',
57-
'database' => database_path('database-test.sqlite'),
57+
'database' => ':memory:',
5858
'prefix' => '',
5959
],
6060

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</whitelist>
2020
</filter>
2121
<php>
22-
<server name="APP_server" value="testing"/>
22+
<server name="APP_ENV" value="testing"/>
2323
<server name="BCRYPT_ROUNDS" value="4"/>
2424
<server name="CACHE_DRIVER" value="array"/>
2525
<server name="SESSION_DRIVER" value="array"/>

tests/TestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,16 @@ public function createApplication()
2222

2323
return $app;
2424
}
25+
26+
protected function setUp(): void
27+
{
28+
parent::setUp();
29+
Artisan::call('migrate');
30+
}
31+
32+
protected function tearDown(): void
33+
{
34+
Artisan::call('migrate:reset');
35+
parent::tearDown();
36+
}
2537
}

0 commit comments

Comments
 (0)