TASK: Adjust configuration for indexing

* Adjust used configuration in command.
This commit is contained in:
Daniel Siepmann 2017-06-29 09:18:31 +02:00
parent aa8d7e36e6
commit fde592f2e3
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 18 additions and 8 deletions

View file

@ -57,8 +57,7 @@ class IndexCommandController extends CommandController
{ {
// TODO: Allow to index multiple tables at once? // TODO: Allow to index multiple tables at once?
// TODO: Also allow to index everything? // TODO: Also allow to index everything?
// TODO: Adjust config path if ($this->configuration->getIfExists('indexing.' . $table) === null) {
if (! in_array($table, GeneralUtility::trimExplode(',', $this->configuration->get('indexer.tca.allowedTables')))) {
$this->outputLine('Table is not allowed for indexing.'); $this->outputLine('Table is not allowed for indexing.');
$this->quit(1); $this->quit(1);
} }

View file

@ -40,6 +40,11 @@ class IndexCommandControllerTest extends AbstractUnitTestCase
*/ */
protected $indexerFactory; protected $indexerFactory;
/**
* @var ConfigurationContainerInterface
*/
protected $configuration;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
@ -47,20 +52,16 @@ class IndexCommandControllerTest extends AbstractUnitTestCase
$this->indexerFactory = $this->getMockBuilder(IndexerFactory::class) $this->indexerFactory = $this->getMockBuilder(IndexerFactory::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$configuration = $this->getMockBuilder(ConfigurationContainerInterface::class) $this->configuration = $this->getMockBuilder(ConfigurationContainerInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$configuration->expects($this->once())
->method('get')
->with('indexer.tca.allowedTables')
->will($this->returnValue('allowedTable, anotherTable,YetAnotherTable'));
$this->subject = $this->getMockBuilder(IndexCommandController::class) $this->subject = $this->getMockBuilder(IndexCommandController::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(['quit', 'outputLine']) ->setMethods(['quit', 'outputLine'])
->getMock(); ->getMock();
$this->subject->injectIndexerFactory($this->indexerFactory); $this->subject->injectIndexerFactory($this->indexerFactory);
$this->inject($this->subject, 'configuration', $configuration); $this->inject($this->subject, 'configuration', $this->configuration);
} }
/** /**
@ -80,6 +81,10 @@ class IndexCommandControllerTest extends AbstractUnitTestCase
$this->indexerFactory->expects($this->never()) $this->indexerFactory->expects($this->never())
->method('getIndexer'); ->method('getIndexer');
$this->configuration->expects($this->once())
->method('getIfExists')
->with('indexing.nonAllowedTable')
->will($this->returnValue(null));
$this->subject->indexCommand('nonAllowedTable'); $this->subject->indexCommand('nonAllowedTable');
} }
@ -101,6 +106,12 @@ class IndexCommandControllerTest extends AbstractUnitTestCase
->with('allowedTable') ->with('allowedTable')
->will($this->returnValue($indexerMock)); ->will($this->returnValue($indexerMock));
$this->configuration->expects($this->once())
->method('getIfExists')
->with('indexing.allowedTable')
->will($this->returnValue([
'indexer' => 'Leonmrni\SearchCore\Domain\Index\TcaIndexer',
]));
$this->subject->indexCommand('allowedTable'); $this->subject->indexCommand('allowedTable');
} }
} }