diff --git a/Tests/Functional/AbstractFunctionalTestCase.php b/Tests/Functional/AbstractFunctionalTestCase.php index eec956d..c231784 100644 --- a/Tests/Functional/AbstractFunctionalTestCase.php +++ b/Tests/Functional/AbstractFunctionalTestCase.php @@ -36,12 +36,25 @@ abstract class AbstractFunctionalTestCase extends CoreTestCase $this->setUpBackendUserFromFixture(1); \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject(); - // Provide necessary configuration for extension - $this->importDataSet('Tests/Functional/Fixtures/BasicSetup.xml'); + foreach ($this->getDataSets() as $dataSet) { + $this->importDataSet($dataSet); + } $this->setUpFrontendRootPage(1, $this->getTypoScriptFilesForFrontendRootPage()); } + /** + * Overwrite to import different files. + * + * Defines which DataSet Files should be imported. + * + * @return array + */ + protected function getDataSets() + { + return ['Tests/Functional/Fixtures/BasicSetup.xml']; + } + /** * Overwrite to import different files. * diff --git a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php index 30d55f9..a6120da 100644 --- a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php +++ b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php @@ -28,11 +28,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager; */ class IndexTcaTableTest extends AbstractFunctionalTestCase { - public function setUp() + protected function getDataSets() { - parent::setUp(); - - $this->importDataSet('Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml'); + return array_merge( + parent::getDataSets(), + ['Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml'] + ); } /** diff --git a/Tests/Functional/Hooks/DataHandler/AbstractDataHandlerTest.php b/Tests/Functional/Hooks/DataHandler/AbstractDataHandlerTest.php new file mode 100644 index 0000000..7a7569e --- /dev/null +++ b/Tests/Functional/Hooks/DataHandler/AbstractDataHandlerTest.php @@ -0,0 +1,57 @@ + + * + * 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 Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface; +use Leonmrni\SearchCore\Domain\Service\DataHandler as DataHandlerService; +use Leonmrni\SearchCore\Hook\DataHandler as DataHandlerHook; +use Leonmrni\SearchCore\Tests\Functional\AbstractFunctionalTestCase; +use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Object\ObjectManager; + +abstract class AbstractDataHandlerTest extends AbstractFunctionalTestCase +{ + /** + * @var DataHandlerService|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface + */ + protected $subject; + + public function setUp() + { + parent::setUp(); + + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + + $this->subject = $this->getAccessibleMock( + DataHandlerService::class, + [ + 'add', + 'update', + 'delete', + ], + [$objectManager->get(ConfigurationContainerInterface::class)] + ); + + // This way TYPO3 will use our mock instead of a new instance. + $GLOBALS['T3_VAR']['getUserObj']['&' . DataHandlerHook::class] = new DataHandlerHook($this->subject); + } +} diff --git a/Tests/Functional/Hooks/DataHandler/IgnoresUnkownOperationTest.php b/Tests/Functional/Hooks/DataHandler/IgnoresUnkownOperationTest.php index a66e3d8..44f5186 100644 --- a/Tests/Functional/Hooks/DataHandler/IgnoresUnkownOperationTest.php +++ b/Tests/Functional/Hooks/DataHandler/IgnoresUnkownOperationTest.php @@ -23,56 +23,32 @@ namespace Leonmrni\SearchCore\Tests\Functional\Hooks\DataHandler; use Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface; use Leonmrni\SearchCore\Domain\Service\DataHandler as DataHandlerService; use Leonmrni\SearchCore\Hook\DataHandler as DataHandlerHook; -use Leonmrni\SearchCore\Tests\Functional\AbstractFunctionalTestCase; use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; -class IgnoresUnkownOperationTest extends AbstractFunctionalTestCase +class IgnoresUnkownOperationTest extends AbstractDataHandlerTest { /** * @var DataHandlerService|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface */ protected $subject; - public function setUp() - { - parent::setUp(); - - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - - $this->subject = $this->getAccessibleMock( - DataHandlerService::class, - [ - 'add', - 'update', - 'delete', - ], - [$objectManager->get(ConfigurationContainerInterface::class)] - ); - - // This way TYPO3 will use our mock instead of a new instance. - $GLOBALS['T3_VAR']['getUserObj']['&' . DataHandlerHook::class] = new DataHandlerHook($this->subject); - } - /** * @test */ - public function deletionWillBeTriggeredForTtContent() + public function dataHandlerCommandSomethingIsIgnored() { - $this->subject->expects($this->exactly(0))->method('add'); - $this->subject->expects($this->exactly(0))->method('update'); - $this->subject->expects($this->exactly(0))->method('delete'); - - $tce = GeneralUtility::makeInstance(Typo3DataHandler::class); - $tce->stripslashes_values = 0; - $tce->start([], [ - 'tt_content' => [ - '1' => [ - 'something' => 1, - ], - ], - ]); - $tce->process_cmdmap(); + $subject = new DataHandlerHook($this->subject); + $this->assertFalse( + $subject->processDatamap_afterDatabaseOperations( + 'something', + 'tt_content', + 1, + [], + new Typo3DataHandler + ), + 'Hook processed status "something".' + ); } } diff --git a/Tests/Functional/Hooks/DataHandler/NonAllowedTablesTest.php b/Tests/Functional/Hooks/DataHandler/NonAllowedTablesTest.php index 1238d18..6073633 100644 --- a/Tests/Functional/Hooks/DataHandler/NonAllowedTablesTest.php +++ b/Tests/Functional/Hooks/DataHandler/NonAllowedTablesTest.php @@ -23,37 +23,23 @@ namespace Leonmrni\SearchCore\Tests\Functional\Hooks\DataHandler; use Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface; use Leonmrni\SearchCore\Domain\Service\DataHandler as DataHandlerService; use Leonmrni\SearchCore\Hook\DataHandler as DataHandlerHook; -use Leonmrni\SearchCore\Tests\Functional\AbstractFunctionalTestCase; use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; -class NonAllowedTablesTest extends AbstractFunctionalTestCase +class NonAllowedTablesTest extends AbstractDataHandlerTest { /** * @var DataHandlerService|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface */ protected $subject; - public function setUp() + protected function getDataSets() { - parent::setUp(); - $this->importDataSet('Tests/Functional/Fixtures/Hooks/DataHandler/NonAllowedTables.xml'); - - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - - $this->subject = $this->getAccessibleMock( - DataHandlerService::class, - [ - 'add', - 'update', - 'delete', - ], - [$objectManager->get(ConfigurationContainerInterface::class)] + return array_merge( + parent::getDataSets(), + ['Tests/Functional/Fixtures/Hooks/DataHandler/NonAllowedTables.xml'] ); - - // This way TYPO3 will use our mock instead of a new instance. - $GLOBALS['T3_VAR']['getUserObj']['&' . DataHandlerHook::class] = new DataHandlerHook($this->subject); } /** diff --git a/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php b/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php index f07767c..e9e834e 100644 --- a/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php +++ b/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php @@ -23,37 +23,23 @@ namespace Leonmrni\SearchCore\Tests\Functional\Hooks\DataHandler; use Leonmrni\SearchCore\Configuration\ConfigurationContainerInterface; use Leonmrni\SearchCore\Domain\Service\DataHandler as DataHandlerService; use Leonmrni\SearchCore\Hook\DataHandler as DataHandlerHook; -use Leonmrni\SearchCore\Tests\Functional\AbstractFunctionalTestCase; use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; -class ProcessesAllowedTablesTest extends AbstractFunctionalTestCase +class ProcessesAllowedTablesTest extends AbstractDataHandlerTest { /** * @var DataHandlerService|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface */ protected $subject; - public function setUp() + protected function getDataSets() { - parent::setUp(); - $this->importDataSet('Tests/Functional/Fixtures/Hooks/DataHandler/AllowedTables.xml'); - - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - - $this->subject = $this->getAccessibleMock( - DataHandlerService::class, - [ - 'add', - 'update', - 'delete', - ], - [$objectManager->get(ConfigurationContainerInterface::class)] + return array_merge( + parent::getDataSets(), + ['Tests/Functional/Fixtures/Hooks/DataHandler/AllowedTables.xml'] ); - - // This way TYPO3 will use our mock instead of a new instance. - $GLOBALS['T3_VAR']['getUserObj']['&' . DataHandlerHook::class] = new DataHandlerHook($this->subject); } /**