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