Completed
Push — master ( 3db674...2e3aab )
by Remy
03:46
created

BuildIndexesCommandTest::testExecute()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 16
nc 4
nop 0
1
<?php
2
3
namespace Pouzor\MongoDBBundle\Tests\Functional\Command;
4
5
use Pouzor\MongoDBBundle\Command\BuildIndexesCommand;
6
use Pouzor\MongoDBBundle\Tests\MongoTestCase;
7
use Symfony\Bundle\FrameworkBundle\Console\Application;
8
use Symfony\Component\Console\Tester\CommandTester;
9
10
class BuildIndexesCommandTest extends MongoTestCase {
11
12
    public function testExecute() {
13
14
        $command = new BuildIndexesCommand();
15
        $command->setManager($this->manager);
16
17
        $indexes = $this->testRepo->listIndexes();
18
        $base = ['_id_'];
19
        foreach ($indexes as $i) {
20
            $this->assertContains($i['name'], $base);
21
        }
22
23
        $app = new Application($this->k);
24
25
        $app->add($command);
26
27
        $tester = new CommandTester($command);
28
29
        $tester->execute(array(
30
            '-vvv' => null,
31
        ));
32
33
        $indexes = $this->testRepo->listIndexes();
34
        $base = ['_id_', 'bar_-1'];
35
36
        foreach ($indexes as $i) {
37
            $this->assertContains($i['name'], $base);
38
        }
39
40
    }
41
}