mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-28 19:23:11 +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()
|
public function run()
|
||||||
{
|
{
|
||||||
User::create([
|
User::create([
|
||||||
'name' => 'bubka',
|
'name' => 'testLogin',
|
||||||
'email' => 'edouard@ganeau.me',
|
'email' => 'test@test.com',
|
||||||
'password' => bcrypt('bubka'),
|
'password' => bcrypt('test'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
</filter>
|
</filter>
|
||||||
<php>
|
<php>
|
||||||
<server name="APP_ENV" value="testing"/>
|
<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="BCRYPT_ROUNDS" value="4"/>
|
||||||
<server name="CACHE_DRIVER" value="array"/>
|
<server name="CACHE_DRIVER" value="array"/>
|
||||||
<server name="MAIL_DRIVER" value="array"/>
|
<server name="MAIL_DRIVER" value="array"/>
|
||||||
|
@ -4,11 +4,15 @@
|
|||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Illuminate\Foundation\Testing\WithFaker;
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Auth\Authenticatable;
|
use Illuminate\Auth\Authenticatable;
|
||||||
|
|
||||||
class APITest extends TestCase
|
class APITest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
use DatabaseMigrations;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test User creation via API
|
* test User creation via API
|
||||||
*
|
*
|
||||||
@ -17,9 +21,9 @@ class APITest extends TestCase
|
|||||||
public function testUserCreation()
|
public function testUserCreation()
|
||||||
{
|
{
|
||||||
$response = $this->json('POST', '/api/register', [
|
$response = $this->json('POST', '/api/register', [
|
||||||
'name' => 'Demo User',
|
'name' => 'testCreate',
|
||||||
'email' => str_random(10) . '@phpunit.com',
|
'email' => str_random(10) . '@test.com',
|
||||||
'password' => '12345',
|
'password' => 'test',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertStatus(200)->assertJsonStructure([
|
$response->assertStatus(200)->assertJsonStructure([
|
||||||
@ -36,8 +40,8 @@ public function testUserCreation()
|
|||||||
public function testUserLogin()
|
public function testUserLogin()
|
||||||
{
|
{
|
||||||
$response = $this->json('POST', '/api/login', [
|
$response = $this->json('POST', '/api/login', [
|
||||||
'email' => 'edouard@ganeau.me',
|
'email' => 'test@test.com',
|
||||||
'password' => 'bubka'
|
'password' => 'test'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertStatus(200)->assertJsonStructure([
|
$response->assertStatus(200)->assertJsonStructure([
|
||||||
@ -58,8 +62,8 @@ public function testAccountCreation()
|
|||||||
|
|
||||||
$response = $this->actingAs($user, 'api')
|
$response = $this->actingAs($user, 'api')
|
||||||
->json('POST', '/api/account', [
|
->json('POST', '/api/account', [
|
||||||
'name' => 'phpunit account #' . str_random(5),
|
'name' => 'testCreation',
|
||||||
'secret' => '3GB2I2P365J575LS',
|
'secret' => 'test',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->assertStatus(200)->assertJson([
|
$response->assertStatus(200)->assertJson([
|
||||||
@ -105,8 +109,8 @@ public function testAccountDeletion()
|
|||||||
$user = \App\User::find(1);
|
$user = \App\User::find(1);
|
||||||
|
|
||||||
$account = \App\Account::create([
|
$account = \App\Account::create([
|
||||||
'name' => 'To be deleted #' . str_random(5),
|
'name' => 'testDelete',
|
||||||
'secret' => '12345'
|
'secret' => 'test'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->actingAs($user, 'api')
|
$response = $this->actingAs($user, 'api')
|
||||||
|
Loading…
Reference in New Issue
Block a user