AdventureStepCompletionTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRejectAction() 0 12 1
A testAcceptAction() 0 13 1
1
<?php
2
3
namespace Badger\Bundle\GameBundle\Tests\Controller;
4
5
use Badger\BadgerTestCase;
6
7
/**
8
 * @author    Marie Bochu <[email protected]>
9
 * @license   http://opensource.org/licenses/MIT The MIT License (MIT)
10
 */
11
class AdventureStepCompletionTest extends BadgerTestCase
12
{
13
    public function testRejectAction()
14
    {
15
        $client = $this->createUser();
16
17
        $adventureStepCompletionRepo = $this->get('badger.game.repository.adventure_step_completion');
18
        $count = count($adventureStepCompletionRepo->findAll());
19
20
        $adventureStepCompletion = $adventureStepCompletionRepo->findOneBy(['pending' => 1])->getId();
21
        $client->request('GET', sprintf('admin/claimed-adventure-step/%s/reject', $adventureStepCompletion));
22
23
        $this->assertCount($count -= 1, $adventureStepCompletionRepo->findAll(), 'Adventure step has been rejected and deleted');
24
    }
25
26
    public function testAcceptAction()
27
    {
28
        $adventureStepCompletionRepo = $this->get('badger.game.repository.adventure_step_completion');
29
        $adventureStepCompletions = $adventureStepCompletionRepo->findBy(['pending' => 1]);
30
31
        $client = $this->createUser();
32
        $countPending = count($adventureStepCompletions);
33
        $countAccepted = count($adventureStepCompletionRepo->findBy(['pending' => 0]));
34
        $client->request('GET', sprintf('admin/claimed-adventure-step/%s/accept', current($adventureStepCompletions)->getId()));
35
36
        $this->assertCount($countPending -= 1, $adventureStepCompletionRepo->findBy(['pending' => 1]), 'Adventure step has been accepted');
37
        $this->assertCount($countAccepted += 1, $adventureStepCompletionRepo->findBy(['pending' => 0]), 'Adventure step has been accepted');
38
    }
39
}
40