Issue #3283794 by mondrake, longwave: Fix 'should return {type} but return statement is missing' PHPStan L0 errors in test code

merge-requests/2431/head
Alex Pott 2022-06-19 18:13:29 +01:00
parent 60d6c151a9
commit 9b485ec74d
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
92 changed files with 192 additions and 77 deletions

View File

@ -109,6 +109,7 @@ abstract class BlockResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -66,6 +66,7 @@ abstract class BlockContentTypeResourceTestBase extends ConfigEntityResourceTest
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -179,10 +179,8 @@ class CommentNonNodeTest extends BrowserTestBase {
$this->assertArrayHasKey(1, $match);
}
if (isset($match[1])) {
return Comment::load($match[1]);
}
}
/**
* Checks current page for specified comment.

View File

@ -317,16 +317,17 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
switch ($method) {
case 'GET';
case 'GET':
return "The 'access comments' permission is required and the comment must be published.";
case 'POST';
case 'POST':
return "The 'post comments' permission is required.";
case 'PATCH';
case 'PATCH':
return "The 'edit own comments' permission is required, the user must be the comment author, and the comment must be published.";
case 'DELETE':
default:
// \Drupal\comment\CommentAccessControlHandler::checkAccess() does not
// specify a reason for not allowing a comment to be deleted.
return '';

View File

@ -72,6 +72,7 @@ abstract class CommentTypeResourceTestBase extends ConfigEntityResourceTestBase
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -68,6 +68,7 @@ abstract class ConfigTestResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -85,6 +85,7 @@ abstract class ContactFormResourceTestBase extends ConfigEntityResourceTestBase
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -122,6 +122,7 @@ abstract class EditorResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -94,6 +94,7 @@ abstract class FieldConfigResourceTestBase extends ConfigEntityResourceTestBase
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -73,6 +73,7 @@ abstract class FieldStorageConfigResourceTestBase extends ConfigEntityResourceTe
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -83,6 +83,7 @@ abstract class FilterFormatResourceTestBase extends ConfigEntityResourceTestBase
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -99,6 +99,7 @@ abstract class ImageStyleResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -112,6 +112,7 @@ class ActionTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -123,6 +123,7 @@ class BaseFieldOverrideTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -103,6 +103,7 @@ class BlockContentTypeTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -136,6 +136,7 @@ class BlockTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update once https://www.drupal.org/node/2300677 is fixed.
return [];
}
/**

View File

@ -104,6 +104,7 @@ class CommentTypeTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -116,6 +116,7 @@ class ConfigTestTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -105,6 +105,7 @@ class ConfigurableLanguageTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -112,6 +112,7 @@ class ContactFormTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -116,6 +116,7 @@ class ContentLanguageSettingsTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -108,6 +108,7 @@ class DateFormatTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -156,6 +156,7 @@ class EditorTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -173,6 +173,7 @@ class EntityFormDisplayTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -106,6 +106,7 @@ class EntityFormModeTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -127,6 +127,7 @@ class EntityViewDisplayTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -106,6 +106,7 @@ class EntityViewModeTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -133,6 +133,7 @@ class FieldConfigTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -112,6 +112,7 @@ class FieldStorageConfigTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -5,6 +5,7 @@ namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Component\Render\PlainTextOutput;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTest;
@ -775,6 +776,7 @@ class FileUploadTest extends ResourceTestBase {
case 'PATCH':
return "The current user is not permitted to upload a file for this field. The 'administer entity_test content' permission is required.";
}
return '';
}
/**
@ -927,6 +929,7 @@ class FileUploadTest extends ResourceTestBase {
protected function getExpectedUnauthorizedAccessCacheability() {
// There is cacheability metadata to check as file uploads only allows POST
// requests, which will not return cacheable responses.
return new CacheableMetadata();
}
}

View File

@ -120,6 +120,7 @@ class FilterFormatTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -130,6 +130,7 @@ class ImageStyleTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -110,6 +110,7 @@ class MediaTypeTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -106,6 +106,7 @@ class MenuTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -265,6 +265,7 @@ class NodeTest extends ResourceTestBase {
case 'DELETE':
return "The 'access content' permission is required.";
}
return '';
}
/**

View File

@ -106,6 +106,7 @@ class NodeTypeTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -148,6 +148,7 @@ class RdfMappingTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -142,6 +142,7 @@ class ResponsiveImageStyleTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -2,6 +2,7 @@
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Url;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
@ -117,11 +118,15 @@ class RestJsonApiUnsupported extends ResourceTestBase {
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {}
protected function getExpectedUnauthorizedAccessMessage($method) {
return '';
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessCacheability() {}
protected function getExpectedUnauthorizedAccessCacheability() {
return (new CacheableMetadata());
}
}

View File

@ -126,6 +126,7 @@ class RestResourceConfigTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -101,6 +101,7 @@ class RoleTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -119,6 +119,7 @@ class SearchPageTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -123,6 +123,7 @@ class ShortcutSetTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -131,6 +131,7 @@ class TourTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -121,6 +121,7 @@ class ViewTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -100,6 +100,7 @@ class VocabularyTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -126,6 +126,7 @@ class WorkflowTest extends ConfigEntityResourceTestBase {
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -73,6 +73,7 @@ abstract class ConfigurableLanguageResourceTestBase extends ConfigEntityResource
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -77,6 +77,7 @@ abstract class ContentLanguageSettingsResourceTestBase extends ConfigEntityResou
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -43,56 +43,77 @@ class TestStateBasedSectionStorage extends SectionStorageBase {
/**
* {@inheritdoc}
*/
public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {}
public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
protected function getSectionList() {}
protected function getSectionList() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function getStorageId() {}
public function getStorageId() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function getSectionListFromId($id) {}
public function getSectionListFromId($id) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function buildRoutes(RouteCollection $collection) {}
public function buildRoutes(RouteCollection $collection) {
}
/**
* {@inheritdoc}
*/
public function getRedirectUrl() {}
public function getRedirectUrl() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function getLayoutBuilderUrl($rel = 'view') {}
public function getLayoutBuilderUrl($rel = 'view') {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function extractIdFromRoute($value, $definition, $name, array $defaults) {}
public function extractIdFromRoute($value, $definition, $name, array $defaults) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function deriveContextsFromRoute($value, $definition, $name, array $defaults) {}
public function deriveContextsFromRoute($value, $definition, $name, array $defaults) {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function label() {}
public function label() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function save() {}
public function save() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
}

View File

@ -3,6 +3,7 @@
namespace Drupal\Tests\layout_builder\Functional\Rest;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Url;
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
use Drupal\Tests\rest\Functional\ResourceTestBase;
@ -131,7 +132,9 @@ abstract class LayoutRestTestBase extends ResourceTestBase {
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessCacheability() {}
protected function getExpectedUnauthorizedAccessCacheability() {
return (new CacheableMetadata());
}
/**
* Gets the decoded contents.

View File

@ -73,6 +73,7 @@ abstract class MediaTypeResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -225,12 +225,16 @@ class TestSqlBase extends SqlBase {
/**
* {@inheritdoc}
*/
public function getIds() {}
public function getIds() {
return [];
}
/**
* {@inheritdoc}
*/
public function fields() {}
public function fields() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}

View File

@ -220,12 +220,16 @@ class TestSqlBase extends SqlBase {
/**
* {@inheritdoc}
*/
public function fields() {}
public function fields() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}
*/
public function query() {}
public function query() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**
* {@inheritdoc}

View File

@ -32,6 +32,7 @@ class TestMigrateExecutable extends MigrateExecutable {
*/
public function setStringTranslation(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
return $this;
}
/**

View File

@ -184,6 +184,7 @@ class TestDrupalSqlBase extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
}
/**

View File

@ -44,24 +44,28 @@ class IdConflictTest extends MigrateUpgradeExecuteTestBase {
* {@inheritdoc}
*/
protected function getEntityCounts() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getEntityCountsIncremental() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getAvailablePaths() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getMissingPaths() {
return [];
}
/**

View File

@ -51,24 +51,28 @@ class NodeClassicTest extends MigrateUpgradeExecuteTestBase {
* {@inheritdoc}
*/
protected function getEntityCounts() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getEntityCountsIncremental() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getAvailablePaths() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getMissingPaths() {
return [];
}
/**

View File

@ -287,30 +287,35 @@ class FilePathTest extends MigrateUpgradeTestBase {
* {@inheritdoc}
*/
protected function getEntityCounts() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getEntityCountsIncremental() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getAvailablePaths() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getMissingPaths() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getSourceBasePath() {
return '';
}
}

View File

@ -44,24 +44,28 @@ class IdConflictTest extends MigrateUpgradeExecuteTestBase {
* {@inheritdoc}
*/
protected function getEntityCounts() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getEntityCountsIncremental() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getAvailablePaths() {
return [];
}
/**
* {@inheritdoc}
*/
protected function getMissingPaths() {
return [];
}
/**

View File

@ -74,6 +74,7 @@ abstract class NodeTypeResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -111,6 +111,7 @@ abstract class RdfMappingResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -117,6 +117,7 @@ abstract class ResponsiveImageStyleResourceTestBase extends ConfigEntityResource
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\rest\Functional;
use Drupal\Component\Render\PlainTextOutput;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTest;
@ -819,6 +820,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
protected function getExpectedUnauthorizedAccessCacheability() {
// There is cacheability metadata to check as file uploads only allows POST
// requests, which will not return cacheable responses.
return new CacheableMetadata();
}
}

View File

@ -501,6 +501,8 @@ abstract class ResourceTestBase extends BrowserTestBase {
static::recursiveKSort($value);
}
}
return $array;
}
}

View File

@ -89,6 +89,7 @@ abstract class RestResourceConfigResourceTestBase extends ConfigEntityResourceTe
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -80,6 +80,7 @@ abstract class SearchPageResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -83,6 +83,7 @@ abstract class ShortcutSetResourceTestBase extends ConfigEntityResourceTestBase
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -68,6 +68,7 @@ abstract class EntityTestBundleResourceTestBase extends ConfigEntityResourceTest
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -43,7 +43,7 @@ class StubForm extends FormBase {
* {@inheritdoc}
*/
public function getFormId() {
$this->formId;
return $this->formId;
}
/**

View File

@ -75,6 +75,7 @@ abstract class ActionResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -64,6 +64,7 @@ abstract class MenuResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -415,6 +415,7 @@ class TestPathBasedBreadcrumbBuilder extends PathBasedBreadcrumbBuilder {
public function setStringTranslation(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
return $this;
}
public function setLinkGenerator(LinkGeneratorInterface $link_generator) {

View File

@ -63,6 +63,7 @@ abstract class VocabularyResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -94,6 +94,7 @@ abstract class TourResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -64,6 +64,7 @@ abstract class RoleResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -2,6 +2,7 @@
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Test\AssertMailTrait;
use Drupal\Core\Url;
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
@ -248,11 +249,15 @@ class UserRegistrationRestTest extends ResourceTestBase {
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {}
protected function getExpectedUnauthorizedAccessMessage($method) {
return '';
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessCacheability() {}
protected function getExpectedUnauthorizedAccessCacheability() {
return new CacheableMetadata();
}
}

View File

@ -27,12 +27,9 @@ trait ViewResultAssertionTrait {
* @param string $message
* (optional) A custom message to display with the assertion. Defaults to
* 'Identical result set.'
*
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
*/
protected function assertIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL) {
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertIdentical', $message);
protected function assertIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL): void {
$this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertIdentical', $message);
}
/**
@ -50,12 +47,9 @@ trait ViewResultAssertionTrait {
* @param string $message
* (optional) A custom message to display with the assertion. Defaults to
* 'Non-identical result set.'
*
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
*/
protected function assertNotIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL) {
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertNotIdentical', $message);
protected function assertNotIdenticalResultset($view, $expected_result, $column_map = [], $message = NULL): void {
$this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, 'assertNotIdentical', $message);
}
/**
@ -76,11 +70,8 @@ trait ViewResultAssertionTrait {
* 'assertNotIdentical').
* @param string $message
* (optional) The message to display with the assertion.
*
* @return bool
* TRUE if the assertion succeeded.
*/
protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $assert_method, $message = NULL) {
protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $assert_method, $message = NULL): void {
// Convert $view->result to an array of arrays.
$result = [];
foreach ($view->result as $key => $value) {
@ -142,11 +133,11 @@ trait ViewResultAssertionTrait {
switch ($assert_method) {
case 'assertIdentical':
$this->assertSame($expected_result, $result, $message);
return TRUE;
break;
case 'assertNotIdentical':
$this->assertNotSame($expected_result, $result, $message);
return TRUE;
break;
}
}

View File

@ -84,6 +84,7 @@ abstract class ViewResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -102,6 +102,7 @@ abstract class WorkflowResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -86,6 +86,7 @@ abstract class BaseFieldOverrideResourceTestBase extends ConfigEntityResourceTes
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -71,6 +71,7 @@ abstract class DateFormatResourceTestBase extends ConfigEntityResourceTestBase {
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -137,6 +137,7 @@ abstract class EntityFormDisplayResourceTestBase extends ConfigEntityResourceTes
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -69,6 +69,7 @@ abstract class EntityFormModeResourceTestBase extends ConfigEntityResourceTestBa
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -95,6 +95,7 @@ abstract class EntityViewDisplayResourceTestBase extends ConfigEntityResourceTes
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**

View File

@ -69,6 +69,7 @@ abstract class EntityViewModeResourceTestBase extends ConfigEntityResourceTestBa
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
}

View File

@ -429,11 +429,8 @@ trait AssertContentTrait {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE on pass, FALSE on fail.
*/
protected function assertRaw($raw, $message = '', $group = 'Other') {
protected function assertRaw($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Raw "' . Html::escape($raw) . '" found';
}
@ -457,11 +454,8 @@ trait AssertContentTrait {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE on pass, FALSE on fail.
*/
protected function assertNoRaw($raw, $message = '', $group = 'Other') {
protected function assertNoRaw($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Raw "' . Html::escape($raw) . '" not found';
}
@ -485,11 +479,8 @@ trait AssertContentTrait {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE on pass, FALSE on fail.
*/
protected function assertEscaped($raw, $message = '', $group = 'Other') {
protected function assertEscaped($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Escaped "' . Html::escape($raw) . '" found';
}
@ -514,11 +505,8 @@ trait AssertContentTrait {
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE on pass, FALSE on fail.
*/
protected function assertNoEscaped($raw, $message = '', $group = 'Other') {
protected function assertNoEscaped($raw, $message = '', $group = 'Other'): void {
if (!$message) {
$message = 'Escaped "' . Html::escape($raw) . '" not found';
}
@ -544,13 +532,10 @@ trait AssertContentTrait {
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE on pass, FALSE on fail.
*
* @see \Drupal\simpletest\AssertContentTrait::assertRaw()
*/
protected function assertText($text, $message = '', $group = 'Other') {
return $this->assertTextHelper($text, $message, $group, FALSE);
protected function assertText($text, $message = '', $group = 'Other'): void {
$this->assertTextHelper($text, $message, $group, FALSE);
}
/**
@ -572,13 +557,10 @@ trait AssertContentTrait {
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE on pass, FALSE on fail.
*
* @see \Drupal\simpletest\AssertContentTrait::assertNoRaw()
*/
protected function assertNoText($text, $message = '', $group = 'Other') {
return $this->assertTextHelper($text, $message, $group, TRUE);
protected function assertNoText($text, $message = '', $group = 'Other'): void {
$this->assertTextHelper($text, $message, $group, TRUE);
}
/**
@ -601,11 +583,8 @@ trait AssertContentTrait {
* @param bool $not_exists
* (optional) TRUE if this text should not exist, FALSE if it should.
* Defaults to TRUE.
*
* @return bool
* TRUE on pass, FALSE on fail.
*/
protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE) {
protected function assertTextHelper($text, $message = '', $group = 'Other', $not_exists = TRUE): void {
if (!$message) {
$message = !$not_exists ? new FormattableMarkup('"@text" found', ['@text' => $text]) : new FormattableMarkup('"@text" not found', ['@text' => $text]);
}

View File

@ -515,12 +515,14 @@ class BasicForm extends FormBase {
* {@inheritdoc}
*/
public function getFormId() {
return '';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_test = NULL) {
return [];
}
/**
@ -540,12 +542,14 @@ class BasicFormNoUpcasting extends FormBase {
* {@inheritdoc}
*/
public function getFormId() {
return '';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $entity_test = NULL) {
return [];
}
/**
@ -562,12 +566,14 @@ class BasicFormNoContainerInjectionInterface implements FormInterface {
* {@inheritdoc}
*/
public function getFormId() {
return '';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity_test = NULL) {
return [];
}
/**

View File

@ -385,6 +385,7 @@ class FieldDefinitionTest extends UnitTestCase {
$definition->setFieldStorageDefinition($this->storageDefinition);
return $definition;
}
throw new \InvalidArgumentException("Invalid factory name '$factory_name' passed to " . __METHOD__);
}
}

View File

@ -441,7 +441,9 @@ class PrepareCallbackTestForm implements FormInterface {
return 'test_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {}
public function buildForm(array $form, FormStateInterface $form_state) {
return [];
}
public function validateForm(array &$form, FormStateInterface $form_state) {}

View File

@ -116,6 +116,8 @@ class ImageTest extends UnitTestCase {
}
$this->image = new Image($this->toolkit, $this->source);
return $this->image;
}
/**
@ -140,6 +142,8 @@ class ImageTest extends UnitTestCase {
->will($this->returnValue($this->toolkitOperation));
$this->image = new Image($this->toolkit, $this->source);
return $this->image;
}
/**

View File

@ -86,10 +86,8 @@ abstract class LazyPluginCollectionTestBase extends UnitTestCase {
* The mock plugin object.
*/
public function returnPluginMap($plugin_id) {
if (isset($this->pluginInstances[$plugin_id])) {
return $this->pluginInstances[$plugin_id];
}
}
/**
* Returns a mocked plugin object.