Skip to content

Commit

Permalink
Merge pull request #85 from pagemachine/typo3v12
Browse files Browse the repository at this point in the history
Add support for TYPO3v12
  • Loading branch information
mbrodala authored Sep 6, 2023
2 parents 2109617 + 5c0e60c commit 7ca5754
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 37 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
typo3:
- ^11.5
- ^12.4
include:
- php: '7.4'
typo3: ^11.5
- php: '8.0'
typo3: ^11.5

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions Classes/Page/PageCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
final class PageCollection implements \IteratorAggregate, \Countable
{
/**
* @var \Doctrine\DBAL\Driver\Statement
* @var \Doctrine\DBAL\Result
*/
private $pages;

Expand All @@ -32,7 +32,7 @@ public function __construct()
$this->pages = $queryBuilder
->select('uid')
->from('pages')
->execute();
->executeQuery();
$this->pageRepository = GeneralUtility::makeInstance(PageRepository::class);
}

Expand All @@ -41,7 +41,7 @@ public function __construct()
*/
public function getIterator(): \Generator
{
foreach ($this->pages as $page) {
foreach ($this->pages->iterateAssociative() as $page) {
yield new Page($page['uid']);
}
}
Expand Down
8 changes: 4 additions & 4 deletions Classes/Page/Redirect/Conflict/RedirectConflictDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function detect(Page $page): \Generator
]
);

foreach ($redirects as $redirect) {
foreach ($redirects->iterateAssociative() as $redirect) {
yield new ConflictRedirect($redirect['uid']);
}

Expand All @@ -53,7 +53,7 @@ public function detect(Page $page): \Generator
]
);

foreach ($redirects as $redirect) {
foreach ($redirects->iterateAssociative() as $redirect) {
yield new ConflictRedirect($redirect['uid']);
}
}
Expand Down Expand Up @@ -81,8 +81,8 @@ private function getLanguageOfPage(Page $page): int
'uid',
$queryBuilder->createNamedParameter($page->getUid())
))
->execute()
->fetchColumn();
->executeQuery()
->fetchOne();

return $pageLanguage;
}
Expand Down
14 changes: 8 additions & 6 deletions Classes/Page/Redirect/Typo3Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
*/
final class Typo3Uri extends Uri
{
/**
* @var int[] Associative array containing schemes and their default ports.
*/
protected $supportedSchemes = [
't3' => 0,
];
public function __construct(string $uri = '')
{
$this->supportedSchemes = [
't3' => 0,
];

parent::__construct($uri);
}
}
4 changes: 4 additions & 0 deletions Tests/Functional/Fixtures/be_users.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"be_users"
,"uid","pid","username","password","admin","disable","deleted"
# The password is "password"
,1,0,"admin","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",1,0,0
16 changes: 13 additions & 3 deletions Tests/Functional/Hook/DataHandler/AddRedirectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Pagemachine\FlatUrls\Tests\Functional\Hook\DataHandler;

use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -29,7 +30,10 @@ final class AddRedirectTest extends FunctionalTestCase
*/
public function addsRedirectsOnSlugChange(array $pages, array $changes, array $expected): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down Expand Up @@ -148,7 +152,10 @@ public function redirectPages(): \Generator
*/
public function skipsPagesWithoutSite(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down Expand Up @@ -181,7 +188,10 @@ public function skipsPagesWithoutSite(): void
*/
public function skipsInactivePages(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down
6 changes: 5 additions & 1 deletion Tests/Functional/Hook/DataHandler/AmendSlugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Pagemachine\FlatUrls\Tests\Functional\Hook\DataHandler;

use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -29,7 +30,10 @@ final class AmendSlugTest extends FunctionalTestCase
*/
public function ensuresFlatUrls(array $changes, int $pageUid, string $expected): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down
6 changes: 5 additions & 1 deletion Tests/Functional/Hook/DataHandler/RefreshSlugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Pagemachine\FlatUrls\Tests\Functional\Hook\DataHandler;

use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -28,7 +29,10 @@ final class RefreshSlugTest extends FunctionalTestCase
*/
public function ensuresFlatUrls(array $pages, array $changes, int $pageUid, string $expected): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down
26 changes: 21 additions & 5 deletions Tests/Functional/Hook/DataHandler/ResolveRedirectConflictTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -29,7 +30,10 @@ final class ResolveRedirectConflictTest extends FunctionalTestCase
*/
public function resolvesPagePathRedirectConflicts(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down Expand Up @@ -107,7 +111,10 @@ public function resolvesPagePathRedirectConflicts(): void
*/
public function normalizesPagePath(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down Expand Up @@ -187,7 +194,10 @@ public function normalizesPagePath(): void
*/
public function resolvesUidRedirectConflicts(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down Expand Up @@ -226,7 +236,10 @@ public function resolvesUidRedirectConflicts(): void
*/
public function skipsPagesWithoutSite(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down Expand Up @@ -258,7 +271,10 @@ public function skipsPagesWithoutSite(): void
*/
public function skipsInactivePages(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$pageConnection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down
6 changes: 5 additions & 1 deletion Tests/Functional/Page/Slug/PageSlugProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Pagemachine\FlatUrls\Page\Page;
use Pagemachine\FlatUrls\Page\Slug\PageSlugProcessor;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand All @@ -29,7 +30,10 @@ final class PageSlugProcessorTest extends FunctionalTestCase
*/
public function updatesPageSlugs(array $pages, int $pageUid, string $expected): void
{
$this->setUpBackendUserFromFixture(1);
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
$this->setUpBackendUser(1);

Bootstrap::initializeLanguageObject();

$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('pages');
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
],
"require": {
"php": "^7.4 || ^8.0",
"typo3/cms-backend": "^11.5",
"typo3/cms-core": "^11.5",
"typo3/cms-extbase": "^11.5",
"typo3/cms-frontend": "^11.5",
"typo3/cms-redirects": "^11.5.7"
"typo3/cms-backend": "^11.5 || ^12.4",
"typo3/cms-core": "^11.5 || ^12.4",
"typo3/cms-extbase": "^11.5 || ^12.4",
"typo3/cms-frontend": "^11.5 || ^12.4",
"typo3/cms-redirects": "^11.5.7 || ^12.4"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^5.0",
"codedungeon/phpunit-result-printer": "^0.32.0",
"ergebnis/composer-normalize": "^2.8",
"jangregor/phpstan-prophecy": "^1.0.0",
"php-parallel-lint/php-console-highlighter": "^1.0.0",
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ version: '3'

services:
app:
image: thecodingmachine/php:${PHP_VERSION:-7.4}-v4-cli
image: thecodingmachine/php:${PHP_VERSION:-8.1}-v4-cli
environment:
TYPO3_VERSION: ${TYPO3_VERSION:-^11.5}
PHP_EXTENSION_INTL: 1
TYPO3_VERSION: ${TYPO3_VERSION:-^12.4}
TYPO3_API_PASSWORD:
TYPO3_API_USERNAME:
TAG:
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'version' => '3.0.2',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-11.5.99',
'typo3' => '11.5.0-12.4.99',
],
],
];
1 change: 0 additions & 1 deletion phpunit-functional.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
Expand Down

0 comments on commit 7ca5754

Please sign in to comment.