tracking/Tests/Functional/Typo3FeaturesTest.php
Daniel Siepmann 456c86b492 Update PHPStan
PHPStan was released with first stable public version 1.x.
The version is updated together with extensions.

The new version finds new issues which are solved right away to not
break CI.
2022-01-06 08:10:02 +01:00

103 lines
3.4 KiB
PHP

<?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.
*/
use DanielSiepmann\Tracking\Functional\CopyingPageWithRecordsWorks;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @covers \DanielSiepmann\Tracking\Functional\CopyingPageWithRecordsWorks
* @testdox This extension works with TYPO3 feature:
*/
class Typo3FeaturesTest extends TestCase
{
protected $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
public function setUp(): void
{
parent::setUp();
$this->importDataSet('EXT:tracking/Tests/Functional/Fixtures/Typo3FeaturesTest/PageWithRecords.xml');
$this->setUpBackendUserFromFixture(1);
$languageServiceFactory = $this->getContainer()->get(LanguageServiceFactory::class);
if (!$languageServiceFactory instanceof LanguageServiceFactory) {
throw new \UnexpectedValueException('Did not retrieve LanguageServiceFactory.', 1637847250);
}
$GLOBALS['LANG'] = $languageServiceFactory->create('default');
}
public function tearDown(): void
{
unset($GLOBALS['LANG']);
parent::tearDown();
}
/**
* @test
* @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
* @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'
);
}
}