Issue #3458426 by mstrelan, catch, abarrio, quietone, smustgrave: Add int return typehints to protected test helper methods

merge-requests/9874/merge
quietone 2024-10-24 14:07:06 +13:00
parent a1b47eafdb
commit 2319f33906
No known key found for this signature in database
GPG Key ID: 43BFBBB26EA09FE1
12 changed files with 13 additions and 13 deletions

View File

@ -255,7 +255,7 @@ abstract class MediaTestBase extends WebDriverTestBase {
* @return int
* The size of the bytes transferred.
*/
protected function getLastPreviewRequestTransferSize() {
protected function getLastPreviewRequestTransferSize(): int {
$javascript = <<<JS
(function(){
return window.performance

View File

@ -159,7 +159,7 @@ class EditModeTest extends WebDriverTestBase {
* @return int
* The number of tabbable elements.
*/
protected function getTabbableElementsCount() {
protected function getTabbableElementsCount(): int {
// Mark all tabbable elements.
$this->getSession()->executeScript("jQuery(window.tabbable.tabbable(document.body)).attr('data-marked', '');");
// Count all marked elements.

View File

@ -119,7 +119,7 @@ abstract class DateTimeHandlerTestBase extends ViewsKernelTestBase {
* @return int
* Unix timestamp.
*/
protected function getUTCEquivalentOfUserNowAsTimestamp() {
protected function getUTCEquivalentOfUserNowAsTimestamp(): int {
$user_now = new DateTimePlus('now', new \DateTimeZone(date_default_timezone_get()));
$utc_equivalent = new DateTimePlus($user_now->format('Y-m-d H:i:s'), new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE));

View File

@ -83,7 +83,7 @@ class DbLogTest extends KernelTestBase {
* @return int
* Number of new watchdog entries.
*/
private function runCron() {
private function runCron(): int {
$connection = Database::getConnection();
// Get last ID to compare against; log entries get deleted, so we can't
// reliably add the number of newly created log entries to the current count

View File

@ -62,7 +62,7 @@ class FileListingTest extends FileFieldTestBase {
* @return int
* Total usage count.
*/
protected function sumUsages($usage) {
protected function sumUsages($usage): int {
$count = 0;
foreach ($usage as $module) {
foreach ($module as $entity_type) {

View File

@ -214,7 +214,7 @@ class LanguageConfigurationTest extends BrowserTestBase {
* @return int
* Maximum weight of configurable languages.
*/
protected function getHighestConfigurableLanguageWeight() {
protected function getHighestConfigurableLanguageWeight(): int {
$max_weight = 0;
$storage = $this->container->get('entity_type.manager')

View File

@ -315,7 +315,7 @@ class LayoutBuilderDisableInteractionsTest extends WebDriverTestBase {
* @return int
* The element position.
*/
protected function getElementVerticalPosition($css_selector, $position_type) {
protected function getElementVerticalPosition($css_selector, $position_type): int {
$this->assertContains($position_type, ['top', 'bottom'], 'Expected position type.');
return (int) $this->getSession()->evaluateScript("document.querySelector('$css_selector').getBoundingClientRect().$position_type + window.pageYOffset");
}

View File

@ -466,7 +466,7 @@ abstract class BuildTestBase extends TestCase {
* @throws \RuntimeException
* Thrown when there are no available ports within the range.
*/
protected function findAvailablePort() {
protected function findAvailablePort(): int {
$store = new FlockStore(DrupalFilesystem::getOsTemporaryDirectory());
$lock_factory = new LockFactory($store);
@ -524,7 +524,7 @@ abstract class BuildTestBase extends TestCase {
*
* @return int
*/
protected function getPortNumber() {
protected function getPortNumber(): int {
if (empty($this->hostPort)) {
$this->hostPort = $this->findAvailablePort();
}

View File

@ -112,7 +112,7 @@ class DatabaseBackendTest extends GenericCacheBackendUnitTestBase {
* @return int
* The number of rows in the test cache bin database table.
*/
protected function getNumRows() {
protected function getNumRows(): int {
$table = 'cache_' . $this->testBin;
$connection = $this->container->get('database');
$query = $connection->select($table);

View File

@ -288,7 +288,7 @@ class EntityDecoupledTranslationRevisionsTest extends EntityKernelTestBase {
* @return int
* The latest saved revision id.
*/
protected function doTestEditSequence($sequence) {
protected function doTestEditSequence($sequence): int {
$revision_id = NULL;
foreach ($sequence as $index => $step) {
$this->stepIndex = $index;

View File

@ -452,7 +452,7 @@ class AttributeTest extends UnitTestCase {
* @return int
* The number of results that are found.
*/
protected function getXPathResultCount($query, $html) {
protected function getXPathResultCount($query, $html): int {
$document = Html::load($html);
$xpath = new \DOMXPath($document);

View File

@ -113,7 +113,7 @@ trait TestFileCreationTrait {
*
* @return int
*/
protected function compareFiles($file1, $file2) {
protected function compareFiles($file1, $file2): int {
$compare_size = filesize($file1->uri) - filesize($file2->uri);
if ($compare_size) {
// Sort by file size.