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
|
|
|
|