Fixing reset command to allow resetting of just one type, starting to write test
This commit is contained in:
parent
f565ec5638
commit
05ee300ddb
|
@ -60,7 +60,7 @@ class ResetCommand extends ContainerAwareCommand
|
|||
|
||||
if (null !== $type) {
|
||||
$output->writeln(sprintf('<info>Resetting</info> <comment>%s/%s</comment>', $index, $type));
|
||||
$this->resetter->resetIndex($index, $type);
|
||||
$this->resetter->resetIndexType($index, $type);
|
||||
} else {
|
||||
$indexes = null === $index
|
||||
? array_keys($this->indexManager->getAllIndexes())
|
||||
|
|
53
Tests/Command/ResetCommandTest.php
Normal file
53
Tests/Command/ResetCommandTest.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace FOS\ElasticaBundle\Tests\Command;
|
||||
|
||||
|
||||
use FOS\ElasticaBundle\Command\ResetCommand;
|
||||
|
||||
class ResetCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $resetter;
|
||||
|
||||
private $indexManager;
|
||||
|
||||
public function setup()
|
||||
{
|
||||
$container = new Container();
|
||||
|
||||
$this->resetter = $this->getMockBuilder('\FOS\ElasticaBundle\Resetter')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('resetIndex', 'resetIndexType'))
|
||||
->getMock();
|
||||
|
||||
$container->set('fos_elastica.resetter', $this->resetter);
|
||||
|
||||
$this->indexManager = $this->getMockBuilder('\FOS\ElasticaBundle\IndexManager')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getAllIndexes'))
|
||||
->getMock();
|
||||
|
||||
$this->command = new ResetCommand();
|
||||
$this->command->setContainer($container);
|
||||
}
|
||||
|
||||
public function testResetAllIndexes()
|
||||
{
|
||||
$this->indexManager->expects($this->any())
|
||||
->method('getAllIndexes')
|
||||
->will($this->returnValue(array('index1', 'index2')));
|
||||
|
||||
$this->resetter->expects($this->at(1))
|
||||
->method('resetIndex')
|
||||
->with($this->equalTo('index1'));
|
||||
|
||||
$this->resetter->expects($this->at(2))
|
||||
->method('resetIndex')
|
||||
->with($this->equalTo('index2'));
|
||||
|
||||
$this->command->run(
|
||||
new ArrayInput(array()),
|
||||
new NullOutput()
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue