[FEATURE] Added flush command as indexation is now into one

This commit is contained in:
Benjamin Serfhos 2018-10-26 10:56:57 +02:00
parent b8de35adee
commit 6e492d2bdb
2 changed files with 37 additions and 0 deletions

View file

@ -84,4 +84,20 @@ class IndexCommandController extends CommandController
}
}
}
/**
* Will delete the full index.
*
* @param string $identifier
* @return void
*/
public function flushCommand(string $identifier = 'pages')
{
try {
$this->indexerFactory->getIndexer($identifier)->delete();
$this->outputLine('Default configured indices were deleted via ' . $identifier . '.');
} catch (NoMatchingIndexerException $e) {
$this->outputLine('No indexer found for: ' . $identifier);
}
}
}

View file

@ -112,6 +112,27 @@ class IndexCommandControllerTest extends AbstractUnitTestCase
$this->subject->deleteCommand('allowedTable');
}
/**
* @test
*/
public function flushIsPossible()
{
$indexerMock = $this->getMockBuilder(TcaIndexer::class)
->disableOriginalConstructor()
->getMock();
$this->subject->expects($this->once())
->method('outputLine')
->with('Default configured indices were deleted via pages.');
$this->indexerFactory->expects($this->once())
->method('getIndexer')
->with('pages')
->will($this->returnValue($indexerMock));
$indexerMock->expects($this->once())
->method('delete');
$this->subject->flushCommand('pages');
}
/**
* @test
*/