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']);
}
?>
- \Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testDynamicLibrary
- \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationDeletion
- \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::assertPagePath
- \Drupal\KernelTests\Core\Entity\EntityCrudHookTest::assertHookMessageOrder
- \Drupal\Tests\views_ui\Functional\ExposedFormUITest::assertNoGroupedFilterErrors
- \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchArray
- \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchClass
- \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchNum
- \Drupal\KernelTests\Core\Database\FetchTest::testQueryFetchBoth
- \Drupal\KernelTests\Core\Field\FieldItemTest::assertSavedFieldItemValue
- \Drupal\Tests\image\Functional\ImageStyleDeleteTest::testDelete
- \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertTranslation
- \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.
- \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::assertDisabledTextarea
- \Drupal\Tests\system\Functional\Form\ConfirmFormTest::assertCancelLinkUrl
- \Drupal\KernelTests\Core\Database\ConnectionUnitTest::assertConnection
- \Drupal\KernelTests\Core\Database\ConnectionUnitTest::assertNoConnection
- \Drupal\Tests\content_translation\Functional\ContentTranslationSettingsTest::assertSettings
- \Drupal\Tests\views_ui\Functional\DefaultViewsTest::clickViewsOperationLink
- \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase::assertDefinitionIdentical
- \Drupal\Tests\editor\Functional\EditorUploadImageScaleTest::assertSavedMaxDimensions
- \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::assertDependencyHelper
- \Drupal\KernelTests\Core\Entity\EntityQueryAggregateTest::assertResults
- \Drupal\KernelTests\Core\Entity\EntityReferenceFieldTest::assertUserAutocreate
- \Drupal\KernelTests\Core\Entity\EntityReferenceFieldTest::assertUserRoleAutocreate
- \Drupal\Tests\system\Functional\System\ErrorHandlerTest::assertNoMessages
- \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::assertIds
- \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::assertSubString
- \Drupal\Tests\views\Kernel\Handler\FieldKernelTest::assertNotSubString
- \Drupal\Tests\system\Functional\Update\FieldSchemaDataUninstallUpdateTest::assertFieldSchemaData
- \Drupal\KernelTests\Core\Entity\FieldTranslationSqlStorageTest::assertFieldStorageLangcode
- \Drupal\Tests\views\Functional\Handler\FieldWebTest::assertSubString
- \Drupal\Tests\views\Functional\Handler\FieldWebTest::assertNotSubString
- \file_delete
- \Drupal\Tests\filter\Kernel\FilterKernelTest::testLineBreakFilter
- \Drupal\Tests\filter\Kernel\FilterKernelTest::assertFilteredString
- \Drupal\Tests\filter\Kernel\FilterKernelTest::assertNormalized
- \Drupal\Tests\filter\Kernel\FilterKernelTest::assertNoNormalized
- \Drupal\Tests\views\Functional\Handler\HandlerTest::assertEqualValue
- \Drupal\KernelTests\Core\File\HtaccessTest::assertFilePermissions
- \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::assertHtmlToText
- \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testDrupalHtmlToTextBlockTagToNewline
- \Drupal\Tests\image\Functional\ImageEffectsTest::assertImageEffect
- \Drupal\KernelTests\KernelMissingDependentModuleMethodTest::publicCheckRequirements
- \Drupal\KernelTests\KernelMissingDependentModuleTest::publicCheckRequirements
- \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::assertAssetInLibrary
- \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::assertNoAssetInLibrary
- \locale_translation_batch_fetch_finished
- \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertNoConfigOverride
- \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertConfigOverride
- \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertActiveConfig
- \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest::assertNoTranslation
- \Drupal\Tests\system\Functional\Menu\LocalTasksTest::assertLocalTaskAppers
- \Drupal\Tests\image\Kernel\Migrate\d6\MigrateImageCacheTest::assertImageEffect
- \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertTableCount
- \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleTablesExist
- \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertModuleConfig
- \Drupal\Tests\system\Functional\Module\ModuleTestBase::assertNoModuleConfig
- \Drupal\Tests\system\Functional\Batch\ProcessingTest::assertBatchMessages
- \Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::assertTranslations
- \Drupal\Tests\views\Functional\SearchIntegrationTest::assertOneLink
- \Drupal\Tests\system\Functional\Session\SessionHttpsTest::assertSessionIds
- \Drupal\Tests\system\Functional\Session\SessionTest::testSessionSaveRegenerate
- \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::assertShortcutQuickLink
- \Drupal\KernelTests\Core\Image\ToolkitGdTest::checkRequirements
- \Drupal\KernelTests\Core\Database\TransactionTest::assertRowPresent
- \Drupal\KernelTests\Core\Database\TransactionTest::assertRowAbsent
- \Drupal\Tests\system\Functional\Path\UrlAlterFunctionalTest::assertUrlOutboundAlter
- \Drupal\Tests\system\Functional\Path\UrlAlterFunctionalTest::assertUrlInboundAlter