mirror of
https://github.com/Codappix/search_core.git
synced 2025-01-11 07:56:10 +01:00
[FEATURE] Added flush command as indexation is now into one
This commit is contained in:
parent
b8de35adee
commit
6e492d2bdb
2 changed files with 37 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue