‪TYPO3CMS  ‪main
DbCheckModuleCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Codeception\Attribute\DataProvider;
21 use Codeception\Example;
22 use Facebook\WebDriver\Remote\RemoteWebDriver;
23 use Facebook\WebDriver\Remote\RemoteWebElement;
26 
31 {
32  private static string ‪$defaultDashboardTitle = 'My Dashboard';
33 
34  public function ‪_before(‪ApplicationTester $I): void
35  {
36  $I->useExistingSession('admin');
37  $I->click('[data-modulemenu-identifier="system_dbint"]');
38  $I->switchToContentFrame();
39  }
40 
41  private function ‪recordStatisticsDataProvider(): array
42  {
43  return [
44  [
45  'name' => 'Total number of default language pages',
46  'count' => 84,
47  ],
48  [
49  'name' => 'Total number of translated pages',
50  'count' => 132,
51  ],
52  [
53  'name' => 'Marked-deleted pages',
54  'count' => 0,
55  ],
56  [
57  'name' => 'Hidden pages',
58  'count' => 1,
59  ],
60  [
61  'name' => 'Standard',
62  'count' => 1,
63  ],
64  [
65  'name' => 'Backend User Section',
66  'count' => 0,
67  ],
68  [
69  'name' => 'Link to External URL',
70  'count' => 0,
71  ],
72  ];
73  }
74 
75  #[DataProvider('recordStatisticsDataProvider')]
76  public function ‪seeRecordStatistics(‪ApplicationTester $I, Example $testData): void
77  {
78  $this->‪goToPageAndSeeHeadline($I, 'Record Statistics', 'Records Statistics');
79 
80  $count = $this->‪getCountByRowName($I, $testData['name'])->getText();
81  // Use >= here to make sure we don't get in trouble with other tests creating db entries
82  $I->assertGreaterThanOrEqual($testData['count'], $count);
83  }
84 
86  {
87  $this->‪goToPageAndSeeHeadline($I, 'Database Relations', 'Relations');
88  $I->see('Select fields', 'h2');
89  $I->see('Group fields', 'h2');
90  }
91 
92  public function ‪seeFullSearch(‪ApplicationTester $I, ‪ModalDialog $modalDialog): void
93  {
94  $this->‪goToPageAndSeeHeadline($I, 'Full search', 'Search whole Database');
95 
96  // Fill in search phrase and check results
97  $I->fillField('input[name="SET[sword]"]', 'styleguide demo group 1');
98  $I->click('Search All Records');
99  $I->see('Result', 'h2');
100  $I->see('styleguide demo group 1', 'td');
101  $I->dontSee('styleguide demo group 2', 'td');
102 
103  // Open info modal and see text in card
104  $I->click('a[data-dispatch-args-list]');
105  $modalDialog->‪canSeeDialog();
106  $I->switchToIFrame('.modal-iframe');
107  $I->see('styleguide demo group 1', '.card-title');
108  }
109 
111  {
112  $this->‪goToPageAndSeeHeadline($I, 'Manage Reference Index', 'Manage Reference Index');
113 
114  $I->click('Check reference index');
115  $I->waitForElement('.callout-warning');
116 
117  $I->click('Update reference index');
118  $I->waitForElement('.callout-warning');
119 
120  $I->click('Check reference index');
121  $I->waitForElement('.callout-success');
122  $I->see('Index integrity was perfect!', '.callout-success');
123 
124  $I->click('Update reference index');
125  $I->waitForElement('.callout-success');
126  $I->see('Index integrity was perfect!', '.callout-success');
127  }
128 
129  private function ‪goToPageAndSeeHeadline(‪ApplicationTester $I, string $select, string $headline): void
130  {
131  $I->selectOption('select[name=DatabaseJumpMenu]', $select);
132  $I->see($headline, 'h1');
133  }
134 
138  private function ‪getCountByRowName(‪ApplicationTester $I, string $rowName, int $sibling = 1): RemoteWebElement
139  {
140  $I->comment('Get context for table row "' . $rowName . '"');
141  return $I->executeInSelenium(
142  static function (RemoteWebDriver $webDriver) use ($rowName, $sibling) {
143  return $webDriver->findElement(
144  \Facebook\WebDriver\WebDriverBy::xpath(
145  '//td[contains(text(),"' . $rowName . '")]/following-sibling::td[' . $sibling . ']'
146  )
147  );
148  }
149  );
150  }
151 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest
Definition: DbCheckModuleCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\seeRecordStatistics
‪seeRecordStatistics(ApplicationTester $I, Example $testData)
Definition: DbCheckModuleCest.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\getCountByRowName
‪getCountByRowName(ApplicationTester $I, string $rowName, int $sibling=1)
Definition: DbCheckModuleCest.php:138
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\$defaultDashboardTitle
‪static string $defaultDashboardTitle
Definition: DbCheckModuleCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog\canSeeDialog
‪canSeeDialog()
Definition: ModalDialog.php:68
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\_before
‪_before(ApplicationTester $I)
Definition: DbCheckModuleCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\seeFullSearch
‪seeFullSearch(ApplicationTester $I, ModalDialog $modalDialog)
Definition: DbCheckModuleCest.php:92
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck
Definition: DbCheckModuleCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\seeDatabaseRelations
‪seeDatabaseRelations(ApplicationTester $I)
Definition: DbCheckModuleCest.php:85
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\goToPageAndSeeHeadline
‪goToPageAndSeeHeadline(ApplicationTester $I, string $select, string $headline)
Definition: DbCheckModuleCest.php:129
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\recordStatisticsDataProvider
‪recordStatisticsDataProvider()
Definition: DbCheckModuleCest.php:41
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog
Definition: ModalDialog.php:24
‪TYPO3\CMS\Core\Tests\Acceptance\Application\DbCheck\DbCheckModuleCest\seeManageReferenceIndex
‪seeManageReferenceIndex(ApplicationTester $I)
Definition: DbCheckModuleCest.php:110