Fix unit tests

This commit is contained in:
Bubka 2020-01-27 21:44:29 +01:00
parent 1433e7b550
commit baa9658e46
2 changed files with 5 additions and 6 deletions

View File

@ -43,7 +43,7 @@ class TwoFAccount extends Model
public function getIconAttribute($value) public function getIconAttribute($value)
{ {
if (\App::environment('testing') == false) { if (\App::environment('testing') == false) {
if( !Storage::exists('public/icons/' . pathinfo($value)['basename']) ) { if( !Storage::exists('public/icons/' . $value) ) {
return ''; return '';
} }
@ -62,7 +62,7 @@ public function getIconAttribute($value)
public function setIconAttribute($value) public function setIconAttribute($value)
{ {
if( !Storage::exists('public/icons/' . pathinfo($value)['basename']) ) { if( !Storage::exists('public/icons/' . $value) && \App::environment('testing') == false ) {
$this->attributes['icon'] = ''; $this->attributes['icon'] = '';
} }

View File

@ -140,10 +140,10 @@ public function testTOTPgeneration()
]); ]);
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/twofaccounts/' . $twofaccount->id . '/totp') ->json('GET', '/api/twofaccounts/' . $twofaccount->id . '/otp')
->assertStatus(200) ->assertStatus(200)
->assertJsonStructure([ ->assertJsonStructure([
'totp', 'otp',
]); ]);
} }
@ -161,7 +161,6 @@ public function testTwoFAccountUpdate()
->json('PUT', '/api/twofaccounts/' . $twofaccount->id, [ ->json('PUT', '/api/twofaccounts/' . $twofaccount->id, [
'service' => 'testUpdate', 'service' => 'testUpdate',
'account' => 'testUpdate@test.com', 'account' => 'testUpdate@test.com',
'uri' => 'testUpdate',
'icon' => 'testUpdate.png', 'icon' => 'testUpdate.png',
]) ])
->assertStatus(200) ->assertStatus(200)
@ -169,7 +168,7 @@ public function testTwoFAccountUpdate()
'id' => 1, 'id' => 1,
'service' => 'testUpdate', 'service' => 'testUpdate',
'account' => 'testUpdate@test.com', 'account' => 'testUpdate@test.com',
'uri' => 'testUpdate', 'uri' => $twofaccount->uri,
'icon' => 'testUpdate.png', 'icon' => 'testUpdate.png',
]); ]);
} }