-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incorporate all current quests into quest stats
Add tests for this and refactor.
- Loading branch information
Showing
5 changed files
with
171 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
tests/Feature/Microtasks/Workbench/ContributionsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Microtasks\Workbench; | ||
|
||
use App\Faultcat; | ||
use App\Misccat; | ||
use App\Mobifix; | ||
use App\MobifixOra; | ||
use App\PrintcatOra; | ||
use App\TabicatOra; | ||
use App\User; | ||
|
||
use DB; | ||
use Hash; | ||
use Mockery; | ||
use Tests\TestCase; | ||
|
||
|
||
class ContributionsTest extends TestCase | ||
{ | ||
protected $user1; | ||
protected $user2; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
Faultcat::truncate(); | ||
Misccat::truncate(); | ||
Mobifix::truncate(); | ||
MobifixOra::truncate(); | ||
PrintcatOra::truncate(); | ||
TabicatOra::truncate(); | ||
|
||
$this->userWithContributions = factory(User::class)->state('Restarter')->create(); | ||
$this->anotherUserWithContributions = factory(User::class)->state('Restarter')->create(); | ||
$this->userNoContributions = factory(User::class)->state('Restarter')->create(); | ||
|
||
// 3 contributions, 3 quests. | ||
FaultCat::insert([ | ||
'iddevices' => 1, | ||
'fault_type' => 'Performance', | ||
'user_id' => $this->userWithContributions->id, | ||
]); | ||
PrintcatOra::insert([ | ||
'id_ords' => 'restart_1', | ||
'fault_type_id' => 1, | ||
'user_id' => $this->userWithContributions->id, | ||
]); | ||
TabicatOra::insert([ | ||
'id_ords' => 'restart_1', | ||
'fault_type_id' => 1, | ||
'user_id' => $this->userWithContributions->id, | ||
]); | ||
|
||
// 2 contributions, 1 quest. | ||
TabicatOra::insert([ | ||
'id_ords' => 'restart_2', | ||
'fault_type_id' => 1, | ||
'user_id' => $this->anotherUserWithContributions->id, | ||
]); | ||
TabicatOra::insert([ | ||
'id_ords' => 'restart_3', | ||
'fault_type_id' => 1, | ||
'user_id' => $this->anotherUserWithContributions->id, | ||
]); | ||
} | ||
|
||
public function testLoggedInNoContributions() | ||
{ | ||
$this->actingAs($this->userNoContributions); | ||
$response = $this->get('/workbench'); | ||
|
||
$props = $this->getVueProperties($response)[0]; | ||
$this->assertEquals(0, $props[':current-user-quests']); | ||
$this->assertEquals(0, $props[':current-user-contributions']); | ||
} | ||
|
||
public function testLoggedInSomeContributions() | ||
{ | ||
$this->actingAs($this->userWithContributions); | ||
$response = $this->get('/workbench'); | ||
|
||
$props = $this->getVueProperties($response)[0]; | ||
$this->assertEquals(3, $props[':current-user-quests']); | ||
$this->assertEquals(3, $props[':current-user-contributions']); | ||
} | ||
|
||
public function testLoggedInMultipleContributionsOneQuest() | ||
{ | ||
$this->actingAs($this->anotherUserWithContributions); | ||
$response = $this->get('/workbench'); | ||
|
||
$props = $this->getVueProperties($response)[0]; | ||
$this->assertEquals(1, $props[':current-user-quests']); | ||
$this->assertEquals(2, $props[':current-user-contributions']); | ||
} | ||
|
||
public function testLoggedOut() | ||
{ | ||
$response = $this->get('/workbench'); | ||
|
||
$props = $this->getVueProperties($response)[0]; | ||
$this->assertEquals(0, $props[':current-user-quests']); | ||
$this->assertEquals(0, $props[':current-user-contributions']); | ||
} | ||
|
||
public function testTotals() | ||
{ | ||
$response = $this->get('/workbench'); | ||
|
||
$props = $this->getVueProperties($response)[0]; | ||
$this->assertEquals(6, $props[':total-quests']); | ||
$this->assertEquals(5, $props[':total-contributions']); | ||
} | ||
} |