mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-25 16:39:13 +01:00
db test and Travis CI integration
This commit is contained in:
parent
85fc616899
commit
507f2677dd
9
.env.travis
Normal file
9
.env.travis
Normal file
@ -0,0 +1,9 @@
|
||||
APP_ENV=testing
|
||||
APP_KEY=
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
DB_DATABASE=:memory:
|
||||
|
||||
CACHE_DRIVER=array
|
||||
SESSION_DRIVER=array
|
||||
QUEUE_DRIVER=sync
|
15
.travis.yml
Normal file
15
.travis.yml
Normal file
@ -0,0 +1,15 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- "7.2"
|
||||
|
||||
before_script:
|
||||
- cp .env.travis .env
|
||||
- composer self-update
|
||||
- composer install --no-interaction
|
||||
- php artisan key:generate
|
||||
- php artisan migrate --seed
|
||||
- php artisan passport:install
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit
|
@ -13,9 +13,9 @@ class UsersTableSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
User::create([
|
||||
'name' => 'bubka',
|
||||
'email' => 'edouard@ganeau.me',
|
||||
'password' => bcrypt('bubka'),
|
||||
'name' => 'testLogin',
|
||||
'email' => 'test@test.com',
|
||||
'password' => bcrypt('test'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
</filter>
|
||||
<php>
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
<server name="DB_CONNECTION" value="sqlite"/>
|
||||
<server name="DB_DATABASE" value=":memory:"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
<server name="CACHE_DRIVER" value="array"/>
|
||||
<server name="MAIL_DRIVER" value="array"/>
|
||||
|
@ -4,11 +4,15 @@
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
|
||||
class APITest extends TestCase
|
||||
{
|
||||
|
||||
use DatabaseMigrations;
|
||||
|
||||
|
||||
/**
|
||||
* test User creation via API
|
||||
*
|
||||
@ -17,9 +21,9 @@ class APITest extends TestCase
|
||||
public function testUserCreation()
|
||||
{
|
||||
$response = $this->json('POST', '/api/register', [
|
||||
'name' => 'Demo User',
|
||||
'email' => str_random(10) . '@phpunit.com',
|
||||
'password' => '12345',
|
||||
'name' => 'testCreate',
|
||||
'email' => str_random(10) . '@test.com',
|
||||
'password' => 'test',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)->assertJsonStructure([
|
||||
@ -36,8 +40,8 @@ public function testUserCreation()
|
||||
public function testUserLogin()
|
||||
{
|
||||
$response = $this->json('POST', '/api/login', [
|
||||
'email' => 'edouard@ganeau.me',
|
||||
'password' => 'bubka'
|
||||
'email' => 'test@test.com',
|
||||
'password' => 'test'
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)->assertJsonStructure([
|
||||
@ -58,8 +62,8 @@ public function testAccountCreation()
|
||||
|
||||
$response = $this->actingAs($user, 'api')
|
||||
->json('POST', '/api/account', [
|
||||
'name' => 'phpunit account #' . str_random(5),
|
||||
'secret' => '3GB2I2P365J575LS',
|
||||
'name' => 'testCreation',
|
||||
'secret' => 'test',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)->assertJson([
|
||||
@ -105,8 +109,8 @@ public function testAccountDeletion()
|
||||
$user = \App\User::find(1);
|
||||
|
||||
$account = \App\Account::create([
|
||||
'name' => 'To be deleted #' . str_random(5),
|
||||
'secret' => '12345'
|
||||
'name' => 'testDelete',
|
||||
'secret' => 'test'
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user, 'api')
|
||||
|
Loading…
Reference in New Issue
Block a user