Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Fix array undefined warnings in "DB Check" Module
Add fallback for undefined array keys to make "DB Check" compatible with PHP8. Also basic tests have been added to check each page in the module. Resolves: #94498 Releases: master Change-Id: I98a598d0e809077cd89e7620efe31a498b3fbfa1 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69759 Tested-by: core-ci <typo3@b13.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: crell <larry@garfieldtech.com> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
- Loading branch information
Showing
5 changed files
with
257 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
typo3/sysext/core/Tests/Acceptance/Backend/DbCheck/DbCheckModuleCest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\DbCheck; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Facebook\WebDriver\Remote\RemoteWebElement; | ||
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester; | ||
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog; | ||
|
||
/** | ||
* Tests concerning Reports Module | ||
*/ | ||
class DbCheckModuleCest | ||
{ | ||
protected static string $defaultDashboardTitle = 'My Dashboard'; | ||
|
||
/** | ||
* @param BackendTester $I | ||
*/ | ||
public function _before(BackendTester $I) | ||
{ | ||
$I->useExistingSession('admin'); | ||
$I->click('#system_dbint'); | ||
$I->switchToContentFrame(); | ||
} | ||
|
||
/** | ||
* @param BackendTester $I | ||
*/ | ||
public function seeOverview(BackendTester $I) | ||
{ | ||
$I->see('Database integrity check', 'h1'); | ||
$I->see('Records Statistics', 'a'); | ||
$I->see('Relations', 'a'); | ||
$I->see('Search', 'a'); | ||
$I->see('Check and update global reference index', 'a'); | ||
} | ||
|
||
/** | ||
* @param BackendTester $I | ||
*/ | ||
public function seeRecordStatistics(BackendTester $I) | ||
{ | ||
$this->goToPageAndSeeHeadline($I, 'Record Statistics', 'Records Statistics'); | ||
|
||
foreach ($this->recordStatisticsDataProvider() as $statistic) { | ||
$count = $this->getCountByRowName($I, $statistic['name'])->getText(); | ||
// Use >= here to make sure we don't get in trouble with other tests creating db entries | ||
$I->assertGreaterThanOrEqual($statistic['count'], $count); | ||
} | ||
} | ||
|
||
/** | ||
* @param BackendTester $I | ||
*/ | ||
public function seeDatabaseRelations(BackendTester $I) | ||
{ | ||
$this->goToPageAndSeeHeadline($I, 'Database Relations', 'Relations'); | ||
$I->see('Select fields', 'h2'); | ||
$I->see('Group fields', 'h2'); | ||
} | ||
|
||
/** | ||
* @param BackendTester $I | ||
*/ | ||
public function seeFullSearch(BackendTester $I, ModalDialog $modalDialog) | ||
{ | ||
$this->goToPageAndSeeHeadline($I, 'Full search', 'Search whole Database'); | ||
$I->see('Search options', 'h2'); | ||
$I->see('Result', 'h2'); | ||
|
||
// Fill in search phrase and check results | ||
$I->fillField('input[name="SET[sword]"]', 'styleguide demo group 1'); | ||
$I->click('Search All Records'); | ||
$I->see('styleguide demo group 1', 'td'); | ||
$I->dontSee('styleguide demo group 2', 'td'); | ||
|
||
// Open info modal and see text in card | ||
$I->click('a[data-dispatch-args-list]'); | ||
$modalDialog->canSeeDialog(); | ||
$I->switchToIFrame('.modal-iframe'); | ||
$I->see('styleguide demo group 1', '.card-title'); | ||
} | ||
|
||
/** | ||
* @param BackendTester $I | ||
*/ | ||
public function seeManageReferenceIndex(BackendTester $I) | ||
{ | ||
$this->goToPageAndSeeHeadline($I, 'Manage Reference Index', 'Manage Reference Index'); | ||
|
||
$I->click('Check reference index'); | ||
$I->waitForElement('.alert-danger'); | ||
|
||
$I->click('Update reference index'); | ||
$I->waitForElement('.alert-danger'); | ||
|
||
$I->click('Check reference index'); | ||
$I->waitForElement('.alert-success'); | ||
$I->see('Index Integrity was perfect!', '.alert-success'); | ||
|
||
$I->click('Update reference index'); | ||
$I->see('Index Integrity was perfect!', '.alert-success'); | ||
} | ||
|
||
/** | ||
* @return array[] | ||
*/ | ||
protected function recordStatisticsDataProvider(): array | ||
{ | ||
return [ | ||
[ | ||
'name' => 'Total number of default language pages', | ||
'count' => 84, | ||
], | ||
[ | ||
'name' => 'Total number of translated pages', | ||
'count' => 132, | ||
], | ||
[ | ||
'name' => 'Marked-deleted pages', | ||
'count' => 0, | ||
], | ||
[ | ||
'name' => 'Hidden pages', | ||
'count' => 1, | ||
], | ||
[ | ||
'name' => 'Standard', | ||
'count' => 1, | ||
], | ||
[ | ||
'name' => 'Backend User Section', | ||
'count' => 0, | ||
], | ||
[ | ||
'name' => 'Link to External URL', | ||
'count' => 0, | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @param string $select | ||
* @param string $headline | ||
* @param BackendTester $I | ||
*/ | ||
protected function goToPageAndSeeHeadline(BackendTester $I, string $select, string $headline): void | ||
{ | ||
$I->selectOption('select[name=DatabaseJumpMenu]', $select); | ||
$I->see($headline, 'h1'); | ||
} | ||
|
||
/** | ||
* Find count of table row by name | ||
* | ||
* @param BackendTester $I | ||
* @param string $fieldLabel | ||
* @return RemoteWebElement | ||
*/ | ||
protected function getCountByRowName(BackendTester $I, string $rowName, int $sibling = 1): RemoteWebElement | ||
{ | ||
$I->comment('Get context for table row "' . $rowName . '"'); | ||
return $I->executeInSelenium( | ||
function (RemoteWebDriver $webDriver) use ($rowName, $sibling) { | ||
return $webDriver->findElement( | ||
\Facebook\WebDriver\WebDriverBy::xpath( | ||
'//td[contains(text(),"' . $rowName . '")]/following-sibling::td[' . $sibling . ']' | ||
) | ||
); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.