From 50f2a95156215446352d8a6c1124b8b3410d8f06 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 15 Oct 2024 13:54:58 +0200 Subject: [PATCH] Raise to TYPO3 v13.4 LTS --- Classes/Domain/Pageview/Factory.php | 6 ++-- Classes/Domain/Repository/Site.php | 40 ++++++++++++++++++++++ Tests/Unit/Domain/Pageview/FactoryTest.php | 26 +++++++------- composer.json | 6 ++-- 4 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 Classes/Domain/Repository/Site.php diff --git a/Classes/Domain/Pageview/Factory.php b/Classes/Domain/Pageview/Factory.php index a50f43a..fd36eba 100644 --- a/Classes/Domain/Pageview/Factory.php +++ b/Classes/Domain/Pageview/Factory.php @@ -24,17 +24,17 @@ declare(strict_types=1); namespace DanielSiepmann\Tracking\Domain\Pageview; use DanielSiepmann\Tracking\Domain\Model\Pageview; +use DanielSiepmann\Tracking\Domain\Repository\Site; use DateTimeImmutable; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Routing\PageArguments; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; -use TYPO3\CMS\Core\Site\SiteFinder; use UnexpectedValueException; class Factory { public function __construct( - private readonly SiteFinder $siteFinder + private readonly Site $siteRepository ) { } @@ -54,7 +54,7 @@ class Factory { return new Pageview( (int) $dbRow['pid'], - $this->siteFinder->getSiteByPageId((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']), + $this->siteRepository->findByPageUid((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']), new DateTimeImmutable('@' . $dbRow['crdate']), (int) $dbRow['type'], $dbRow['url'], diff --git a/Classes/Domain/Repository/Site.php b/Classes/Domain/Repository/Site.php new file mode 100644 index 0000000..ab3f754 --- /dev/null +++ b/Classes/Domain/Repository/Site.php @@ -0,0 +1,40 @@ + + * + * 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. + */ + +namespace DanielSiepmann\Tracking\Domain\Repository; + +use TYPO3\CMS\Core\Site\Entity\Site as SiteEntity; +use TYPO3\CMS\Core\Site\SiteFinder; + +class Site +{ + public function __construct( + private readonly SiteFinder $siteFinder + ) { + } + + public function findByPageUid(int $pageUid): SiteEntity + { + return $this->siteFinder->getSiteByPageId($pageUid); + } +} diff --git a/Tests/Unit/Domain/Pageview/FactoryTest.php b/Tests/Unit/Domain/Pageview/FactoryTest.php index c3399f5..2b4ae7a 100644 --- a/Tests/Unit/Domain/Pageview/FactoryTest.php +++ b/Tests/Unit/Domain/Pageview/FactoryTest.php @@ -24,14 +24,14 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Pageview; */ use DanielSiepmann\Tracking\Domain\Model\Pageview; use DanielSiepmann\Tracking\Domain\Pageview\Factory; +use DanielSiepmann\Tracking\Domain\Repository\Site; use DateTimeImmutable; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Routing\PageArguments; -use TYPO3\CMS\Core\Site\Entity\Site; +use TYPO3\CMS\Core\Site\Entity\Site as SiteEntity; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; -use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; #[CoversClass(Factory::class)] @@ -54,7 +54,7 @@ class FactoryTest extends UnitTestCase $request->method('getUri')->willReturn(''); $request->method('getHeader')->willReturn([]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertInstanceOf(Pageview::class, $result); @@ -79,7 +79,7 @@ class FactoryTest extends UnitTestCase 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0', ]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertSame( @@ -105,7 +105,7 @@ class FactoryTest extends UnitTestCase $request->method('getUri')->willReturn('https://example.com/path?query=params&some=more#anchor'); $request->method('getHeader')->willReturn([]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertSame( @@ -131,7 +131,7 @@ class FactoryTest extends UnitTestCase $request->method('getUri')->willReturn(''); $request->method('getHeader')->willReturn([]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertSame( @@ -157,7 +157,7 @@ class FactoryTest extends UnitTestCase $request->method('getUri')->willReturn(''); $request->method('getHeader')->willReturn([]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertInstanceOf(DateTimeImmutable::class, $result->getCrdate()); @@ -180,7 +180,7 @@ class FactoryTest extends UnitTestCase $request->method('getUri')->willReturn(''); $request->method('getHeader')->willReturn([]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertInstanceOf(SiteLanguage::class, $result->getLanguage()); @@ -203,7 +203,7 @@ class FactoryTest extends UnitTestCase $request->method('getUri')->willReturn(''); $request->method('getHeader')->willReturn([]); - $subject = new Factory($this->createStub(SiteFinder::class)); + $subject = new Factory($this->createStub(Site::class)); $result = $subject->fromRequest($request); self::assertSame( @@ -216,12 +216,12 @@ class FactoryTest extends UnitTestCase public function returnsPageviewFromDbRow(): void { $siteLanguage = $this->createStub(SiteLanguage::class); - $site = $this->createStub(Site::class); + $site = $this->createStub(SiteEntity::class); $site->method('getLanguageById')->willReturn($siteLanguage); - $siteFinder = $this->createStub(SiteFinder::class); - $siteFinder->method('getSiteByPageId')->willReturn($site); + $siteRepository = $this->createStub(Site::class); + $siteRepository->method('findByPageUid')->willReturn($site); - $subject = new Factory($siteFinder); + $subject = new Factory($siteRepository); $result = $subject->fromDbRow([ 'uid' => 1, diff --git a/composer.json b/composer.json index 26fc52f..d6bfe87 100644 --- a/composer.json +++ b/composer.json @@ -34,9 +34,9 @@ "psr/http-server-middleware": "^1.0", "symfony/console": "^5.2 || ^6.1 || ^7.0", "symfony/expression-language": "^5.2 || ^6.1 || ^7.0", - "typo3/cms-backend": "^12.4 || ^13.3", - "typo3/cms-core": "^12.4 || ^13.3", - "typo3/cms-dashboard": "^12.4 || ^13.3" + "typo3/cms-backend": "^12.4 || ^13.4", + "typo3/cms-core": "^12.4 || ^13.4", + "typo3/cms-dashboard": "^12.4 || ^13.4" }, "require-dev": { "codappix/typo3-php-datasets": "^1.5",