Completed
Push — feature/EVO-5751-searchindex-t... ( 8122b9...5f637b )
by
unknown
09:09 queued 09:04
created

GenerateBuildIndexesCommandTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/** GenerateBuildIndexesCommandTest **/
3
4
namespace Graviton\GeneratorBundle\Tests\Command;
5
6
use Graviton\GeneratorBundle\Command\GenerateBuildIndexesCommand;
7
use Graviton\TestBundle\Test\GravitonTestCase;
8
use Symfony\Bundle\FrameworkBundle\Console\Application;
9
use Symfony\Component\Console\Tester\CommandTester;
10
11
/**
12
 * GenerateBuildIndexesCommandTest
13
 *
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
class GenerateBuildIndexesCommandTest extends GravitonTestCase
19
{
20
    /**
21
     * @var \Doctrine\ODM\MongoDB\DocumentManager
22
     */
23
    private $documentManager;
24
25
    /**
26
     * {@inheritDoc}
27
     *
28
     * @return void
29
     */
30
    protected function setUp()
31
    {
32
        self::bootKernel();
33
34
        $this->documentManager = static::$kernel->getContainer()
35
            ->get('doctrine_mongodb.odm.default_document_manager');
36
    }
37
38
    /**
39
     * Tests the execution of the command building all indexes
40
     *
41
     * @return void
42
     */
43
    public function testExecute()
44
    {
45
        $kernel = self::createKernel();
46
47
        $application = new Application($kernel);
48
        $application->add(new GenerateBuildIndexesCommand($this->documentManager));
49
50
        $command = $application->find('graviton:generate:build-indexes');
51
52
        $commandTester = new CommandTester($command);
53
        $commandTester->execute(array());
54
55
        // test the creation of the index searchModuleIndex
56
        $indexInfo = $this->documentManager
57
            ->getDocumentCollection("GravitonDyn\ModuleBundle\Document\Module")
58
            ->getIndexInfo();
59
60
        $this->assertEquals('searchModuleIndex', $indexInfo[1]['name']);
61
    }
62
}
63