2021-08-16 10:33:25 +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-08-16 10:33:25 +02:00
|
|
|
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
|
2023-05-11 08:48:15 +02:00
|
|
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
2021-08-16 10:33:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @testdox Recordviews are
|
2022-12-07 13:37:19 +01:00
|
|
|
*
|
|
|
|
* @coversNothing
|
2021-08-16 10:33:25 +02:00
|
|
|
*/
|
2023-05-11 08:48:15 +02:00
|
|
|
class RecordviewTest extends FunctionalTestCase
|
2021-08-16 10:33:25 +02:00
|
|
|
{
|
2023-05-11 08:48:15 +02:00
|
|
|
use TestingFramework;
|
|
|
|
|
2022-12-07 13:37:19 +01:00
|
|
|
protected array $testExtensionsToLoad = [
|
2021-08-16 10:33:25 +02:00
|
|
|
'typo3conf/ext/tracking',
|
|
|
|
'typo3conf/ext/tracking/Tests/Functional/Fixtures/Extensions/recordview',
|
|
|
|
];
|
|
|
|
|
2022-12-07 13:37:19 +01:00
|
|
|
protected array $pathsToLinkInTestInstance = [
|
2021-08-16 10:33:25 +02:00
|
|
|
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
|
|
|
|
];
|
|
|
|
|
2023-02-07 12:39:48 +01:00
|
|
|
protected array $configurationToUseInTestInstance = [
|
|
|
|
'FE' => [
|
|
|
|
'cacheHash' => [
|
|
|
|
'enforceValidation' => false,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2021-08-16 10:33:25 +02:00
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2023-05-11 08:48:15 +02:00
|
|
|
$this->importPHPDataSet(__DIR__ . '/Fixtures/Pages.php');
|
2021-08-16 10:33:25 +02:00
|
|
|
$this->setUpFrontendRootPage(1, [
|
|
|
|
'EXT:tracking/Tests/Functional/Fixtures/Rendering.typoscript',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function trackedWhenAllowed(): void
|
|
|
|
{
|
|
|
|
$request = new InternalRequest();
|
|
|
|
$request = $request->withPageId(1);
|
|
|
|
$request = $request->withQueryParameter('topic_id', 1);
|
|
|
|
$request = $request->withHeader('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0');
|
|
|
|
$response = $this->executeFrontendRequest($request);
|
|
|
|
|
|
|
|
self::assertSame(200, $response->getStatusCode());
|
|
|
|
|
|
|
|
$records = $this->getAllRecords('tx_tracking_recordview');
|
|
|
|
self::assertCount(1, $records);
|
2023-04-26 17:29:23 +02:00
|
|
|
self::assertSame('1', (string)$records[0]['pid']);
|
|
|
|
self::assertSame('1', (string)$records[0]['uid']);
|
2021-08-16 10:33:25 +02:00
|
|
|
self::assertSame('http://localhost/?id=1&topic_id=1', $records[0]['url']);
|
|
|
|
self::assertSame('Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0', $records[0]['user_agent']);
|
|
|
|
self::assertSame('Macintosh', $records[0]['operating_system']);
|
|
|
|
self::assertSame('sys_category_1', $records[0]['record']);
|
2023-04-26 17:29:23 +02:00
|
|
|
self::assertSame('1', (string)$records[0]['record_uid']);
|
2021-08-16 10:33:25 +02:00
|
|
|
self::assertSame('sys_category', $records[0]['record_table_name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function notTrackedWhenNotDetected(): void
|
|
|
|
{
|
|
|
|
$request = new InternalRequest();
|
|
|
|
$request = $request->withPageId(1);
|
|
|
|
$response = $this->executeFrontendRequest($request);
|
|
|
|
|
|
|
|
self::assertSame(200, $response->getStatusCode());
|
|
|
|
|
|
|
|
$records = $this->getAllRecords('tx_tracking_recordview');
|
|
|
|
self::assertCount(0, $records);
|
|
|
|
}
|
|
|
|
}
|