mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-14 19:36:11 +01:00
Daniel Siepmann
20513400de
We use the cache clear hook to index pages whenever the cache was cleared. This makes it possible to cover some cases like changing content on a page. But also if an integrator configures to clear additional pages. This is limited as we can not handle cache tags at the moment. Resolves: #131
94 lines
3.2 KiB
PHP
94 lines
3.2 KiB
PHP
<?php
|
|
namespace Codappix\SearchCore\Tests\Unit\Hook;
|
|
|
|
/*
|
|
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
* 02110-1301, USA.
|
|
*/
|
|
|
|
use Codappix\SearchCore\Domain\Service\DataHandler as OwnDataHandler;
|
|
use Codappix\SearchCore\Hook\DataHandler;
|
|
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
|
|
use TYPO3\CMS\Core\DataHandling\DataHandler as CoreDataHandler;
|
|
|
|
class DataHandlerToProcessorTest extends AbstractUnitTestCase
|
|
{
|
|
/**
|
|
* @test
|
|
* @dataProvider getPossibleCallCombinations
|
|
*/
|
|
public function fieldsAreCopiedAsConfigured(array $parameters, bool $expectCall)
|
|
{
|
|
$coreDataHandlerMock = $this->getMockBuilder(CoreDataHandler::class)->getMock();
|
|
$ownDataHandlerMock = $this->getMockBuilder(OwnDataHandler::class)
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$subject = $this->getMockBuilder(DataHandler::class)
|
|
->setConstructorArgs([$ownDataHandlerMock])
|
|
->setMethods(['getRecord'])
|
|
->getMock();
|
|
|
|
$ownDataHandlerMock->expects($this->any())
|
|
->method('supportsTable')
|
|
->willReturn(true);
|
|
|
|
if ($expectCall) {
|
|
$subject->expects($this->once())
|
|
->method('getRecord')
|
|
->with('pages', 10)
|
|
->willReturn(['uid' => 10]);
|
|
$ownDataHandlerMock->expects($this->once())
|
|
->method('update')
|
|
->with('pages', ['uid' => 10]);
|
|
} else {
|
|
$subject->expects($this->never())
|
|
->method('getRecord');
|
|
$ownDataHandlerMock->expects($this->never())
|
|
->method('update');
|
|
}
|
|
|
|
$subject->clearCachePostProc($parameters, $coreDataHandlerMock);
|
|
}
|
|
|
|
public function getPossibleCallCombinations() : array
|
|
{
|
|
return [
|
|
'Editor triggered cache clear of page manual' => [
|
|
'parameters' => [
|
|
'cacheCmd' => '10',
|
|
],
|
|
'expectCall' => true,
|
|
],
|
|
'Editor changed records on a page' => [
|
|
'parameters' => [
|
|
'uid_page' =>10,
|
|
],
|
|
'expectCall' => true,
|
|
],
|
|
'Something unexpected' => [
|
|
'parameters' => [],
|
|
'expectCall' => false,
|
|
],
|
|
'Something unexpected' => [
|
|
'parameters' => [
|
|
'cacheCmd' => 'something like a tag?!',
|
|
],
|
|
'expectCall' => false,
|
|
],
|
|
];
|
|
}
|
|
}
|