Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 301110

return value of void functions used in several places

$
0
0

NULL return value prevents further asserts

In \PHPUnit\Framework\TestCase tests $this->assertTrue() method has no return value.
In PHP that means it returns NULL.
NULL in if conditions converted to FALSE.

In the following example inside the if the $this->assertSame() never gonna check that the $foo['bar'] is equal to '1.0' or not.

<?php
$foo = ['bar' => 'something'],
if ($this->assertTrue(isset($foo['bar']))) {
  $this->assertSame('1.0', $foo['bar']);
}
?>
  1. \Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testDynamicLibrary
  2. \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationDeletion
  3. \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::assertPagePath
  4. \Drupal\KernelTests\Core\Entity\EntityCrudHookTest::assertHookMessageOrder
  5. \Drupal\Tests\views_ui\Functional\ExposedFormUITest::assertNoGroupedFilterErrors
  6. \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchArray
  7. \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchClass
  8. \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchNum
  9. \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchBoth
  10. \Drupal\KernelTests\Core\Field\FieldItemTest::assertSavedFieldItemValue
  11. \Drupal\Tests\image\Functional\ImageStyleDeleteTest::testDelete
  12. \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertTranslation
  13. \update_manager_file_get

Actual return value of a function does not match to its @return PhpDoc


The @return something should not be there, or should not be a return statement inside the function.

Bad

<?php
/**
 * @return bool
 */
function foo() {
  return myVoid();
}
?>

Good

<?php
function foo() {
  myVoid();
}
?>

If an $this->assert*() fails it throws an exception, it does not return TRUE or FALSE.

  1. \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::assertDisabledTextarea
  2. \Drupal\Tests\system\Functional\Form\ConfirmFormTest::assertCancelLinkUrl
  3. \Drupal\KernelTests\Core\Database\ConnectionUnitTest::assertConnection
  4. \Drupal\KernelTests\Core\Database\ConnectionUnitTest::assertNoConnection
  5. \Drupal\Tests\content_translation\Functional\ContentTranslationSettingsTest::assertSettings
  6. \Drupal\Tests\views_ui\Functional\DefaultViewsTest::clickViewsOperationLink
  7. \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase::assertDefinitionIdentical
  8. \Drupal\Tests\editor\Functional\EditorUploadImageScaleTest::assertSavedMaxDimensions
  9. \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::assertDependencyHelper
  10. \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::assertResults
  11. \Drupal\KernelTests\Core\Entity\EntityReferenceFieldTest::assertUserAutocreate
  12. \Drupal\KernelTests\Core\Entity\EntityReferenceFieldTest::assertUserRoleAutocreate
  13. \Drupal\Tests\system\Functional\System\ErrorHandlerTest::assertNoMessages
  14. \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::assertIds
  15. \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::assertSubString
  16. \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::assertNotSubString
  17. \Drupal\Tests\system\Functional\Update\FieldSchemaDataUninstallUpdateTest::assertFieldSchemaData
  18. \Drupal\KernelTests\Core\Entity\FieldTranslationSqlStorageTest::assertFieldStorageLangcode
  19. \Drupal\Tests\views\Functional\Handler\FieldWebTest::assertSubString
  20. \Drupal\Tests\views\Functional\Handler\FieldWebTest::assertNotSubString
  21. \file_delete
  22. \Drupal\Tests\filter\Kernel\FilterKernelTest::testLineBreakFilter
  23. \Drupal\Tests\filter\Kernel\FilterKernelTest::assertFilteredString
  24. \Drupal\Tests\filter\Kernel\FilterKernelTest::assertNormalized
  25. \Drupal\Tests\filter\Kernel\FilterKernelTest::assertNoNormalized
  26. \Drupal\Tests\views\Functional\Handler\HandlerTest::assertEqualValue
  27. \Drupal\KernelTests\Core\File\HtaccessTest::assertFilePermissions
  28. \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::assertHtmlToText
  29. \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testDrupalHtmlToTextBlockTagToNewline
  30. \Drupal\Tests\image\Functional\ImageEffectsTest::assertImageEffect
  31. \Drupal\KernelTests\KernelMissingDependentModuleMethodTest::publicCheckRequirements
  32. \Drupal\KernelTests\KernelMissingDependentModuleTest::publicCheckRequirements
  33. \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::assertAssetInLibrary
  34. \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::assertNoAssetInLibrary
  35. \locale_translation_batch_fetch_finished
  36. \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertNoConfigOverride
  37. \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertConfigOverride
  38. \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertActiveConfig
  39. \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertNoTranslation
  40. \Drupal\Tests\system\Functional\Menu\LocalTasksTest::assertLocalTaskAppers
  41. \Drupal\Tests\image\Kernel\Migrate\d6\MigrateImageCacheTest::assertImageEffect
  42. \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertTableCount
  43. \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesExist
  44. \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleConfig
  45. \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertNoModuleConfig
  46. \Drupal\Tests\system\Functional\Batch\ProcessingTest::assertBatchMessages
  47. \Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::assertTranslations
  48. \Drupal\Tests\views\Functional\SearchIntegrationTest::assertOneLink
  49. \Drupal\Tests\system\Functional\Session\SessionHttpsTest::assertSessionIds
  50. \Drupal\Tests\system\Functional\Session\SessionTest::testSessionSaveRegenerate
  51. \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::assertShortcutQuickLink
  52. \Drupal\KernelTests\Core\Image\ToolkitGdTest::checkRequirements
  53. \Drupal\KernelTests\Core\Database\TransactionTest::assertRowPresent
  54. \Drupal\KernelTests\Core\Database\TransactionTest::assertRowAbsent
  55. \Drupal\Tests\system\Functional\Path\UrlAlterFunctionalTest::assertUrlOutboundAlter
  56. \Drupal\Tests\system\Functional\Path\UrlAlterFunctionalTest::assertUrlInboundAlter

Viewing all articles
Browse latest Browse all 301110

Trending Articles