2021-05-21 18:16:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DanielSiepmann\Tracking\Tests\Functional;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 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.
|
|
|
|
*/
|
|
|
|
|
2023-05-11 08:48:15 +02:00
|
|
|
use Codappix\Typo3PhpDatasets\TestingFramework;
|
2021-05-21 18:16:33 +02:00
|
|
|
use TYPO3\CMS\Core\DataHandling\DataHandler;
|
|
|
|
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
|
2023-05-11 08:48:15 +02:00
|
|
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
2022-12-07 13:37:19 +01:00
|
|
|
use UnexpectedValueException;
|
2021-05-21 18:16:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \DanielSiepmann\Tracking\Functional\CopyingPageWithRecordsWorks
|
2022-12-07 13:37:19 +01:00
|
|
|
*
|
2021-05-21 18:16:33 +02:00
|
|
|
* @testdox This extension works with TYPO3 feature:
|
|
|
|
*/
|
2023-05-11 08:48:15 +02:00
|
|
|
class Typo3FeaturesTest extends FunctionalTestCase
|
2021-05-21 18:16:33 +02:00
|
|
|
{
|
2023-05-11 08:48:15 +02:00
|
|
|
use TestingFramework;
|
|
|
|
|
2022-12-07 13:37:19 +01:00
|
|
|
protected array $testExtensionsToLoad = [
|
2021-05-21 18:16:33 +02:00
|
|
|
'typo3conf/ext/tracking',
|
|
|
|
];
|
|
|
|
|
2022-12-07 13:37:19 +01:00
|
|
|
protected function setUp(): void
|
2021-11-25 14:40:00 +01:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2023-05-11 08:48:15 +02:00
|
|
|
$this->importPHPDataSet(__DIR__ . '/Fixtures/BackendUser.php');
|
|
|
|
$this->importPHPDataSet(__DIR__ . '/Fixtures/Typo3FeaturesTest/PageWithRecords.php');
|
2022-12-07 13:37:19 +01:00
|
|
|
$this->setUpBackendUser(1);
|
2021-11-25 14:40:00 +01:00
|
|
|
$languageServiceFactory = $this->getContainer()->get(LanguageServiceFactory::class);
|
|
|
|
if (!$languageServiceFactory instanceof LanguageServiceFactory) {
|
2022-12-07 13:37:19 +01:00
|
|
|
throw new UnexpectedValueException('Did not retrieve LanguageServiceFactory.', 1637847250);
|
2021-11-25 14:40:00 +01:00
|
|
|
}
|
|
|
|
$GLOBALS['LANG'] = $languageServiceFactory->create('default');
|
|
|
|
}
|
|
|
|
|
2022-12-07 13:37:19 +01:00
|
|
|
protected function tearDown(): void
|
2021-11-25 14:40:00 +01:00
|
|
|
{
|
|
|
|
unset($GLOBALS['LANG']);
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
2021-05-21 18:16:33 +02:00
|
|
|
/**
|
|
|
|
* @test
|
2022-12-07 13:37:19 +01:00
|
|
|
*
|
2021-05-21 18:16:33 +02:00
|
|
|
* @testdox Copy pages. Tracking records will not be copied.
|
|
|
|
*/
|
|
|
|
public function copyContainingRecords(): void
|
|
|
|
{
|
|
|
|
$dataHandler = new DataHandler();
|
|
|
|
$dataHandler->start([], [
|
|
|
|
'pages' => [
|
|
|
|
1 => [
|
|
|
|
'copy' => 1,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$dataHandler->process_cmdmap();
|
|
|
|
|
|
|
|
self::assertCount(0, $dataHandler->errorLog, 'Failed with errors: ' . implode(PHP_EOL, $dataHandler->errorLog));
|
|
|
|
$this->assertCSVDataSet(
|
|
|
|
'EXT:tracking/Tests/Functional/ExpectedResults/Typo3FeaturesTest/CopyPasteContainingRecords.csv'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
2022-12-07 13:37:19 +01:00
|
|
|
*
|
2021-05-21 18:16:33 +02:00
|
|
|
* @testdox Copy individual tables, but always exclude tracking tables.
|
|
|
|
*/
|
|
|
|
public function copyCustomTablesViaDataHandler(): void
|
|
|
|
{
|
|
|
|
$dataHandler = new DataHandler();
|
|
|
|
$dataHandler->copyWhichTables = 'pages,tx_tracking_pageview,tx_tracking_recordview';
|
|
|
|
$dataHandler->start([], [
|
|
|
|
'pages' => [
|
|
|
|
1 => [
|
|
|
|
'copy' => 1,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$dataHandler->process_cmdmap();
|
|
|
|
|
|
|
|
self::assertCount(0, $dataHandler->errorLog, 'Failed with errors: ' . implode(PHP_EOL, $dataHandler->errorLog));
|
|
|
|
$this->assertCSVDataSet(
|
|
|
|
'EXT:tracking/Tests/Functional/ExpectedResults/Typo3FeaturesTest/CopyPasteContainingRecords.csv'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|