From 3872f1a8edf33728d9c7aeca1c72e94d26a7e00e Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 20 May 2021 22:10:07 +0100 Subject: [PATCH] Issue #3139404 by mondrake, munish.kumar, pavnish, longwave: [May 25, 2021] Replace usages of AssertLegacyTrait::assertText, that is deprecated --- .../src/Functional/ConfigurationTest.php | 8 +- .../tests/src/Functional/AddFeedTest.php | 4 +- .../src/Functional/AggregatorAdminTest.php | 12 +- .../Functional/AggregatorRenderingTest.php | 2 +- .../src/Functional/AggregatorTestBase.php | 2 +- .../tests/src/Functional/DeleteFeedTest.php | 2 +- .../src/Functional/FeedAdminDisplayTest.php | 14 +- .../tests/src/Functional/FeedParserTest.php | 20 +-- .../tests/src/Functional/ImportOpmlTest.php | 8 +- .../src/Functional/UpdateFeedItemTest.php | 2 +- .../tests/src/Functional/UpdateFeedTest.php | 4 +- .../src/Functional/IpAddressBlockingTest.php | 10 +- .../tests/src/Functional/BasicAuthTest.php | 12 +- .../tests/src/Functional/BlockCacheTest.php | 32 ++--- .../src/Functional/BlockFormInBlockTest.php | 10 +- .../src/Functional/BlockHiddenRegionTest.php | 4 +- .../tests/src/Functional/BlockInstallTest.php | 2 +- .../src/Functional/BlockLanguageCacheTest.php | 4 +- .../src/Functional/BlockLanguageTest.php | 8 +- .../block/tests/src/Functional/BlockTest.php | 28 ++-- .../tests/src/Functional/BlockUiTest.php | 10 +- .../Functional/BlockContentCreationTest.php | 4 +- .../src/Functional/BlockContentListTest.php | 2 +- .../Functional/BlockContentListViewsTest.php | 2 +- .../src/Functional/BlockContentTypeTest.php | 4 +- .../tests/src/Functional/PageEditTest.php | 2 +- .../Views/BlockContentRedirectTest.php | 2 +- .../book/tests/src/Functional/BookTest.php | 26 ++-- .../tests/src/Functional/BookTestTrait.php | 2 +- .../src/Functional/CKEditorAdminTest.php | 2 +- .../src/Functional/ColorSafePreviewTest.php | 2 +- .../color/tests/src/Functional/ColorTest.php | 4 +- .../tests/src/Functional/CommentAdminTest.php | 30 ++-- .../src/Functional/CommentAnonymousTest.php | 2 +- .../tests/src/Functional/CommentBlockTest.php | 6 +- .../tests/src/Functional/CommentBookTest.php | 12 +- .../src/Functional/CommentCacheTagsTest.php | 2 +- .../src/Functional/CommentFieldsTest.php | 2 +- .../src/Functional/CommentInterfaceTest.php | 16 +-- .../tests/src/Functional/CommentLinksTest.php | 4 +- .../src/Functional/CommentNodeAccessTest.php | 12 +- .../src/Functional/CommentNonNodeTest.php | 10 +- .../tests/src/Functional/CommentPagerTest.php | 4 +- .../src/Functional/CommentPreviewTest.php | 22 +-- .../tests/src/Functional/CommentTestBase.php | 8 +- .../tests/src/Functional/CommentTypeTest.php | 4 +- .../src/Functional/Views/CommentAdminTest.php | 32 ++--- .../src/Functional/Views/CommentEditTest.php | 4 +- ...yMetadataConfigOverrideIntegrationTest.php | 2 +- .../Functional/ConfigDependencyWebTest.php | 8 +- .../ConfigEntityFormOverrideTest.php | 4 +- .../src/Functional/ConfigEntityListTest.php | 2 +- .../tests/src/Functional/ConfigEntityTest.php | 4 +- .../Functional/ConfigExportImportUITest.php | 34 ++--- .../ConfigImportInstallProfileTest.php | 6 +- .../src/Functional/ConfigImportUITest.php | 79 +++++------ .../src/Functional/ConfigImportUploadTest.php | 2 +- .../ConfigLanguageOverrideWebTest.php | 4 +- .../ConfigSingleImportExportTest.php | 16 +-- .../LanguageNegotiationFormOverrideTest.php | 4 +- .../SchemaConfigListenerWebTest.php | 2 +- .../TransformedConfigExportImportUITest.php | 15 +- .../Functional/ConfigTranslationCacheTest.php | 4 +- .../ConfigTranslationOverviewTest.php | 14 +- .../Functional/ConfigTranslationUiTest.php | 34 ++--- .../src/Functional/ContactPersonalTest.php | 4 +- .../src/Functional/ContactSitewideTest.php | 44 +++--- .../src/Functional/ContactStorageTest.php | 6 +- .../src/Functional/ModerationFormTest.php | 8 +- .../src/Functional/ModerationLocaleTest.php | 26 ++-- .../Functional/ModerationStateBlockTest.php | 18 +-- .../Functional/ModerationStateNodeTest.php | 10 +- .../ModerationStateNodeTypeTest.php | 6 +- ...kspaceContentModerationIntegrationTest.php | 8 +- .../ContentTranslationEnableTest.php | 4 +- .../ContentTranslationSettingsTest.php | 6 +- .../ContentTranslationUISkipTest.php | 4 +- .../ContentTranslationUITestBase.php | 2 +- .../tests/src/Functional/DateFilterTest.php | 2 +- .../src/Functional/DateTimeFieldTest.php | 32 ++--- .../src/Functional/DateRangeFieldTest.php | 62 ++++---- .../dblog/tests/src/Functional/DbLogTest.php | 38 ++--- .../Functional/Boolean/BooleanFieldTest.php | 14 +- .../src/Functional/Email/EmailFieldTest.php | 2 +- .../EntityReferenceAdminTest.php | 10 +- .../EntityReferenceAutoCreateTest.php | 4 +- ...erenceFieldTranslatedReferenceViewTest.php | 8 +- .../tests/src/Functional/FieldAccessTest.php | 2 +- .../tests/src/Functional/FieldHelpTest.php | 2 +- .../FieldImportDeleteUninstallUiTest.php | 4 +- .../field/tests/src/Functional/FormTest.php | 20 +-- .../src/Functional/Number/NumberFieldTest.php | 10 +- .../Functional/ReEnableModuleFieldTest.php | 6 +- .../src/Functional/String/StringFieldTest.php | 2 +- .../src/Functional/EntityDisplayModeTest.php | 4 +- .../src/Functional/FieldUIDeleteTest.php | 6 +- .../tests/src/Functional/FieldUIRouteTest.php | 2 +- .../Functional/ManageFieldsFunctionalTest.php | 28 ++-- .../FileFieldAnonymousSubmissionTest.php | 14 +- .../src/Functional/FileFieldDisplayTest.php | 4 +- .../src/Functional/FileFieldValidateTest.php | 2 +- .../tests/src/Functional/FileListingTest.php | 14 +- .../Functional/FileManagedFileElementTest.php | 10 +- .../src/Functional/SaveUploadFormTest.php | 4 +- .../tests/src/Functional/FilterAdminTest.php | 6 +- .../src/Functional/FilterFormatAccessTest.php | 18 +-- .../tests/src/Functional/FilterHooksTest.php | 8 +- .../src/Functional/FilterSecurityTest.php | 4 +- .../tests/src/Functional/ForumIndexTest.php | 4 +- .../src/Functional/ForumNodeAccessTest.php | 6 +- .../forum/tests/src/Functional/ForumTest.php | 14 +- .../src/Functional/ForumUninstallTest.php | 6 +- .../src/Functional/ExperimentalHelpTest.php | 4 +- .../tests/src/Functional/HelpBlockTest.php | 8 +- .../help/tests/src/Functional/HelpTest.php | 6 +- .../help/tests/src/Functional/NoHelpTest.php | 2 +- .../src/Functional/HelpTopicSearchTest.php | 2 +- .../src/Functional/ImageAdminStylesTest.php | 10 +- .../ImageFieldDefaultImagesTest.php | 4 +- .../src/Functional/ImageFieldDisplayTest.php | 8 +- .../src/Functional/ImageFieldValidateTest.php | 10 +- .../src/Functional/ImageFieldWidgetTest.php | 6 +- .../LanguageBrowserDetectionTest.php | 4 +- .../LanguageConfigOverrideImportTest.php | 6 +- .../Functional/LanguageConfigurationTest.php | 6 +- ...anguageCustomLanguageConfigurationTest.php | 4 +- .../tests/src/Functional/LanguageListTest.php | 10 +- .../src/Functional/LanguageLocaleListTest.php | 2 +- .../LanguagePathMonolingualTest.php | 2 +- .../src/Functional/LanguageSwitchingTest.php | 8 +- .../LanguageUILanguageNegotiationTest.php | 8 +- .../Functional/LanguageUrlRewritingTest.php | 2 +- .../tests/src/Functional/LinkFieldTest.php | 20 +-- .../tests/src/Functional/LinkFieldUITest.php | 2 +- .../LocaleConfigTranslationImportTest.php | 6 +- .../LocaleConfigTranslationTest.php | 2 +- .../src/Functional/LocaleContentTest.php | 6 +- .../Functional/LocaleImportFunctionalTest.php | 10 +- .../tests/src/Functional/LocalePathTest.php | 10 +- .../src/Functional/LocalePluralFormatTest.php | 28 ++-- .../Functional/LocaleTranslationUiTest.php | 34 ++--- .../Functional/LocaleUpdateInterfaceTest.php | 22 +-- .../tests/src/Functional/LocaleUpdateTest.php | 16 +-- .../MenuLinkContentDeleteFormTest.php | 2 +- .../Functional/MenuLinkContentFormTest.php | 4 +- .../tests/src/Functional/MenuUiNodeTest.php | 6 +- .../tests/src/Functional/MenuUiTest.php | 28 ++-- .../src/Functional/MigrateAccessTest.php | 2 +- .../src/Functional/NodeAccessFieldTest.php | 6 +- .../src/Functional/NodeAccessPagerTest.php | 4 +- .../NodeAccessRebuildNodeGrantsTest.php | 4 +- .../NodeActionsConfigurationTest.php | 8 +- .../Functional/NodeBlockFunctionalTest.php | 20 +-- .../tests/src/Functional/NodeCreationTest.php | 10 +- .../tests/src/Functional/NodeEditFormTest.php | 10 +- .../NodeEntityViewModeAlterTest.php | 2 +- .../tests/src/Functional/NodeHelpTest.php | 4 +- .../tests/src/Functional/NodeLinksTest.php | 4 +- .../src/Functional/NodeRSSContentTest.php | 2 +- .../src/Functional/NodeRevisionsAllTest.php | 12 +- .../src/Functional/NodeRevisionsTest.php | 28 ++-- .../src/Functional/NodeTranslationUITest.php | 6 +- .../tests/src/Functional/NodeTypeTest.php | 2 +- .../Functional/NodeTypeTranslationTest.php | 8 +- .../src/Functional/NodeViewLanguageTest.php | 2 +- .../tests/src/Functional/PagePreviewTest.php | 30 ++-- .../src/Functional/Views/BulkFormTest.php | 10 +- .../Functional/Views/FilterNodeAccessTest.php | 20 +-- .../src/Functional/Views/FrontPageTest.php | 2 +- .../src/Functional/Views/NodeLanguageTest.php | 26 ++-- .../src/Functional/Views/StatusExtraTest.php | 24 ++-- .../src/Functional/OptionsFieldUITest.php | 4 +- .../src/Functional/OptionsWidgetsTest.php | 4 +- .../tests/src/Functional/PageCacheTest.php | 12 +- .../tests/src/Functional/PathAliasTest.php | 28 ++-- .../tests/src/Functional/PathLanguageTest.php | 12 +- .../src/Functional/PathLanguageUiTest.php | 6 +- .../src/Functional/PathTaxonomyTermTest.php | 4 +- .../src/Functional/UrlAlterFunctionalTest.php | 6 +- .../Functional/ResponsiveImageAdminUITest.php | 6 +- .../Functional/Views/StyleSerializerTest.php | 2 +- .../SearchAdvancedSearchFormTest.php | 12 +- .../tests/src/Functional/SearchBlockTest.php | 12 +- .../SearchCommentCountToggleTest.php | 6 +- .../src/Functional/SearchCommentTest.php | 16 +-- .../SearchConfigSettingsFormTest.php | 18 +-- .../src/Functional/SearchEmbedFormTest.php | 6 +- .../tests/src/Functional/SearchExactTest.php | 4 +- .../SearchKeywordsConditionsTest.php | 6 +- .../src/Functional/SearchLanguageTest.php | 8 +- .../SearchMultilingualEntityTest.php | 12 +- .../Functional/SearchNodePunctuationTest.php | 6 +- .../SearchNodeUpdateAndDeletionTest.php | 6 +- .../Functional/SearchNumberMatchingTest.php | 4 +- .../src/Functional/SearchNumbersTest.php | 4 +- .../Functional/SearchPageCacheTagsTest.php | 14 +- .../src/Functional/SearchPageOverrideTest.php | 4 +- .../src/Functional/SearchPageTextTest.php | 30 ++-- .../SearchPreprocessLangcodeTest.php | 10 +- .../src/Functional/SearchQueryAlterTest.php | 2 +- .../src/Functional/SearchRankingTest.php | 2 +- .../src/Functional/ShortcutLinksTest.php | 22 +-- .../tests/src/Functional/ShortcutSetsTest.php | 6 +- .../src/Functional/StatisticsAdminTest.php | 10 +- .../src/Functional/StatisticsReportsTest.php | 8 +- .../tests/src/Functional/SyslogTest.php | 2 +- .../tests/src/Functional/Batch/PageTest.php | 4 +- .../src/Functional/Batch/ProcessingTest.php | 28 ++-- .../src/Functional/Common/FormatDateTest.php | 2 +- .../Condition/ConditionFormTest.php | 6 +- .../DrupalKernel/ContentNegotiationTest.php | 2 +- .../src/Functional/Entity/EntityAddUITest.php | 6 +- .../Functional/Entity/EntityRevisionsTest.php | 4 +- .../Entity/EntityTranslationFormTest.php | 2 +- .../Entity/EntityViewControllerTest.php | 2 +- .../tests/src/Functional/File/ConfigTest.php | 8 +- .../Functional/Form/ArbitraryRebuildTest.php | 4 +- .../src/Functional/Form/ConfirmFormTest.php | 4 +- .../tests/src/Functional/Form/ElementTest.php | 2 +- .../Functional/Form/ElementsAccessTest.php | 2 +- .../src/Functional/Form/FormObjectTest.php | 30 ++-- .../Form/FormStoragePageCacheTest.php | 16 +-- .../tests/src/Functional/Form/FormTest.php | 12 +- .../Form/ModulesListFormWebTest.php | 8 +- .../Functional/Form/SystemConfigFormTest.php | 2 +- .../src/Functional/Form/ValidationTest.php | 28 ++-- .../Functional/Lock/LockFunctionalTest.php | 16 +-- .../src/Functional/Menu/MenuRouterTest.php | 28 ++-- .../src/Functional/Module/ClassLoaderTest.php | 2 +- .../src/Functional/Module/DependencyTest.php | 12 +- .../Module/ExperimentalModuleTest.php | 24 ++-- .../Module/HookRequirementsTest.php | 2 +- .../Module/InstallUninstallTest.php | 28 ++-- .../Module/PrepareUninstallTest.php | 46 +++--- .../src/Functional/Module/UninstallTest.php | 24 ++-- .../tests/src/Functional/Pager/PagerTest.php | 12 +- .../Render/HtmlResponseAttachmentsTest.php | 4 +- .../src/Functional/Routing/RouterTest.php | 10 +- .../ServiceProviderWebTest.php | 2 +- .../Functional/Session/SessionHttpsTest.php | 2 +- .../src/Functional/Session/SessionTest.php | 24 ++-- .../Functional/System/AccessDeniedTest.php | 16 +-- .../tests/src/Functional/System/AdminTest.php | 2 +- .../src/Functional/System/CronRunTest.php | 6 +- .../System/DateFormatsLockedTest.php | 2 +- .../System/DateFormatsMachineNameTest.php | 10 +- .../src/Functional/System/DateTimeTest.php | 36 ++--- .../Functional/System/ErrorHandlerTest.php | 2 +- .../src/Functional/System/FrontPageTest.php | 12 +- .../src/Functional/System/HtaccessTest.php | 4 +- .../System/MainContentFallbackTest.php | 6 +- .../Functional/System/PageNotFoundTest.php | 8 +- .../src/Functional/System/PageTitleTest.php | 4 +- .../Functional/System/SiteMaintenanceTest.php | 12 +- .../src/Functional/System/StatusTest.php | 6 +- .../Functional/System/SystemAuthorizeTest.php | 4 +- .../tests/src/Functional/System/ThemeTest.php | 14 +- .../Functional/System/TokenReplaceWebTest.php | 4 +- .../Functional/System/TrustedHostsTest.php | 2 +- .../Functional/Theme/EngineNyanCatTest.php | 2 +- .../Theme/ExperimentalThemeTest.php | 38 ++--- .../src/Functional/Theme/ThemeLegacyTest.php | 14 +- .../Theme/ThemeSuggestionsAlterTest.php | 24 ++-- .../tests/src/Functional/Theme/ThemeTest.php | 8 +- .../src/Functional/Theme/ThemeUiTest.php | 2 +- .../Functional/Theme/TwigExtensionTest.php | 6 +- .../Theme/TwigRegistryLoaderTest.php | 16 +-- .../src/Functional/Theme/TwigTransTest.php | 20 +-- .../UpdateSystem/InvalidUpdateHookTest.php | 2 +- .../UpdatePathTestBaseFilledTest.php | 134 +++++++++--------- .../UpdateSystem/UpdatePostUpdateTest.php | 2 +- .../UpdateSystem/UpdateScriptTest.php | 34 ++--- .../UpdateSystem/UpdatesWith7xTest.php | 2 +- .../src/Functional/TaxonomyImageTest.php | 2 +- .../tests/src/Functional/TermTest.php | 36 ++--- .../TermTranslationFieldViewTest.php | 4 +- .../src/Functional/TermTranslationTest.php | 12 +- .../Views/TaxonomyFieldAllTermsTest.php | 10 +- .../Functional/Views/TaxonomyTermViewTest.php | 12 +- .../Views/TaxonomyVocabularyArgumentTest.php | 2 +- .../Functional/VocabularyPermissionsTest.php | 10 +- .../tests/src/Functional/VocabularyUiTest.php | 18 +-- .../tests/src/Functional/TextFieldTest.php | 6 +- .../src/Functional/ToolbarAdminMenuTest.php | 16 +-- .../Functional/ToolbarMenuTranslationTest.php | 4 +- .../tests/src/Functional/TourHelpPageTest.php | 6 +- .../tour/tests/src/Functional/TourTest.php | 2 +- .../src/Functional/TrackerNodeAccessTest.php | 14 +- .../tests/src/Functional/TrackerTest.php | 20 +-- .../FileTransferAuthorizeFormTest.php | 4 +- .../src/Functional/UpdateContribTest.php | 24 ++-- .../src/Functional/UpdateSemverCoreTest.php | 16 +-- .../tests/src/Functional/UpdateUploadTest.php | 4 +- .../src/Functional/UserAdminLanguageTest.php | 16 +-- .../tests/src/Functional/UserAdminTest.php | 16 +-- .../tests/src/Functional/UserBlocksTest.php | 2 +- .../tests/src/Functional/UserCancelTest.php | 48 +++---- .../src/Functional/UserCreateFailMailTest.php | 2 +- .../tests/src/Functional/UserCreateTest.php | 8 +- .../tests/src/Functional/UserEditTest.php | 8 +- .../Functional/UserLanguageCreationTest.php | 2 +- .../tests/src/Functional/UserLanguageTest.php | 6 +- .../tests/src/Functional/UserLoginTest.php | 2 +- .../src/Functional/UserPasswordResetTest.php | 22 +-- .../src/Functional/UserPermissionsTest.php | 4 +- .../src/Functional/UserRegistrationTest.php | 18 +-- .../src/Functional/UserRoleAdminTest.php | 2 +- .../Functional/UserRolesAssignmentTest.php | 8 +- .../tests/src/Functional/UserSearchTest.php | 24 ++-- .../tests/src/Functional/UserTimeZoneTest.php | 22 +-- .../src/Functional/Views/BulkFormTest.php | 4 +- .../Views/FilterPermissionUiTest.php | 4 +- .../Functional/Views/HandlerFieldRoleTest.php | 2 +- .../src/Functional/Views/UserChangedTest.php | 2 +- .../Views/UserFieldsAccessChangeTest.php | 12 +- .../tests/src/Functional/BulkFormTest.php | 12 +- .../Functional/Entity/BaseFieldAccessTest.php | 2 +- .../Entity/ViewNonTranslatableEntityTest.php | 4 +- .../tests/src/Functional/Handler/AreaTest.php | 8 +- .../src/Functional/Handler/FilterDateTest.php | 2 +- .../ContextualFiltersBlockContextTest.php | 6 +- .../Plugin/DisplayEntityReferenceTest.php | 4 +- .../src/Functional/Plugin/DisplayTest.php | 12 +- .../src/Functional/Plugin/ExposedFormTest.php | 4 +- .../src/Functional/Plugin/FilterTest.php | 2 +- .../src/Functional/Plugin/MenuLinkTest.php | 6 +- .../src/Functional/Plugin/MiniPagerTest.php | 56 ++++---- .../tests/src/Functional/Plugin/PagerTest.php | 14 +- .../src/Functional/Plugin/ViewsBulkTest.php | 6 +- .../src/Functional/TaxonomyGlossaryTest.php | 2 +- .../src/Functional/ViewsEscapingTest.php | 2 +- .../src/Functional/ViewsFormMultipleTest.php | 6 +- .../tests/src/Functional/Wizard/BasicTest.php | 34 ++--- .../Functional/Wizard/ItemsPerPageTest.php | 18 +-- .../src/Functional/Wizard/SortingTest.php | 16 +-- .../src/Functional/Wizard/TaggedWithTest.php | 6 +- .../tests/src/Functional/CachedDataUITest.php | 2 +- .../tests/src/Functional/DefaultViewsTest.php | 6 +- .../src/Functional/DisplayAttachmentTest.php | 6 +- .../tests/src/Functional/DisplayCRUDTest.php | 2 +- .../tests/src/Functional/DisplayFeedTest.php | 2 +- .../tests/src/Functional/DisplayPathTest.php | 16 +-- .../tests/src/Functional/DisplayTest.php | 8 +- .../tests/src/Functional/DuplicateTest.php | 2 +- .../src/Functional/ExposedFormUITest.php | 10 +- .../tests/src/Functional/FieldUITest.php | 2 +- .../src/Functional/FilterNumericWebTest.php | 20 +-- .../tests/src/Functional/FilterUITest.php | 6 +- .../tests/src/Functional/HandlerTest.php | 2 +- .../src/Functional/OverrideDisplaysTest.php | 32 ++--- .../tests/src/Functional/PreviewTest.php | 26 ++-- .../tests/src/Functional/SettingsTest.php | 6 +- .../src/Functional/TokenizeAreaUITest.php | 4 +- .../src/Functional/UnsavedPreviewTest.php | 2 +- .../tests/src/Functional/ViewEditTest.php | 10 +- .../tests/src/Functional/WizardTest.php | 16 +-- .../tests/src/Functional/WorkspaceTest.php | 4 +- .../tests/src/Functional/MinimalTest.php | 6 +- .../tests/src/Functional/StandardTest.php | 32 ++--- .../FunctionalTests/BrowserTestBaseTest.php | 3 +- .../Image/ToolkitSetupFormTest.php | 2 +- ...istributionProfileExistingSettingsTest.php | 2 +- .../Installer/DistributionProfileTest.php | 2 +- ...istributionProfileTranslationQueryTest.php | 4 +- .../DistributionProfileTranslationTest.php | 4 +- ...ConfigDirectorySetNoDirectoryErrorTest.php | 2 +- .../InstallerExistingConfigNoConfigTest.php | 4 +- ...nstallerExistingConfigNoSystemSiteTest.php | 4 +- ...tallerExistingConfigProfileHookInstall.php | 4 +- ...ConfigSyncDriectoryProfileMismatchTest.php | 4 +- ...nEnglishProfileWithoutLocaleModuleTest.php | 2 +- .../Installer/InstallerPostInstallTest.php | 4 +- .../Installer/InstallerTest.php | 2 +- ...stallerTranslationMultipleLanguageTest.php | 8 +- .../InstallerTranslationQueryTest.php | 2 +- .../Installer/InstallerTranslationTest.php | 4 +- .../MultipleDistributionsProfileTest.php | 2 +- .../Installer/SingleVisibleProfileTest.php | 2 +- .../FunctionalTests/Theme/ClaroTest.php | 2 +- .../FunctionalTests/Theme/OliveroTest.php | 2 +- .../Update/UpdatePathTestBaseTest.php | 2 +- .../Listeners/DeprecationListenerTrait.php | 1 - 382 files changed, 1935 insertions(+), 1935 deletions(-) diff --git a/core/modules/action/tests/src/Functional/ConfigurationTest.php b/core/modules/action/tests/src/Functional/ConfigurationTest.php index 99ce8f972700..3746426afe9b 100644 --- a/core/modules/action/tests/src/Functional/ConfigurationTest.php +++ b/core/modules/action/tests/src/Functional/ConfigurationTest.php @@ -52,9 +52,9 @@ public function testActionConfiguration() { $action_id = $edit['id']; // Make sure that the new complex action was saved properly. - $this->assertText('The action has been successfully saved.'); + $this->assertSession()->pageTextContains('The action has been successfully saved.'); // The action label appears on the configuration page. - $this->assertText($action_label); + $this->assertSession()->pageTextContains($action_label); // Make another POST request to the action edit page. $this->clickLink(t('Configure')); @@ -67,12 +67,12 @@ public function testActionConfiguration() { $this->assertSession()->statusCodeEquals(200); // Make sure that the action updated properly. - $this->assertText('The action has been successfully saved.'); + $this->assertSession()->pageTextContains('The action has been successfully saved.'); // The old action label does NOT appear on the configuration page. $this->assertNoText($action_label); // The action label appears on the configuration page after we've updated // the complex action. - $this->assertText($new_action_label); + $this->assertSession()->pageTextContains($new_action_label); // Make sure the URL appears when re-editing the action. $this->clickLink(t('Configure')); diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php index dbcf8550023c..c9abff9111f3 100644 --- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php @@ -37,7 +37,7 @@ public function testAddFeed() { $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); // Verify that the feed label is present in the page title. - $this->assertText($feed->label()); + $this->assertSession()->pageTextContains($feed->label()); $this->assertRaw($feed->getWebsiteUrl()); // Try to add a duplicate. @@ -94,7 +94,7 @@ public function testAddLongFeed() { $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); // Verify that the feed label is present in the page title. - $this->assertText($feed->label()); + $this->assertSession()->pageTextContains($feed->label()); // Delete feeds. $this->deleteFeed($feed); diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php index bfb53e06d188..6620143e12ca 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php @@ -22,9 +22,9 @@ public function testSettingsPage() { $this->clickLink('Aggregator'); $this->clickLink('Settings'); // Make sure that test plugins are present. - $this->assertText('Test fetcher'); - $this->assertText('Test parser'); - $this->assertText('Test processor'); + $this->assertSession()->pageTextContains('Test fetcher'); + $this->assertSession()->pageTextContains('Test parser'); + $this->assertSession()->pageTextContains('Test processor'); // Set new values and enable test plugins. $edit = [ @@ -37,7 +37,7 @@ public function testSettingsPage() { 'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor', ]; $this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); // Check that settings have the correct default value. foreach ($edit as $name => $value) { @@ -45,13 +45,13 @@ public function testSettingsPage() { } // Check for our test processor settings form. - $this->assertText('Dummy length setting'); + $this->assertSession()->pageTextContains('Dummy length setting'); // Change its value to ensure that settingsSubmit is called. $edit = [ 'dummy_length' => 100, ]; $this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $this->assertSession()->fieldValueEquals('dummy_length', 100); // Make sure settings form is still accessible even after uninstalling a module diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php index b9f0fea7472f..ecf7e5e15be5 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php @@ -56,7 +56,7 @@ public function testBlockLinks() { // Confirm that the block is now being displayed on pages. $this->drupalGet('test-page'); - $this->assertText($block->label()); + $this->assertSession()->pageTextContains($block->label()); // Confirm items appear as links. $items = $this->container->get('entity_type.manager')->getStorage('aggregator_item')->loadByFeed($feed->id(), 1); diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php index eddaba4bdf71..34399c1c093a 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php @@ -75,7 +75,7 @@ protected function setUp() { public function createFeed($feed_url = NULL, array $edit = []) { $edit = $this->getFeedEditArray($feed_url, $edit); $this->drupalPostForm('aggregator/sources/add', $edit, 'Save'); - $this->assertText('The feed ' . Html::escape($edit['title[0][value]']) . ' has been added.'); + $this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.'); // Verify that the creation message contains a link to a feed. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]'); diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php index 5fab7be8dcf8..09adee064b1d 100644 --- a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php @@ -38,7 +38,7 @@ public function testDeleteFeed() { // Delete feed. $this->deleteFeed($feed1); - $this->assertText($feed2->label()); + $this->assertSession()->pageTextContains($feed2->label()); $block_storage = $this->container->get('entity_type.manager')->getStorage('block'); $this->assertNull($block_storage->load($block->id()), 'Block for the deleted feed was deleted.'); $this->assertEquals($block2->id(), $block_storage->load($block2->id())->id(), 'Block for not deleted feed still exists.'); diff --git a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php index 067aba2a2119..6cb4a774736e 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php @@ -26,8 +26,8 @@ public function testFeedUpdateFields() { // The scheduled feed shows that it has not been updated yet and is // scheduled. - $this->assertText('never'); - $this->assertText('imminently'); + $this->assertSession()->pageTextContains('never'); + $this->assertSession()->pageTextContains('imminently'); $this->assertNoText('ago'); $this->assertNoText('left'); @@ -38,8 +38,8 @@ public function testFeedUpdateFields() { // and next update. $this->assertNoText('never'); $this->assertNoText('imminently'); - $this->assertText('ago'); - $this->assertText('left'); + $this->assertSession()->pageTextContains('ago'); + $this->assertSession()->pageTextContains('left'); // Delete scheduled feed. $this->deleteFeed($scheduled_feed); @@ -49,7 +49,7 @@ public function testFeedUpdateFields() { $this->drupalGet('admin/config/services/aggregator'); // The non scheduled feed shows that it has not been updated yet. - $this->assertText('never'); + $this->assertSession()->pageTextContains('never'); $this->assertNoText('imminently'); $this->assertNoText('ago'); $this->assertNoText('left'); @@ -59,9 +59,9 @@ public function testFeedUpdateFields() { // After the feed update, we still need to see "never" as next update label. // Last update will show an interval. - $this->assertText('never'); + $this->assertSession()->pageTextContains('never'); $this->assertNoText('imminently'); - $this->assertText('ago'); + $this->assertSession()->pageTextContains('ago'); $this->assertNoText('left'); } diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php index 6056d1a4621b..bed280f583d9 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php @@ -38,18 +38,18 @@ public function testRSS091Sample() { $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); - $this->assertText('First example feed item title'); + $this->assertSession()->pageTextContains('First example feed item title'); $this->assertSession()->linkByHrefExists('http://example.com/example-turns-one'); - $this->assertText('First example feed item description.'); + $this->assertSession()->pageTextContains('First example feed item description.'); $this->assertRaw('<img src="http://example.com/images/druplicon.png"'); // Several additional items that include elements over 255 characters. $this->assertRaw("Second example feed item title."); - $this->assertText('Long link feed item title'); - $this->assertText('Long link feed item description'); + $this->assertSession()->pageTextContains('Long link feed item title'); + $this->assertSession()->pageTextContains('Long link feed item description'); $this->assertSession()->linkByHrefExists('http://example.com/tomorrow/and/tomorrow/and/tomorrow/creeps/in/this/petty/pace/from/day/to/day/to/the/last/syllable/of/recorded/time/and/all/our/yesterdays/have/lighted/fools/the/way/to/dusty/death/out/out/brief/candle/life/is/but/a/walking/shadow/a/poor/player/that/struts/and/frets/his/hour/upon/the/stage/and/is/heard/no/more/it/is/a/tale/told/by/an/idiot/full/of/sound/and/fury/signifying/nothing'); - $this->assertText('Long author feed item title'); - $this->assertText('Long author feed item description'); + $this->assertSession()->pageTextContains('Long author feed item title'); + $this->assertSession()->pageTextContains('Long author feed item description'); $this->assertSession()->linkByHrefExists('http://example.com/long/author'); } @@ -61,9 +61,9 @@ public function testAtomSample() { $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Atom-Powered Robots Run Amok'); + $this->assertSession()->pageTextContains('Atom-Powered Robots Run Amok'); $this->assertSession()->linkByHrefExists('http://example.org/2003/12/13/atom03'); - $this->assertText('Some text.'); + $this->assertSession()->pageTextContains('Some text.'); $item_ids = \Drupal::entityQuery('aggregator_item') ->accessCheck(FALSE) ->condition('link', 'http://example.org/2003/12/13/atom03') @@ -72,9 +72,9 @@ public function testAtomSample() { $this->assertEquals('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $item->getGuid(), 'Atom entry id element is parsed correctly.'); // Check for second feed entry. - $this->assertText('We tried to stop them, but we failed.'); + $this->assertSession()->pageTextContains('We tried to stop them, but we failed.'); $this->assertSession()->linkByHrefExists('http://example.org/2003/12/14/atom03'); - $this->assertText('Some other text.'); + $this->assertSession()->pageTextContains('Some other text.'); $item_ids = \Drupal::entityQuery('aggregator_item') ->accessCheck(FALSE) ->condition('link', 'http://example.org/2003/12/14/atom03') diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php index 8e13e498bd4f..abc6502474b6 100644 --- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php +++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php @@ -46,7 +46,7 @@ public function openImportForm() { $this->drupalPlaceBlock('help_block', ['region' => 'help']); $this->drupalGet('admin/config/services/aggregator/add/opml'); - $this->assertText('A single OPML document may contain many feeds.'); + $this->assertSession()->pageTextContains('A single OPML document may contain many feeds.'); // Ensure that the file upload, remote URL, and refresh fields exist. $this->assertSession()->fieldExists('files[upload]'); $this->assertSession()->fieldExists('remote'); @@ -75,7 +75,7 @@ public function validateImportFormFields() { // Error if the URL is invalid. $edit = ['remote' => 'invalidUrl://empty']; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import'); - $this->assertText('The URL invalidUrl://empty is not valid.'); + $this->assertSession()->pageTextContains('The URL invalidUrl://empty is not valid.'); $after = $count_query->execute(); $this->assertEquals($before, $after, 'No feeds were added during the three last form submissions.'); @@ -91,12 +91,12 @@ protected function submitImportForm() { // Attempting to upload invalid XML. $form['files[upload]'] = $this->getInvalidOpml(); $this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, 'Import'); - $this->assertText('No new feed has been added.'); + $this->assertSession()->pageTextContains('No new feed has been added.'); // Attempting to load empty OPML from remote URL $edit = ['remote' => file_create_url($this->getEmptyOpml())]; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import'); - $this->assertText('No new feed has been added.'); + $this->assertSession()->pageTextContains('No new feed has been added.'); $after = $count_query->execute(); $this->assertEquals($before, $after, 'No feeds were added during the two last form submissions.'); diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php index 1c43db482029..eb1931368c16 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php @@ -44,7 +44,7 @@ public function testUpdateFeedItem() { $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm('aggregator/sources/add', $edit, 'Save'); - $this->assertText('The feed ' . $edit['title[0][value]'] . ' has been added.'); + $this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.'); // Verify that the creation message contains a link to a feed. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]'); diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php index b7a412b8942a..c552d67ffeea 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php @@ -30,7 +30,7 @@ public function testUpdateFeed() { $edit[$same_field] = $feed->{$same_field}->value; } $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, 'Save'); - $this->assertText('The feed ' . $edit['title[0][value]'] . ' has been updated.'); + $this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been updated.'); // Verify that the creation message contains a link to a feed. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]'); @@ -42,7 +42,7 @@ public function testUpdateFeed() { // Check feed source, the title should be on the page. $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); - $this->assertText($edit['title[0][value]']); + $this->assertSession()->pageTextContains($edit['title[0][value]']); // Set correct title so deleteFeed() will work. $feed->title = $edit['title[0][value]']; diff --git a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php index fbc4ca70f6d6..9b26a88616ae 100644 --- a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php +++ b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php @@ -47,25 +47,25 @@ public function testIPAddressValidation() { $edit = []; $edit['ip'] = '1.2.3.3'; $this->drupalPostForm('admin/config/people/ban', $edit, 'Add'); - $this->assertText('This IP address is already banned.'); + $this->assertSession()->pageTextContains('This IP address is already banned.'); // Try to block a reserved IP address. $edit = []; $edit['ip'] = '255.255.255.255'; $this->drupalPostForm('admin/config/people/ban', $edit, 'Add'); - $this->assertText('Enter a valid IP address.'); + $this->assertSession()->pageTextContains('Enter a valid IP address.'); // Try to block a reserved IP address. $edit = []; $edit['ip'] = 'test.example.com'; $this->drupalPostForm('admin/config/people/ban', $edit, 'Add'); - $this->assertText('Enter a valid IP address.'); + $this->assertSession()->pageTextContains('Enter a valid IP address.'); // Submit an empty form. $edit = []; $edit['ip'] = ''; $this->drupalPostForm('admin/config/people/ban', $edit, 'Add'); - $this->assertText('Enter a valid IP address.'); + $this->assertSession()->pageTextContains('Enter a valid IP address.'); // Pass an IP address as a URL parameter and submit it. $submit_ip = '1.2.3.4'; @@ -80,7 +80,7 @@ public function testIPAddressValidation() { // $edit = array(); // $edit['ip'] = \Drupal::request()->getClientIP(); // $this->drupalPostForm('admin/config/people/ban', $edit, 'Save'); - // $this->assertText('You may not ban your own IP address.'); + // $this->assertSession()->pageTextContains('You may not ban your own IP address.'); // Test duplicate ip address are not present in the 'blocked_ips' table. // when they are entered programmatically. diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php index 1c1376d659cf..a4734aaf82d0 100644 --- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php +++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php @@ -48,7 +48,7 @@ public function testBasicAuth() { // Ensure we can log in with valid authentication details. $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); - $this->assertText($account->getAccountName()); + $this->assertSession()->pageTextContains($account->getAccountName()); $this->assertSession()->statusCodeEquals(200); $this->mink->resetSessions(); $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); @@ -164,7 +164,7 @@ public function testLocale() { $url = Url::fromRoute('router_test.11'); $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); - $this->assertText($account->getAccountName()); + $this->assertSession()->pageTextContains($account->getAccountName()); $this->assertSession()->statusCodeEquals(200); } @@ -180,26 +180,26 @@ public function testUnauthorizedErrorMessage() { $this->drupalGet($url); $this->assertSession()->statusCodeEquals(401); $this->assertNoText('Exception'); - $this->assertText('Please log in to access this page.'); + $this->assertSession()->pageTextContains('Please log in to access this page.'); // Case when empty credentials are passed, a user friendly access denied // message is displayed. $this->basicAuthGet($url, NULL, NULL); $this->assertSession()->statusCodeEquals(403); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); // Case when wrong credentials are passed, a user friendly access denied // message is displayed. $this->basicAuthGet($url, $account->getAccountName(), $this->randomMachineName()); $this->assertSession()->statusCodeEquals(403); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); // Case when correct credentials but hasn't access to the route, an user // friendly access denied message is displayed. $url = Url::fromRoute('router_test.15'); $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); $this->assertSession()->statusCodeEquals(403); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); } /** diff --git a/core/modules/block/tests/src/Functional/BlockCacheTest.php b/core/modules/block/tests/src/Functional/BlockCacheTest.php index c74f8b747444..8d01a18ae872 100644 --- a/core/modules/block/tests/src/Functional/BlockCacheTest.php +++ b/core/modules/block/tests/src/Functional/BlockCacheTest.php @@ -85,21 +85,21 @@ public function testCachePerRole() { \Drupal::state()->set('block_test.content', $current_content); $this->drupalLogin($this->normalUser); $this->drupalGet(''); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); // Change the content, but the cached copy should still be served. $old_content = $current_content; $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); // Clear the cache and verify that the stale data is no longer there. Cache::invalidateTags(['block_view']); $this->drupalGet(''); $this->assertNoText($old_content); // Fresh block content is displayed after clearing the cache. - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); // Test whether the cached data is served for the correct users. $old_content = $current_content; @@ -113,7 +113,7 @@ public function testCachePerRole() { // User with the same roles sees per-role cached content. $this->drupalLogin($this->normalUserAlt); $this->drupalGet(''); - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); // Admin user does not see content cached per-role for normal user. $this->drupalLogin($this->adminUser); @@ -123,7 +123,7 @@ public function testCachePerRole() { // Block is served from the per-role cache. $this->drupalLogin($this->normalUser); $this->drupalGet(''); - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); } /** @@ -138,7 +138,7 @@ public function testCachePermissions() { \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); @@ -146,12 +146,12 @@ public function testCachePermissions() { // Block content served from cache. $this->drupalGet('user'); - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); // Block content not served from cache. $this->drupalLogout(); $this->drupalGet('user'); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); } /** @@ -165,14 +165,14 @@ public function testNoCache() { // If max_age = 0 has no effect, the next request would be cached. $this->drupalGet(''); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); // A cached copy should not be served. $current_content = $this->randomMachineName(); \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet(''); // Maximum age of zero prevents blocks from being cached. - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); } /** @@ -186,7 +186,7 @@ public function testCachePerUser() { $this->drupalLogin($this->normalUser); $this->drupalGet(''); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); @@ -194,17 +194,17 @@ public function testCachePerUser() { // Block is served from per-user cache. $this->drupalGet(''); - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); // Per-user block cache is not served for other users. $this->drupalLogin($this->normalUserAlt); $this->drupalGet(''); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); // Per-user block cache is persistent. $this->drupalLogin($this->normalUser); $this->drupalGet(''); - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); } /** @@ -217,7 +217,7 @@ public function testCachePerPage() { \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet('test-page'); - $this->assertText($current_content); + $this->assertSession()->pageTextContains($current_content); $old_content = $current_content; $current_content = $this->randomMachineName(); @@ -231,7 +231,7 @@ public function testCachePerPage() { $this->drupalGet('test-page'); $this->assertSession()->statusCodeEquals(200); // Verify that the block content is cached for the test page. - $this->assertText($old_content); + $this->assertSession()->pageTextContains($old_content); } } diff --git a/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php b/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php index 4a270276f853..3983e752e179 100644 --- a/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php @@ -43,25 +43,25 @@ public function testCachePerPage() { // Go to "test-page" and test if the block is enabled. $this->drupalGet('test-page'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Your .com email address.'); + $this->assertSession()->pageTextContains('Your .com email address.'); // Make sure that we're currently still on /test-page after submitting the // form. $this->submitForm($form_values, 'Submit'); $this->assertSession()->addressEquals('test-page'); - $this->assertText('Your email address is test@example.com'); + $this->assertSession()->pageTextContains('Your email address is test@example.com'); // Go to a different page and see if the block is enabled there as well. $this->drupalGet('test-render-title'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Your .com email address.'); + $this->assertSession()->pageTextContains('Your .com email address.'); // Make sure that submitting the form didn't redirect us to the first page // we submitted the form from after submitting the form from // /test-render-title. $this->submitForm($form_values, 'Submit'); $this->assertSession()->addressEquals('test-render-title'); - $this->assertText('Your email address is test@example.com'); + $this->assertSession()->pageTextContains('Your email address is test@example.com'); } /** @@ -71,7 +71,7 @@ public function testPlaceholders() { $this->drupalGet('test-multiple-forms'); $placeholder = 'form_action_' . Crypt::hashBase64('Drupal\Core\Form\FormBuilder::prepareForm'); - $this->assertText('Form action: ' . $placeholder); + $this->assertSession()->pageTextContains('Form action: ' . $placeholder); } } diff --git a/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php b/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php index 575c2230f8e4..0f8bf1ee6682 100644 --- a/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php +++ b/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php @@ -52,7 +52,7 @@ public function testBlockNotInHiddenRegion() { // Ensure that the search form block is displayed. $this->drupalGet(''); - $this->assertText('Search'); + $this->assertSession()->pageTextContains('Search'); // Install "block_test_theme" and set it as the default theme. $theme = 'block_test_theme'; @@ -72,7 +72,7 @@ public function testBlockNotInHiddenRegion() { // Ensure that the search form block is displayed. $this->drupalGet(''); - $this->assertText('Search'); + $this->assertSession()->pageTextContains('Search'); } } diff --git a/core/modules/block/tests/src/Functional/BlockInstallTest.php b/core/modules/block/tests/src/Functional/BlockInstallTest.php index 4e7cc57b22bd..ad79cb59fdbc 100644 --- a/core/modules/block/tests/src/Functional/BlockInstallTest.php +++ b/core/modules/block/tests/src/Functional/BlockInstallTest.php @@ -31,7 +31,7 @@ public function testCacheTagInvalidationUponInstallation() { // invalidated the 'rendered' cache tag to make blocks show up. $this->drupalGet(''); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:block_list'); - $this->assertText('Powered by Drupal'); + $this->assertSession()->pageTextContains('Powered by Drupal'); } } diff --git a/core/modules/block/tests/src/Functional/BlockLanguageCacheTest.php b/core/modules/block/tests/src/Functional/BlockLanguageCacheTest.php index 6ab28c643d01..de83b2bc1ebf 100644 --- a/core/modules/block/tests/src/Functional/BlockLanguageCacheTest.php +++ b/core/modules/block/tests/src/Functional/BlockLanguageCacheTest.php @@ -68,13 +68,13 @@ public function testBlockLinks() { $edit['label'] = $this->randomMachineName(); $edit['id'] = mb_strtolower($edit['label']); $this->drupalPostForm('admin/structure/menu/add', $edit, 'Save'); - $this->assertText('Menu ' . $edit['label'] . ' has been added.'); + $this->assertSession()->pageTextContains('Menu ' . $edit['label'] . ' has been added.'); // Check that the block is listed for all languages. foreach ($this->langcodes as $langcode) { $this->drupalGet('admin/structure/block', ['language' => $langcode]); $this->clickLink('Place block'); - $this->assertText($edit['label']); + $this->assertSession()->pageTextContains($edit['label']); } } diff --git a/core/modules/block/tests/src/Functional/BlockLanguageTest.php b/core/modules/block/tests/src/Functional/BlockLanguageTest.php index 6c5b6b463bbd..5e431f4d4324 100644 --- a/core/modules/block/tests/src/Functional/BlockLanguageTest.php +++ b/core/modules/block/tests/src/Functional/BlockLanguageTest.php @@ -46,7 +46,7 @@ protected function setUp(): void { $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language'); // Verify that language was added successfully. - $this->assertText('French'); + $this->assertSession()->pageTextContains('French'); } /** @@ -77,7 +77,7 @@ public function testLanguageBlockVisibility() { // Check that a page has a block. $this->drupalGet('en'); - $this->assertText('Powered by Drupal'); + $this->assertSession()->pageTextContains('Powered by Drupal'); // Check that a page doesn't has a block for the current language anymore. $this->drupalGet('fr'); @@ -158,7 +158,7 @@ public function testMultipleLanguageTypes() { $this->drupalGet('node', ['query' => ['language' => 'en']]); $this->assertNoText('Powered by Drupal'); $this->drupalGet('node', ['query' => ['language' => 'fr']]); - $this->assertText('Powered by Drupal'); + $this->assertSession()->pageTextContains('Powered by Drupal'); // Log in again in order to clear the interface language stored in the // session. @@ -189,7 +189,7 @@ public function testMultipleLanguageTypes() { $this->drupalGet('en'); $this->assertNoText('Powered by Drupal'); $this->drupalGet('fr'); - $this->assertText('Powered by Drupal'); + $this->assertSession()->pageTextContains('Powered by Drupal'); } } diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php index db234236867f..91e1a7f76010 100644 --- a/core/modules/block/tests/src/Functional/BlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockTest.php @@ -44,14 +44,14 @@ public function testBlockVisibility() { $this->assertSession()->checkboxChecked('edit-visibility-request-path-negate-0'); $this->submitForm($edit, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); $this->clickLink('Configure'); $this->assertSession()->checkboxChecked('edit-visibility-request-path-negate-1'); // Confirm that the block is displayed on the front page. $this->drupalGet(''); - $this->assertText($title); + $this->assertSession()->pageTextContains($title); // Confirm that the block is not displayed according to block visibility // rules. @@ -122,7 +122,7 @@ public function testBlockVisibilityListedEmpty() { // Set the block to be hidden on any user path, and to be shown only to // authenticated users. $this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); // Confirm that block was not displayed according to block visibility // rules. @@ -206,7 +206,7 @@ public function testBlock() { // Set block title to confirm that interface works and override any custom titles. $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], ['settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']], 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); // Check to see if the block was created by checking its configuration. $instance = Block::load($block['id']); @@ -222,7 +222,7 @@ public function testBlock() { $this->clickLink('Disable'); // Confirm that the block is now listed as disabled. - $this->assertText('The block settings have been updated.'); + $this->assertSession()->pageTextContains('The block settings have been updated.'); // Confirm that the block instance title and markup are not displayed. $this->drupalGet('node'); @@ -266,7 +266,7 @@ public function testBlockThemeSelector() { $block['theme'] = $theme; $block['region'] = 'content'; $this->drupalPostForm('admin/structure/block/add/system_powered_by_block', $block, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); $this->assertSession()->addressEquals('admin/structure/block/list/' . $theme . '?block-placement=' . Html::getClass($block['id'])); // Set the default theme and ensure the block is placed. @@ -309,7 +309,7 @@ public function testHideBlockTitle() { 'settings[label]' => $title, ]; $this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); // Confirm that the block is not displayed by default. $this->drupalGet('user'); @@ -319,14 +319,14 @@ public function testHideBlockTitle() { 'settings[label_display]' => TRUE, ]; $this->drupalPostForm('admin/structure/block/manage/' . $id, $edit, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); $this->drupalGet('admin/structure/block/manage/' . $id); $this->assertSession()->checkboxChecked('edit-settings-label-display'); // Confirm that the block is displayed when enabled. $this->drupalGet('user'); - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } /** @@ -349,11 +349,11 @@ public function moveBlockToRegion(array $block, $region) { $this->drupalPostForm('admin/structure/block', $edit, 'Save blocks'); // Confirm that the block was moved to the proper region. - $this->assertText('The block settings have been updated.'); + $this->assertSession()->pageTextContains('The block settings have been updated.'); // Confirm that the block is being displayed. $this->drupalGet(''); - $this->assertText($block['settings[label]']); + $this->assertSession()->pageTextContains($block['settings[label]']); // Confirm that the custom block was found at the proper region. $xpath = $this->assertSession()->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', [ @@ -488,7 +488,7 @@ public function testThemeAdminLink() { ]); $this->drupalLogin($theme_admin); $this->drupalGet('admin/appearance'); - $this->assertText('You can place blocks for each theme on the block layout page'); + $this->assertSession()->pageTextContains('You can place blocks for each theme on the block layout page'); $this->assertSession()->linkByHrefExists('admin/structure/block'); } @@ -503,7 +503,7 @@ public function testUninstallTheme() { $this->config('system.theme')->set('default', 'seven')->save(); $block = $this->drupalPlaceBlock('system_powered_by_block', ['theme' => 'seven', 'region' => 'help']); $this->drupalGet('<front>'); - $this->assertText('Powered by Drupal'); + $this->assertSession()->pageTextContains('Powered by Drupal'); $this->config('system.theme')->set('default', 'classy')->save(); $theme_installer->uninstall(['seven']); @@ -523,7 +523,7 @@ public function testBlockAccess() { \Drupal::state()->set('test_block_access', TRUE); $this->drupalGet('<front>'); - $this->assertText('Hello test world'); + $this->assertSession()->pageTextContains('Hello test world'); } /** diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php index 35fc244ec09c..30c961ef6e04 100644 --- a/core/modules/block/tests/src/Functional/BlockUiTest.php +++ b/core/modules/block/tests/src/Functional/BlockUiTest.php @@ -239,8 +239,8 @@ public function testContextAwareBlocks() { $this->drupalPostForm($block_url, $edit, 'Save block'); $this->drupalGet(''); - $this->assertText('Test context-aware block'); - $this->assertText('User context found.'); + $this->assertSession()->pageTextContains('Test context-aware block'); + $this->assertSession()->pageTextContains('User context found.'); $this->assertRaw($expected_text); // Test context mapping form element is not visible if there are no valid @@ -257,7 +257,7 @@ public function testContextAwareBlocks() { ]; $this->submitForm($edit, 'Save block'); $this->drupalGet(''); - $this->assertText('No context mapping selected.'); + $this->assertSession()->pageTextContains('No context mapping selected.'); $this->assertNoText('User context found.'); // Tests that conditions with missing context are not displayed. @@ -277,13 +277,13 @@ public function testMachineNameSuggestion() { $this->assertSession()->fieldValueEquals('id', 'displaymessage'); $edit = ['region' => 'content']; $this->drupalPostForm($url, $edit, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); // Now, check to make sure the form starts by autoincrementing correctly. $this->drupalGet($url); $this->assertSession()->fieldValueEquals('id', 'displaymessage_2'); $this->drupalPostForm($url, $edit, 'Save block'); - $this->assertText('The block configuration has been saved.'); + $this->assertSession()->pageTextContains('The block configuration has been saved.'); // And verify that it continues working beyond just the first two. $this->drupalGet($url); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php index ef788b76d055..4cb059664560 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php @@ -248,11 +248,11 @@ public function testBlockDelete() { // Navigate to home page. $this->drupalGet(''); - $this->assertText($body); + $this->assertSession()->pageTextContains($body); // Delete the block. $this->drupalGet('block/1/delete'); - $this->assertText('This will also remove 1 placed block instance.'); + $this->assertSession()->pageTextContains('This will also remove 1 placed block instance.'); $this->submitForm([], 'Delete'); $this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']])); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentListTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php index a1a8d491f0ff..4f1f469b729d 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentListTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php @@ -107,7 +107,7 @@ public function testListing() { $this->assertSession()->elementTextNotContains('xpath', '//td', $new_label); // Confirm that the empty text is displayed. - $this->assertText('There are no custom blocks yet.'); + $this->assertSession()->pageTextContains('There are no custom blocks yet.'); $block_content = BlockContent::create([ 'info' => 'Non-reusable block', diff --git a/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php index 3f9827da24cf..64b87f57210c 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php @@ -116,7 +116,7 @@ public function testListing() { $this->assertSession()->elementTextNotContains('xpath', '//td', $new_label); // Confirm that the empty text is displayed. - $this->assertText('There are no custom blocks available.'); + $this->assertSession()->pageTextContains('There are no custom blocks available.'); $this->assertSession()->linkExists('custom block'); $block_content = BlockContent::create([ diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index b3ca5eefdaf4..e01e4951e9da 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -71,7 +71,7 @@ public function testBlockContentTypeCreation() { // Test the page with no block-types. $this->drupalGet('block/add'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('You have not created any block types yet'); + $this->assertSession()->pageTextContains('You have not created any block types yet'); $this->clickLink('block type creation page'); // Create a block type via the user interface. @@ -185,7 +185,7 @@ public function testBlockContentTypeDeletion() { $this->assertRaw( t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()]) ); - $this->assertText('This action cannot be undone.'); + $this->assertSession()->pageTextContains('This action cannot be undone.'); } /** diff --git a/core/modules/block_content/tests/src/Functional/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php index 223f3891cfc0..7bc1cde09289 100644 --- a/core/modules/block_content/tests/src/Functional/PageEditTest.php +++ b/core/modules/block_content/tests/src/Functional/PageEditTest.php @@ -72,7 +72,7 @@ public function testPageEdit() { // Test deleting the block. $this->drupalGet("block/" . $revised_block->id()); $this->clickLink(t('Delete')); - $this->assertText('Are you sure you want to delete the custom block ' . $revised_block->label() . '?'); + $this->assertSession()->pageTextContains('Are you sure you want to delete the custom block ' . $revised_block->label() . '?'); } } diff --git a/core/modules/block_content/tests/src/Functional/Views/BlockContentRedirectTest.php b/core/modules/block_content/tests/src/Functional/Views/BlockContentRedirectTest.php index 28ca089435ae..e33405a5086a 100644 --- a/core/modules/block_content/tests/src/Functional/Views/BlockContentRedirectTest.php +++ b/core/modules/block_content/tests/src/Functional/Views/BlockContentRedirectTest.php @@ -44,7 +44,7 @@ public function testRedirectDestination() { // Check the block content is present in the view redirect destination. $this->drupalGet('admin/content/redirect_destination'); - $this->assertText('Test redirect destination'); + $this->assertSession()->pageTextContains('Test redirect destination'); // Edit the created block and save. $this->clickLink('Edit'); diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 7e465bad0413..f2a7a7a07086 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -161,7 +161,7 @@ public function testEmptyBook() { // Log in as a user with access to the book outline and save the form. $this->drupalLogin($this->adminUser); $this->drupalPostForm('admin/structure/book/' . $book->id(), [], 'Save book pages'); - $this->assertText('Updated book ' . $book->label() . '.'); + $this->assertSession()->pageTextContains('Updated book ' . $book->label() . '.'); } /** @@ -253,7 +253,7 @@ public function testBookExport() { // Make sure each part of the book is there. foreach ($nodes as $node) { - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); $this->assertRaw($node->body->processed); } @@ -297,15 +297,15 @@ public function testBookNavigationBlock() { $edit = []; $edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE; $this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, 'Save permissions'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Test correct display of the block. $nodes = $this->createBook(); $this->drupalGet('<front>'); // Book navigation block. - $this->assertText($block->label()); + $this->assertSession()->pageTextContains($block->label()); // Link to book root. - $this->assertText($this->book->label()); + $this->assertSession()->pageTextContains($this->book->label()); // No links to individual book pages. $this->assertNoText($nodes[0]->label()); @@ -398,7 +398,7 @@ public function testNavigationBlockOnAccessModuleInstalled() { $edit = []; $edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE; $this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, 'Save permissions'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Create a book. $this->createBook(); @@ -406,12 +406,12 @@ public function testNavigationBlockOnAccessModuleInstalled() { // Test correct display of the block to registered users. $this->drupalLogin($this->webUser); $this->drupalGet('node/' . $this->book->id()); - $this->assertText($block->label()); + $this->assertSession()->pageTextContains($block->label()); $this->drupalLogout(); // Test correct display of the block to anonymous users. $this->drupalGet('node/' . $this->book->id()); - $this->assertText($block->label()); + $this->assertSession()->pageTextContains($block->label()); // Test the 'book pages' block_mode setting. $this->drupalGet('<front>'); @@ -458,7 +458,7 @@ public function testBookDelete() { $this->drupalPostForm($this->book->toUrl('delete-form'), [], 'Delete'); $this->drupalGet($nodes[0]->toUrl()); $this->assertSession()->statusCodeEquals(200); - $this->assertText($nodes[0]->label()); + $this->assertSession()->pageTextContains($nodes[0]->label()); // The book parents should be updated. $node_storage = \Drupal::entityTypeManager()->getStorage('node'); $node_storage->resetCache(); @@ -559,7 +559,7 @@ public function testBookListing() { // Load the book page and assert the created book title is displayed. $this->drupalGet('book'); - $this->assertText($this->book->label()); + $this->assertSession()->pageTextContains($this->book->label()); // Unpublish the top book page and confirm that the created book title is // not displayed for anonymous. @@ -610,7 +610,7 @@ public function testAdminBookListing() { // Load the book page and assert the created book title is displayed. $this->drupalLogin($this->adminUser); $this->drupalGet('admin/structure/book'); - $this->assertText($this->book->label()); + $this->assertSession()->pageTextContains($this->book->label()); } /** @@ -624,7 +624,7 @@ public function testAdminBookNodeListing() { // Load the book page list and assert the created book title is displayed // and action links are shown on list items. $this->drupalGet('admin/structure/book/' . $this->book->id()); - $this->assertText($this->book->label()); + $this->assertSession()->pageTextContains($this->book->label()); $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a'); $this->assertEquals('View', $elements[0]->getText(), 'View link is found from the list.'); @@ -712,7 +712,7 @@ public function testBookNavigationBlockOnUnpublishedBook() { $this->drupalGet('node/' . $this->book->id()); // Unpublished book with "Show block only on book pages" book navigation // settings. - $this->assertText($this->book->label()); + $this->assertSession()->pageTextContains($this->book->label()); } /** diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php index 3f005b54685e..9447c94040ac 100644 --- a/core/modules/book/tests/src/Functional/BookTestTrait.php +++ b/core/modules/book/tests/src/Functional/BookTestTrait.php @@ -141,7 +141,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne // Check printer friendly version. $this->drupalGet('book/export/html/' . $node->id()); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); $this->assertRaw($node->body->processed); $number++; diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php index cb0a41b29cc6..c9702c3ae200 100644 --- a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php +++ b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php @@ -227,7 +227,7 @@ public function testExistingFormat() { $this->submitForm($edit, 'editor_configure'); $this->submitForm($edit, 'Save configuration'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); } /** diff --git a/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php b/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php index 6fab6afcfa23..e7ae43df048f 100644 --- a/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php +++ b/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php @@ -53,7 +53,7 @@ public function testColorPreview() { // core/modules/color/tests/modules/color_test/themes/color_test_theme/color/preview.html $url = Url::fromRoute('system.theme_settings_theme', ['theme' => 'color_test_theme']); $this->drupalGet($url); - $this->assertText('TEST COLOR PREVIEW'); + $this->assertSession()->pageTextContains('TEST COLOR PREVIEW'); $this->assertNoRaw('<script>alert("security filter test");</script>'); $this->assertRaw('<h2>TEST COLOR PREVIEW</h2>'); diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php index 57ce27c4235e..83983a0e196d 100644 --- a/core/modules/color/tests/src/Functional/ColorTest.php +++ b/core/modules/color/tests/src/Functional/ColorTest.php @@ -171,10 +171,10 @@ public function testValidColor() { $this->drupalPostForm($settings_path, $edit, 'Save configuration'); if ($is_valid) { - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); } else { - $this->assertText('You must enter a valid hexadecimal color value for Main background.'); + $this->assertSession()->pageTextContains('You must enter a valid hexadecimal color value for Main background.'); } } } diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index 18748255309c..efef5f8de3aa 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -42,7 +42,7 @@ public function testApprovalAdminInterface() { // Test that the comments page loads correctly when there are no comments $this->drupalGet('admin/content/comment'); - $this->assertText('No comments available.'); + $this->assertSession()->pageTextContains('No comments available.'); $this->drupalLogout(); @@ -51,7 +51,7 @@ public function testApprovalAdminInterface() { $body = $this->randomMachineName(); // Set $contact to true so that it won't check for id and message. $this->postComment($this->node, $body, $subject, TRUE); - $this->assertText('Your comment has been queued for review by site administrators and will be published after approval.'); + $this->assertSession()->pageTextContains('Your comment has been queued for review by site administrators and will be published after approval.'); // Get unapproved comment id. $this->drupalLogin($this->adminUser); @@ -83,13 +83,13 @@ public function testApprovalAdminInterface() { // Publish multiple comments in one operation. $this->drupalLogin($this->adminUser); $this->drupalGet('admin/content/comment/approval'); - $this->assertText('Unapproved comments (2)'); + $this->assertSession()->pageTextContains('Unapproved comments (2)'); $edit = [ "comments[{$comments[0]->id()}]" => 1, "comments[{$comments[1]->id()}]" => 1, ]; $this->submitForm($edit, 'Update'); - $this->assertText('Unapproved comments (0)'); + $this->assertSession()->pageTextContains('Unapproved comments (0)'); // Delete multiple comments in one operation. $edit = [ @@ -99,21 +99,21 @@ public function testApprovalAdminInterface() { "comments[{$anonymous_comment4->id()}]" => 1, ]; $this->submitForm($edit, 'Update'); - $this->assertText('Are you sure you want to delete these comments and all their children?'); + $this->assertSession()->pageTextContains('Are you sure you want to delete these comments and all their children?'); $this->submitForm([], 'Delete'); - $this->assertText('No comments available.'); + $this->assertSession()->pageTextContains('No comments available.'); // Test message when no comments selected. $edit = [ 'operation' => 'delete', ]; $this->submitForm($edit, 'Update'); - $this->assertText('Select one or more comments to perform the update on.'); + $this->assertSession()->pageTextContains('Select one or more comments to perform the update on.'); // Make sure the label of unpublished node is not visible on listing page. $this->drupalGet('admin/content/comment'); $this->postComment($this->node, $this->randomMachineName()); $this->drupalGet('admin/content/comment'); - $this->assertText(Html::escape($this->node->label())); + $this->assertSession()->pageTextContains(Html::escape($this->node->label())); $this->node->setUnpublished()->save(); $this->drupalGet('admin/content/comment'); $this->assertNoText(Html::escape($this->node->label())); @@ -139,7 +139,7 @@ public function testApprovalNodeInterface() { $body = $this->randomMachineName(); // Set $contact to true so that it won't check for id and message. $this->postComment($this->node, $body, $subject, TRUE); - $this->assertText('Your comment has been queued for review by site administrators and will be published after approval.'); + $this->assertSession()->pageTextContains('Your comment has been queued for review by site administrators and will be published after approval.'); // Get unapproved comment id. $this->drupalLogin($this->adminUser); @@ -184,15 +184,15 @@ public function testCommentAdmin() { $this->drupalGet('admin/structure/comment'); $this->assertSession()->statusCodeEquals(200); // Make sure titles visible. - $this->assertText('Comment type'); - $this->assertText('Description'); + $this->assertSession()->pageTextContains('Comment type'); + $this->assertSession()->pageTextContains('Description'); // Make sure the description is present. - $this->assertText('Default comment field'); + $this->assertSession()->pageTextContains('Default comment field'); // Manage fields. $this->clickLink('Manage fields'); $this->assertSession()->statusCodeEquals(200); // Make sure comment_body field is shown. - $this->assertText('comment_body'); + $this->assertSession()->pageTextContains('comment_body'); // Rest from here on in is field_ui. } @@ -280,8 +280,8 @@ public function testCommentedTranslationDeletion() { $this->drupalPostForm('admin/content/comment', $edit, 'Update'); $this->assertRaw(new FormattableMarkup('@label (Original translation) - <em>The following comment translations will be deleted:</em>', ['@label' => $comment1->label()])); $this->assertRaw(new FormattableMarkup('@label (Original translation) - <em>The following comment translations will be deleted:</em>', ['@label' => $comment2->label()])); - $this->assertText('English'); - $this->assertText('Urdu'); + $this->assertSession()->pageTextContains('English'); + $this->assertSession()->pageTextContains('Urdu'); $this->submitForm([], 'Delete'); $after_count = $count_query->execute(); $this->assertEquals($before_count, $after_count, 'No comment or translation found.'); diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php index 129c0c89f2d9..5d5a2f2d32d5 100644 --- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php @@ -125,7 +125,7 @@ public function testAnonymous() { $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); // Name should have 'Anonymous' for value by default. - $this->assertText('Email field is required.'); + $this->assertSession()->pageTextContains('Email field is required.'); $this->assertFalse($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) not found.'); // Post comment with contact info (required). diff --git a/core/modules/comment/tests/src/Functional/CommentBlockTest.php b/core/modules/comment/tests/src/Functional/CommentBlockTest.php index 4b6666de36ee..29ebe8f9c87b 100644 --- a/core/modules/comment/tests/src/Functional/CommentBlockTest.php +++ b/core/modules/comment/tests/src/Functional/CommentBlockTest.php @@ -67,12 +67,12 @@ public function testRecentCommentBlock() { // block. $this->drupalLogin($this->webUser); $this->drupalGet(''); - $this->assertText('Recent comments'); + $this->assertSession()->pageTextContains('Recent comments'); // Test the only the 10 latest comments are shown and in the proper order. $this->assertNoText($comments[10]->getSubject()); for ($i = 0; $i < 10; $i++) { - $this->assertText($comments[$i]->getSubject()); + $this->assertSession()->pageTextContains($comments[$i]->getSubject()); if ($i > 1) { $previous_position = $position; $position = strpos($this->getSession()->getPage()->getContent(), $comments[$i]->getSubject()); @@ -86,7 +86,7 @@ public function testRecentCommentBlock() { for ($i = 0; $i < 10; $i++) { $this->clickLink($comments[$i]->getSubject()); - $this->assertText($comments[$i]->getSubject()); + $this->assertSession()->pageTextContains($comments[$i]->getSubject()); $this->assertRaw('<link rel="canonical"'); } } diff --git a/core/modules/comment/tests/src/Functional/CommentBookTest.php b/core/modules/comment/tests/src/Functional/CommentBookTest.php index 181194f982f4..b9be39d688e1 100644 --- a/core/modules/comment/tests/src/Functional/CommentBookTest.php +++ b/core/modules/comment/tests/src/Functional/CommentBookTest.php @@ -69,17 +69,17 @@ public function testBookCommentPrint() { $this->drupalGet('node/' . $book_node->id()); - $this->assertText($comment_subject); - $this->assertText($comment_body); - $this->assertText('Add new comment'); + $this->assertSession()->pageTextContains($comment_subject); + $this->assertSession()->pageTextContains($comment_body); + $this->assertSession()->pageTextContains('Add new comment'); // Ensure that the comment form subject field exists. $this->assertSession()->fieldExists('subject[0][value]'); $this->drupalGet('book/export/html/' . $book_node->id()); - $this->assertText('Comments'); - $this->assertText($comment_subject); - $this->assertText($comment_body); + $this->assertSession()->pageTextContains('Comments'); + $this->assertSession()->pageTextContains($comment_subject); + $this->assertSession()->pageTextContains($comment_body); $this->assertNoText('Add new comment'); // Verify that the comment form subject field is not found. diff --git a/core/modules/comment/tests/src/Functional/CommentCacheTagsTest.php b/core/modules/comment/tests/src/Functional/CommentCacheTagsTest.php index 5277a317c089..d5de08db411e 100644 --- a/core/modules/comment/tests/src/Functional/CommentCacheTagsTest.php +++ b/core/modules/comment/tests/src/Functional/CommentCacheTagsTest.php @@ -128,7 +128,7 @@ public function testCommentEntity() { // Ensure that a new comment only invalidates the commented entity. $this->verifyPageCache($this->entityTestCamelid->toUrl(), 'HIT'); $this->verifyPageCache($this->entityTestHippopotamidae->toUrl(), 'MISS'); - $this->assertText($hippo_comment->getSubject()); + $this->assertSession()->pageTextContains($hippo_comment->getSubject()); // Ensure that updating an existing comment only invalidates the commented // entity. diff --git a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php index 1f6ecb687cf1..511138a6b30c 100644 --- a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php +++ b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php @@ -163,7 +163,7 @@ public function testCommentFieldCreate() { $edit = []; $this->drupalPostForm('admin/config/people/accounts/fields/user.user.field_user_comment/storage', $edit, 'Save field settings'); // We should get an error message. - $this->assertText('An illegal choice has been detected. Please contact the site administrator.'); + $this->assertSession()->pageTextContains('An illegal choice has been detected. Please contact the site administrator.'); // Create a comment type for users. $bundle = CommentType::create([ diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php index 0f26a70e5656..1ecf188ea747 100644 --- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php @@ -85,8 +85,8 @@ public function testCommentInterface() { // Check comment display. $this->drupalLogin($this->webUser); $this->drupalGet('node/' . $this->node->id()); - $this->assertText($subject_text); - $this->assertText($comment_text); + $this->assertSession()->pageTextContains($subject_text); + $this->assertSession()->pageTextContains($comment_text); $arguments = [ ':link' => base_path() . 'comment/' . $comment->id() . '#comment-' . $comment->id(), ]; @@ -132,8 +132,8 @@ public function testCommentInterface() { // Verify we were correctly redirected. $this->assertSession()->addressEquals(Url::fromRoute('comment.reply', ['entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'])); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id()); - $this->assertText($subject_text); - $this->assertText($comment_text); + $this->assertSession()->pageTextContains($subject_text); + $this->assertSession()->pageTextContains($comment_text); $reply = $this->postComment(NULL, $this->randomMachineName(), '', TRUE); $reply_loaded = Comment::load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.'); @@ -143,8 +143,8 @@ public function testCommentInterface() { // Second reply to comment #2 creating comment #4. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id()); - $this->assertText($comment->getSubject()); - $this->assertText($comment->comment_body->value); + $this->assertSession()->pageTextContains($comment->getSubject()); + $this->assertSession()->pageTextContains($comment->comment_body->value); $reply = $this->postComment(NULL, $this->randomMachineName(), $this->randomMachineName(), TRUE); $reply_loaded = Comment::load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.'); @@ -153,8 +153,8 @@ public function testCommentInterface() { // Reply to comment #4 creating comment #5. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $reply_loaded->id()); - $this->assertText($reply_loaded->getSubject()); - $this->assertText($reply_loaded->comment_body->value); + $this->assertSession()->pageTextContains($reply_loaded->getSubject()); + $this->assertSession()->pageTextContains($reply_loaded->comment_body->value); $reply = $this->postComment(NULL, $this->randomMachineName(), $this->randomMachineName(), TRUE); $reply_loaded = Comment::load($reply->id()); $this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.'); diff --git a/core/modules/comment/tests/src/Functional/CommentLinksTest.php b/core/modules/comment/tests/src/Functional/CommentLinksTest.php index 42a284438c54..5af24fe2115f 100644 --- a/core/modules/comment/tests/src/Functional/CommentLinksTest.php +++ b/core/modules/comment/tests/src/Functional/CommentLinksTest.php @@ -138,7 +138,7 @@ public function testCommentLinks() { // Visit the full node, make sure there are links for the comment. $this->drupalGet('node/' . $this->node->id()); - $this->assertText($comment->getSubject()); + $this->assertSession()->pageTextContains($comment->getSubject()); $this->assertSession()->linkExists('Reply'); // Make sure we can hide comment links. @@ -146,7 +146,7 @@ public function testCommentLinks() { ->removeComponent('links') ->save(); $this->drupalGet('node/' . $this->node->id()); - $this->assertText($comment->getSubject()); + $this->assertSession()->pageTextContains($comment->getSubject()); $this->assertSession()->linkNotExists('Reply'); } diff --git a/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php b/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php index 15d0cb66574e..7bf62d59c390 100644 --- a/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNodeAccessTest.php @@ -66,8 +66,8 @@ public function testThreadedCommentView() { // Check comment display. $this->drupalGet('node/' . $this->node->id()); - $this->assertText($comment_subject); - $this->assertText($comment_text); + $this->assertSession()->pageTextContains($comment_subject); + $this->assertSession()->pageTextContains($comment_text); // Reply to comment, creating second comment. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id()); @@ -78,10 +78,10 @@ public function testThreadedCommentView() { // Go to the node page and verify comment and reply are visible. $this->drupalGet('node/' . $this->node->id()); - $this->assertText($comment_text); - $this->assertText($comment_subject); - $this->assertText($reply_text); - $this->assertText($reply_subject); + $this->assertSession()->pageTextContains($comment_text); + $this->assertSession()->pageTextContains($comment_subject); + $this->assertSession()->pageTextContains($reply_text); + $this->assertSession()->pageTextContains($reply_subject); } } diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index 82a6ac16f6f7..d3584e46a1b5 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -172,9 +172,9 @@ public function postComment(EntityInterface $entity, $comment, $subject = '', $c if ($contact !== TRUE) { // If true then attempting to find error message. if ($subject) { - $this->assertText($subject); + $this->assertSession()->pageTextContains($subject); } - $this->assertText($comment); + $this->assertSession()->pageTextContains($comment); // Check the comment ID was extracted. $this->assertArrayHasKey(1, $match); } @@ -241,7 +241,7 @@ public function performCommentOperation($comment, $operation, $approval = FALSE) $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.')); } else { - $this->assertText('The update has been performed.'); + $this->assertSession()->pageTextContains('The update has been performed.'); } } @@ -271,7 +271,7 @@ public function testCommentFunctionality() { $this->drupalLogin($limited_user); // Test that default field exists. $this->drupalGet('entity_test/structure/entity_test/fields'); - $this->assertText('Comments'); + $this->assertSession()->pageTextContains('Comments'); $this->assertSession()->linkByHrefExists('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); // Test widget hidden option is not visible when there's no comments. $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); @@ -334,7 +334,7 @@ public function testCommentFunctionality() { $this->assertRaw('comments[' . $comment1->id() . ']'); // Check that entity access applies to administrative page. - $this->assertText($this->entity->label()); + $this->assertSession()->pageTextContains($this->entity->label()); $limited_user = $this->drupalCreateUser([ 'administer comments', ]); diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php index 6f1834c62167..51e6ab1d8133 100644 --- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php @@ -345,11 +345,11 @@ public function testTwoPagers() { $this->drupalGet('admin/structure/types/manage/article/display'); // No summary for standard pager. $this->assertNoText('Pager ID: 0'); - $this->assertText('Pager ID: 1'); + $this->assertSession()->pageTextContains('Pager ID: 1'); $this->submitForm([], 'comment_settings_edit'); // Change default pager to 2. $this->submitForm(['fields[comment][settings_edit_form][settings][pager_id]' => 2], 'Save'); - $this->assertText('Pager ID: 2'); + $this->assertSession()->pageTextContains('Pager ID: 2'); // Revert the changes. $this->submitForm([], 'comment_settings_edit'); $this->submitForm(['fields[comment][settings_edit_form][settings][pager_id]' => 0], 'Save'); diff --git a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php index b11d8ff15722..999781f83f03 100644 --- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -68,8 +68,8 @@ public function testCommentPreview() { // Check that the preview is displaying the title and body. $this->assertSession()->titleEquals('Preview comment | Drupal'); - $this->assertText($edit['subject[0][value]']); - $this->assertText($edit['comment_body[0][value]']); + $this->assertSession()->pageTextContains($edit['subject[0][value]']); + $this->assertSession()->pageTextContains($edit['comment_body[0][value]']); // Check that the title and body fields are displayed with the correct values. $this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']); @@ -102,8 +102,8 @@ public function testCommentPreviewDuplicateSubmission() { // Check that the preview is displaying the title and body. $this->assertSession()->titleEquals('Preview comment | Drupal'); - $this->assertText($edit['subject[0][value]']); - $this->assertText($edit['comment_body[0][value]']); + $this->assertSession()->pageTextContains($edit['subject[0][value]']); + $this->assertSession()->pageTextContains($edit['comment_body[0][value]']); // Check that the title and body fields are displayed with the correct values. $this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']); @@ -111,7 +111,7 @@ public function testCommentPreviewDuplicateSubmission() { // Store the content of this page. $this->submitForm([], 'Save'); - $this->assertText('Your comment has been posted.'); + $this->assertSession()->pageTextContains('Your comment has been posted.'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $this->assertCount(1, $elements); @@ -119,7 +119,7 @@ public function testCommentPreviewDuplicateSubmission() { $this->getSession()->getDriver()->back(); $submit_button = $this->assertSession()->buttonExists('Save'); $submit_button->click(); - $this->assertText('Your comment has been posted.'); + $this->assertSession()->pageTextContains('Your comment has been posted.'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $this->assertCount(2, $elements); } @@ -156,10 +156,10 @@ public function testCommentEditPreviewSave() { // Check that the preview is displaying the subject, comment, author and date correctly. $this->assertSession()->titleEquals('Preview comment | Drupal'); - $this->assertText($edit['subject[0][value]']); - $this->assertText($edit['comment_body[0][value]']); - $this->assertText($web_user->getAccountName()); - $this->assertText($expected_text_date); + $this->assertSession()->pageTextContains($edit['subject[0][value]']); + $this->assertSession()->pageTextContains($edit['comment_body[0][value]']); + $this->assertSession()->pageTextContains($web_user->getAccountName()); + $this->assertSession()->pageTextContains($expected_text_date); // Check that the subject, comment, author and date fields are displayed with the correct values. $this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']); @@ -170,7 +170,7 @@ public function testCommentEditPreviewSave() { // Check that saving a comment produces a success message. $this->drupalPostForm('comment/' . $comment->id() . '/edit', $edit, 'Save'); - $this->assertText('Your comment has been posted.'); + $this->assertSession()->pageTextContains('Your comment has been posted.'); // Check that the comment fields are correct after loading the saved comment. $this->drupalGet('comment/' . $comment->id() . '/edit'); diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php index 1007a7983a4e..63b56e79bf31 100644 --- a/core/modules/comment/tests/src/Functional/CommentTestBase.php +++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php @@ -172,9 +172,9 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ if ($contact !== TRUE) { // If true then attempting to find error message. if ($subject) { - $this->assertText($subject); + $this->assertSession()->pageTextContains($subject); } - $this->assertText($comment); + $this->assertSession()->pageTextContains($comment); // Check the comment ID was extracted. $this->assertArrayHasKey(1, $match); } @@ -228,7 +228,7 @@ public function commentExists(CommentInterface $comment = NULL, $reply = FALSE) */ public function deleteComment(CommentInterface $comment) { $this->drupalPostForm('comment/' . $comment->id() . '/delete', [], 'Delete'); - $this->assertText('The comment and all its replies have been deleted.'); + $this->assertSession()->pageTextContains('The comment and all its replies have been deleted.'); } /** @@ -368,7 +368,7 @@ public function performCommentOperation(CommentInterface $comment, $operation, $ $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.')); } else { - $this->assertText('The update has been performed.'); + $this->assertSession()->pageTextContains('The update has been performed.'); } } diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index 0ce7589e6444..a0279747f98c 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -86,7 +86,7 @@ public function testCommentTypeCreation() { // Edit the comment-type and ensure that we cannot change the entity-type. $this->drupalGet('admin/structure/comment/manage/foo'); $this->assertSession()->fieldNotExists('target_entity_type_id'); - $this->assertText('Target entity type'); + $this->assertSession()->pageTextContains('Target entity type'); // Save the form and ensure the entity-type value is preserved even though // the field isn't present. $this->submitForm([], 'Save'); @@ -176,7 +176,7 @@ public function testCommentTypeDeletion() { $this->assertRaw( t('Are you sure you want to delete the comment type %type?', ['%type' => $type->id()]) ); - $this->assertText('This action cannot be undone.'); + $this->assertSession()->pageTextContains('This action cannot be undone.'); // Test exception thrown when re-using an existing comment type. try { diff --git a/core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php index 4f7d6ff2b094..938f2470952e 100644 --- a/core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php @@ -52,7 +52,7 @@ public function testApprovalAdminInterface() { // Test that the comments page loads correctly when there are no comments. $this->drupalGet('admin/content/comment'); - $this->assertText('No comments available.'); + $this->assertSession()->pageTextContains('No comments available.'); // Assert the expose filters on the admin page. $this->assertSession()->fieldExists('subject'); @@ -69,7 +69,7 @@ public function testApprovalAdminInterface() { 'name' => $author_name, 'comment_body[0][value]' => $body, ], 'Save'); - $this->assertText('Your comment has been queued for review by site administrators and will be published after approval.'); + $this->assertSession()->pageTextContains('Your comment has been queued for review by site administrators and will be published after approval.'); // Get unapproved comment id. $this->drupalLogin($this->adminUser); @@ -93,7 +93,7 @@ public function testApprovalAdminInterface() { $edit['comment_bulk_form[0]'] = $anonymous_comment4->id(); $this->drupalPostForm('admin/content/comment/approval', $edit, 'Apply to selected items'); - $this->assertText('Publish comment was applied to 1 item.'); + $this->assertSession()->pageTextContains('Publish comment was applied to 1 item.'); $this->drupalLogout(); $this->drupalGet('node/' . $this->node->id()); @@ -106,7 +106,7 @@ public function testApprovalAdminInterface() { // Publish multiple comments in one operation. $this->drupalLogin($this->adminUser); $this->drupalGet('admin/content/comment/approval'); - $this->assertText('Unapproved comments (2)'); + $this->assertSession()->pageTextContains('Unapproved comments (2)'); // Assert the expose filters on the admin page. $this->assertSession()->fieldExists('subject'); @@ -119,11 +119,11 @@ public function testApprovalAdminInterface() { "comment_bulk_form[0]" => $comments[1]->id(), ]; $this->submitForm($edit, 'Apply to selected items'); - $this->assertText('Unapproved comments (0)'); + $this->assertSession()->pageTextContains('Unapproved comments (0)'); // Test message when no comments selected. $this->drupalPostForm('admin/content/comment', [], 'Apply to selected items'); - $this->assertText('Select one or more comments to perform the update on.'); + $this->assertSession()->pageTextContains('Select one or more comments to perform the update on.'); $subject_link = $this->xpath('//table/tbody/tr/td/a[contains(@href, :href) and contains(@title, :title) and text()=:text]', [ ':href' => $comments[0]->permalink()->toString(), @@ -132,7 +132,7 @@ public function testApprovalAdminInterface() { ]); $this->assertTrue(!empty($subject_link), 'Comment listing shows the correct subject link.'); // Verify that anonymous author name is displayed correctly. - $this->assertText($author_name . ' (not verified)'); + $this->assertSession()->pageTextContains($author_name . ' (not verified)'); $subject_link = $this->xpath('//table/tbody/tr/td/a[contains(@href, :href) and contains(@title, :title) and text()=:text]', [ ':href' => $anonymous_comment4->permalink()->toString(), @@ -141,7 +141,7 @@ public function testApprovalAdminInterface() { ]); $this->assertTrue(!empty($subject_link), 'Comment listing shows the correct subject link.'); // Verify that anonymous author name is displayed correctly. - $this->assertText($author_name . ' (not verified)'); + $this->assertSession()->pageTextContains($author_name . ' (not verified)'); // Delete multiple comments in one operation. $edit = [ @@ -151,9 +151,9 @@ public function testApprovalAdminInterface() { "comment_bulk_form[2]" => $anonymous_comment4->id(), ]; $this->submitForm($edit, 'Apply to selected items'); - $this->assertText('Are you sure you want to delete these comments and all their children?'); + $this->assertSession()->pageTextContains('Are you sure you want to delete these comments and all their children?'); $this->submitForm([], 'Delete'); - $this->assertText('No comments available.'); + $this->assertSession()->pageTextContains('No comments available.'); // Make sure the label of unpublished node is not visible on listing page. $this->drupalGet('admin/content/comment'); @@ -162,7 +162,7 @@ public function testApprovalAdminInterface() { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/content/comment'); // Verify that comment admin can see the title of a published node. - $this->assertText(Html::escape($this->node->label())); + $this->assertSession()->pageTextContains(Html::escape($this->node->label())); $this->node->setUnpublished()->save(); $this->assertFalse($this->node->isPublished(), 'Node is unpublished now.'); $this->drupalGet('admin/content/comment'); @@ -177,7 +177,7 @@ public function testApprovalAdminInterface() { $this->drupalGet('admin/content/comment'); // Verify that comment admin with bypass node access permissions can still // see the title of a published node. - $this->assertText(Html::escape($this->node->label())); + $this->assertSession()->pageTextContains(Html::escape($this->node->label())); } /** @@ -222,11 +222,11 @@ public function testCommentedEntityLabel() { ]); $this->assertTrue(!empty($comment_author_link), 'Comment listing links to comment author.'); // Admin page contains label of both entities. - $this->assertText(Html::escape($this->node->label())); - $this->assertText(Html::escape($block_content->label())); + $this->assertSession()->pageTextContains(Html::escape($this->node->label())); + $this->assertSession()->pageTextContains(Html::escape($block_content->label())); // Admin page contains subject of both entities. - $this->assertText(Html::escape($node_comment->label())); - $this->assertText(Html::escape($block_content_comment->label())); + $this->assertSession()->pageTextContains(Html::escape($node_comment->label())); + $this->assertSession()->pageTextContains(Html::escape($block_content_comment->label())); } } diff --git a/core/modules/comment/tests/src/Functional/Views/CommentEditTest.php b/core/modules/comment/tests/src/Functional/Views/CommentEditTest.php index 7ad96e316daa..94263d081861 100644 --- a/core/modules/comment/tests/src/Functional/Views/CommentEditTest.php +++ b/core/modules/comment/tests/src/Functional/Views/CommentEditTest.php @@ -24,14 +24,14 @@ public function testCommentEdit() { // Post a comment to node. $node_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $this->drupalGet('admin/content/comment'); - $this->assertText($this->adminUser->label()); + $this->assertSession()->pageTextContains($this->adminUser->label()); $this->drupalGet($node_comment->toUrl('edit-form')); $edit = [ 'comment_body[0][value]' => $this->randomMachineName(), ]; $this->submitForm($edit, 'Save'); $this->drupalGet('admin/content/comment'); - $this->assertText($this->adminUser->label()); + $this->assertSession()->pageTextContains($this->adminUser->label()); } } diff --git a/core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php b/core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php index 944f6497a3e8..e3aa2b7215c4 100644 --- a/core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php +++ b/core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php @@ -58,7 +58,7 @@ public function testConfigOverride() { // overridden. \Drupal::state()->set('config_override_integration_test.enabled', TRUE); $this->drupalGet('<front>'); - $this->assertText('Overridden block label'); + $this->assertSession()->pageTextContains('Overridden block label'); // Both the cache context and tag should still be present. $this->assertCacheContext('config_override_integration_test'); diff --git a/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php b/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php index 7e1da3f94721..f857c16b7b64 100644 --- a/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php @@ -70,8 +70,8 @@ public function testConfigDependencyDeleteFormTrait() { $this->assertNoText('Configuration deletions'); $this->drupalGet($entity1->toUrl('delete-form')); $this->assertNoText('Configuration updates'); - $this->assertText('Configuration deletions'); - $this->assertText($entity2->id()); + $this->assertSession()->pageTextContains('Configuration deletions'); + $this->assertSession()->pageTextContains($entity2->id()); $this->drupalPostForm($entity1->toUrl('delete-form'), [], 'Delete'); $storage->resetCache(); $this->assertEmpty($storage->loadMultiple([$entity1->id(), $entity2->id()]), 'Test entities deleted'); @@ -117,10 +117,10 @@ public function testConfigDependencyDeleteFormTrait() { $entity3->save(); $this->drupalGet($entity1->toUrl('delete-form')); - $this->assertText('Configuration updates'); + $this->assertSession()->pageTextContains('Configuration updates'); $this->assertNoText('Configuration deletions'); $this->assertNoText($entity2->id()); - $this->assertText($entity2->label()); + $this->assertSession()->pageTextContains($entity2->label()); $this->assertNoText($entity3->id()); $this->drupalPostForm($entity1->toUrl('delete-form'), [], 'Delete'); $storage->resetCache(); diff --git a/core/modules/config/tests/src/Functional/ConfigEntityFormOverrideTest.php b/core/modules/config/tests/src/Functional/ConfigEntityFormOverrideTest.php index a5e8c215e9d9..a363649a4965 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityFormOverrideTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityFormOverrideTest.php @@ -47,7 +47,7 @@ public function testFormsWithOverrides() { // Test that the original label on the listing page is intact. $this->drupalGet('admin/structure/config_test'); - $this->assertText($original_label); + $this->assertSession()->pageTextContains($original_label); $this->assertNoText($overridden_label); // Test that the original label on the editing page is intact. @@ -62,7 +62,7 @@ public function testFormsWithOverrides() { $this->submitForm($edit, 'Save'); $this->drupalGet('admin/structure/config_test'); $this->assertNoText($overridden_label); - $this->assertText($edited_label); + $this->assertSession()->pageTextContains($edited_label); // Test that the editing page now has the edited label. $this->drupalGet('admin/structure/config_test/manage/dotted.default'); diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php index 1dd81548605e..d7aaf05509c0 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php @@ -246,7 +246,7 @@ public function testListUI() { $this->assertSession()->elementNotExists('xpath', '//td[text() = "dotted.default"]'); // Confirm that the empty text is displayed. - $this->assertText('There are no test configuration entities yet.'); + $this->assertSession()->pageTextContains('There are no test configuration entities yet.'); } /** diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php index e701616bc06b..4c911f635579 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php @@ -282,7 +282,7 @@ public function testCRUDUI() { $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $this->assertSession()->addressEquals('admin/structure/config_test'); $this->assertSession()->statusCodeEquals(200); - $this->assertText($label1); + $this->assertSession()->pageTextContains($label1); $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id"); // Rename the configuration entity's ID/machine name. @@ -295,7 +295,7 @@ public function testCRUDUI() { $this->assertSession()->statusCodeEquals(200); $this->assertNoText($label1); $this->assertNoText($label2); - $this->assertText($label3); + $this->assertSession()->pageTextContains($label3); $this->assertSession()->linkByHrefNotExists("admin/structure/config_test/manage/$id"); $id = $edit['id']; $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id"); diff --git a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php index edf9d4c80d02..56ae073421af 100644 --- a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php @@ -92,7 +92,7 @@ public function testExportImport() { // After installation there is no snapshot and nothing to import. $this->drupalGet('admin/config/development/configuration'); $this->assertNoText('Warning message'); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); $this->originalSlogan = $this->config('system.site')->get('slogan'); $this->newSlogan = $this->randomString(16); @@ -170,12 +170,12 @@ public function testExportImport() { // There is no snapshot yet because an import has never run. $this->assertNoText('Warning message'); $this->assertNoText('There are no configuration changes to import.'); - $this->assertText($this->contentType->label()); + $this->assertSession()->pageTextContains($this->contentType->label()); $this->submitForm([], 'Import all'); // After importing the snapshot has been updated and there are no warnings. $this->assertNoText('Warning message'); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); $this->assertEquals($this->newSlogan, $this->config('system.site')->get('slogan')); @@ -186,8 +186,8 @@ public function testExportImport() { ->set('slogan', $this->originalSlogan) ->save(); $this->drupalGet('admin/config/development/configuration'); - $this->assertText('Warning message'); - $this->assertText('The following items in your active configuration have changes since the last import that may be lost on the next import.'); + $this->assertSession()->pageTextContains('Warning message'); + $this->assertSession()->pageTextContains('The following items in your active configuration have changes since the last import that may be lost on the next import.'); // Ensure the item is displayed as part of a list (to avoid false matches // on the rest of the page) and that the list markup is not escaped. $this->assertRaw('<li>system.site</li>'); @@ -197,7 +197,7 @@ public function testExportImport() { $this->drupalGet('admin/config/development/configuration'); $this->assertNoText('Warning message'); $this->assertNoText('The following items in your active configuration have changes since the last import that may be lost on the next import.'); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); // Write a file to sync. The warning about differences between the active // and snapshot should now exist. /** @var \Drupal\Core\Config\StorageInterface $sync */ @@ -207,8 +207,8 @@ public function testExportImport() { $this->copyConfig($this->container->get('config.storage'), $sync); $sync->write('system.site', $data); $this->drupalGet('admin/config/development/configuration'); - $this->assertText('Warning message'); - $this->assertText('The following items in your active configuration have changes since the last import that may be lost on the next import.'); + $this->assertSession()->pageTextContains('Warning message'); + $this->assertSession()->pageTextContains('The following items in your active configuration have changes since the last import that may be lost on the next import.'); // Ensure the item is displayed as part of a list (to avoid false matches // on the rest of the page) and that the list markup is not escaped. $this->assertRaw('<li>system.site</li>'); @@ -279,23 +279,23 @@ public function testExportImportCollections() { // Verify that there are configuration differences to import. $this->drupalGet('admin/config/development/configuration'); $this->assertNoText('There are no configuration changes to import.'); - $this->assertText('collection.test1 configuration collection'); - $this->assertText('collection.test2 configuration collection'); - $this->assertText('config_test.create'); + $this->assertSession()->pageTextContains('collection.test1 configuration collection'); + $this->assertSession()->pageTextContains('collection.test2 configuration collection'); + $this->assertSession()->pageTextContains('config_test.create'); $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create'); - $this->assertText('config_test.update'); + $this->assertSession()->pageTextContains('config_test.update'); $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.update'); - $this->assertText('config_test.delete'); + $this->assertSession()->pageTextContains('config_test.delete'); $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.delete'); - $this->assertText('config_test.another_create'); + $this->assertSession()->pageTextContains('config_test.another_create'); $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_create'); - $this->assertText('config_test.another_update'); + $this->assertSession()->pageTextContains('config_test.another_update'); $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_update'); - $this->assertText('config_test.another_delete'); + $this->assertSession()->pageTextContains('config_test.another_delete'); $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete'); $this->submitForm([], 'Import all'); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); // Test data in collections. $data = $test1_storage->read('config_test.create'); diff --git a/core/modules/config/tests/src/Functional/ConfigImportInstallProfileTest.php b/core/modules/config/tests/src/Functional/ConfigImportInstallProfileTest.php index 3685bce03ab7..5ba88f63dc8a 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportInstallProfileTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportInstallProfileTest.php @@ -60,8 +60,8 @@ public function testInstallProfileValidation() { $sync->write('core.extension', $core); $this->drupalPostForm('admin/config/development/configuration', [], 'Import all'); - $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); - $this->assertText('Unable to uninstall the Testing config import profile since it is the install profile.'); + $this->assertSession()->pageTextContains('The configuration cannot be imported because it failed validation for the following reasons:'); + $this->assertSession()->pageTextContains('Unable to uninstall the Testing config import profile since it is the install profile.'); // Uninstall dependencies of testing_config_import. $core['module']['testing_config_import'] = 0; @@ -75,7 +75,7 @@ public function testInstallProfileValidation() { $theme['default'] = 'classy'; $sync->write('system.theme', $theme); $this->drupalPostForm('admin/config/development/configuration', [], 'Import all'); - $this->assertText('The configuration was imported successfully.'); + $this->assertSession()->pageTextContains('The configuration was imported successfully.'); $this->rebuildContainer(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('syslog'), 'The syslog module has been uninstalled.'); $this->assertFalse(\Drupal::service('theme_handler')->themeExists('stark'), 'The stark theme has been uninstalled.'); diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php index 6653de7b2018..3318afaa4cab 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\config\Functional; -use Drupal\Component\Utility\Html; use Drupal\Core\Config\InstallStorage; use Drupal\Tests\BrowserTestBase; @@ -56,7 +55,7 @@ public function testImport() { $sync = $this->container->get('config.storage.sync'); $this->drupalGet('admin/config/development/configuration'); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); $this->assertSession()->buttonNotExists('Import all'); // Create updated configuration object. @@ -138,7 +137,7 @@ public function testImport() { $this->assertSession()->buttonNotExists('Import all'); // Verify that there are no further changes to import. - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); $this->rebuildContainer(); // Verify site name has changed. @@ -245,7 +244,7 @@ public function testImportLock() { // Attempt to import configuration and verify that an error message appears. $this->submitForm([], 'Import all'); - $this->assertText('Another request may be synchronizing configuration already.'); + $this->assertSession()->pageTextContains('Another request may be synchronizing configuration already.'); // Release the lock, just to keep testing sane. $this->container->get('lock.persistent')->release($config_importer::LOCK_NAME); @@ -267,7 +266,7 @@ public function testImportSiteUuidValidation() { // Verify that there are configuration differences to import. $this->drupalGet('admin/config/development/configuration'); - $this->assertText('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'); + $this->assertSession()->pageTextContains('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'); $this->assertSession()->buttonNotExists('Import all'); } @@ -308,14 +307,14 @@ public function testImportDiff() { // changed. // Changed values are escaped. - $this->assertText(Html::escape("foo: '<p><em>foobar</em></p>'")); - $this->assertText(Html::escape("foo: '<p>foobar</p>'")); + $this->assertSession()->pageTextContains("foo: '<p><em>foobar</em></p>'"); + $this->assertSession()->pageTextContains("foo: '<p>foobar</p>'"); // The no change values are escaped. - $this->assertText(Html::escape("baz: '<strong>no change</strong>'")); + $this->assertSession()->pageTextContains("baz: '<strong>no change</strong>'"); // Added value is escaped. - $this->assertText(Html::escape("biff: '<em>bangpow</em>'")); + $this->assertSession()->pageTextContains("biff: '<em>bangpow</em>'"); // Deleted value is escaped. - $this->assertText(Html::escape("404: '<em>herp</em>'")); + $this->assertSession()->pageTextContains("404: '<em>herp</em>'"); // Verify diff colors are displayed. $result = $this->xpath('//table[contains(@class, :class)]', [':class' => 'diff']); @@ -329,10 +328,10 @@ public function testImportDiff() { // Load the diff UI and verify that the diff reflects a removed key. $this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name); // The no change values are escaped. - $this->assertText(Html::escape("foo: '<p>foobar</p>'")); - $this->assertText(Html::escape("baz: '<strong>no change</strong>'")); + $this->assertSession()->pageTextContains("foo: '<p>foobar</p>'"); + $this->assertSession()->pageTextContains("baz: '<strong>no change</strong>'"); // Removed key is escaped. - $this->assertText(Html::escape("404: '<em>herp</em>'")); + $this->assertSession()->pageTextContains("404: '<em>herp</em>'"); // Reset data back to original and add a key $sync_data = $original_data; @@ -342,10 +341,10 @@ public function testImportDiff() { // Load the diff UI and verify that the diff reflects an added key. $this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name); // The no change values are escaped. - $this->assertText(Html::escape("baz: '<strong>no change</strong>'")); - $this->assertText(Html::escape("404: '<em>herp</em>'")); + $this->assertSession()->pageTextContains("baz: '<strong>no change</strong>'"); + $this->assertSession()->pageTextContains("404: '<em>herp</em>'"); // Added key is escaped. - $this->assertText(Html::escape("biff: '<em>bangpow</em>'")); + $this->assertSession()->pageTextContains("biff: '<em>bangpow</em>'"); } /** @@ -365,9 +364,9 @@ public function testImportValidation() { $this->submitForm([], 'Import all'); // Verify that the validation messages appear. - $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); - $this->assertText('Config import validate error 1.'); - $this->assertText('Config import validate error 2.'); + $this->assertSession()->pageTextContains('The configuration cannot be imported because it failed validation for the following reasons:'); + $this->assertSession()->pageTextContains('Config import validate error 1.'); + $this->assertSession()->pageTextContains('Config import validate error 2.'); // Verify site name has not changed. $this->assertNotEquals($this->config('system.site')->get('name'), $new_site_name); @@ -381,11 +380,11 @@ public function testConfigUninstallConfigException() { $sync->write('core.extension', $core_extension); $this->drupalGet('admin/config/development/configuration'); - $this->assertText('core.extension'); + $this->assertSession()->pageTextContains('core.extension'); // Import and verify that both do not appear anymore. $this->submitForm([], 'Import all'); - $this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); + $this->assertSession()->pageTextContains('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); } public function prepareSiteNameUpdate($new_site_name) { @@ -442,10 +441,10 @@ public function testImportErrorLog() { // Attempt to import configuration and verify that an error message appears. $this->submitForm([], 'Import all'); - $this->assertText('Deleted and replaced configuration entity "' . $name_secondary . '"'); - $this->assertText('The configuration was imported with errors.'); + $this->assertSession()->pageTextContains('Deleted and replaced configuration entity "' . $name_secondary . '"'); + $this->assertSession()->pageTextContains('The configuration was imported with errors.'); $this->assertNoText('The configuration was imported successfully.'); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); } /** @@ -462,11 +461,11 @@ public function testEntityBundleDelete() { $this->drupalGet('admin/config/development/configuration'); // The node type, body field and entity displays will be scheduled for // removal. - $this->assertText('node.type.' . $node_type->id()); - $this->assertText('field.field.node.' . $node_type->id() . '.body'); - $this->assertText('core.entity_view_display.node.' . $node_type->id() . '.teaser'); - $this->assertText('core.entity_view_display.node.' . $node_type->id() . '.default'); - $this->assertText('core.entity_form_display.node.' . $node_type->id() . '.default'); + $this->assertSession()->pageTextContains('node.type.' . $node_type->id()); + $this->assertSession()->pageTextContains('field.field.node.' . $node_type->id() . '.body'); + $this->assertSession()->pageTextContains('core.entity_view_display.node.' . $node_type->id() . '.teaser'); + $this->assertSession()->pageTextContains('core.entity_view_display.node.' . $node_type->id() . '.default'); + $this->assertSession()->pageTextContains('core.entity_form_display.node.' . $node_type->id() . '.default'); // Attempt to import configuration and verify that an error message appears // and the node type, body field and entity displays are still scheduled for @@ -474,17 +473,17 @@ public function testEntityBundleDelete() { $this->submitForm([], 'Import all'); $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]); $this->assertRaw($validation_message); - $this->assertText('node.type.' . $node_type->id()); - $this->assertText('field.field.node.' . $node_type->id() . '.body'); - $this->assertText('core.entity_view_display.node.' . $node_type->id() . '.teaser'); - $this->assertText('core.entity_view_display.node.' . $node_type->id() . '.default'); - $this->assertText('core.entity_form_display.node.' . $node_type->id() . '.default'); + $this->assertSession()->pageTextContains('node.type.' . $node_type->id()); + $this->assertSession()->pageTextContains('field.field.node.' . $node_type->id() . '.body'); + $this->assertSession()->pageTextContains('core.entity_view_display.node.' . $node_type->id() . '.teaser'); + $this->assertSession()->pageTextContains('core.entity_view_display.node.' . $node_type->id() . '.default'); + $this->assertSession()->pageTextContains('core.entity_form_display.node.' . $node_type->id() . '.default'); // Delete the node and try to import again. $node->delete(); $this->submitForm([], 'Import all'); $this->assertNoRaw($validation_message); - $this->assertText('There are no configuration changes to import.'); + $this->assertSession()->pageTextContains('There are no configuration changes to import.'); $this->assertNoText('node.type.' . $node_type->id()); $this->assertNoText('field.field.node.' . $node_type->id() . '.body'); $this->assertNoText('core.entity_view_display.node.' . $node_type->id() . '.teaser'); @@ -520,11 +519,11 @@ public function testExtensionValidation() { $sync->write('core.extension', $core); $this->drupalPostForm('admin/config/development/configuration', [], 'Import all'); - $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); - $this->assertText('Unable to uninstall the Text module since the Node module is installed.'); - $this->assertText('Unable to uninstall the Theme test base theme theme since the Theme test subtheme theme is installed.'); - $this->assertText('Unable to install the does_not_exist module since it does not exist.'); - $this->assertText('Unable to install the does_not_exist theme since it does not exist.'); + $this->assertSession()->pageTextContains('The configuration cannot be imported because it failed validation for the following reasons:'); + $this->assertSession()->pageTextContains('Unable to uninstall the Text module since the Node module is installed.'); + $this->assertSession()->pageTextContains('Unable to uninstall the Theme test base theme theme since the Theme test subtheme theme is installed.'); + $this->assertSession()->pageTextContains('Unable to install the does_not_exist module since it does not exist.'); + $this->assertSession()->pageTextContains('Unable to install the does_not_exist theme since it does not exist.'); } /** diff --git a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php index 8d63151ba001..a1e8148415a5 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php @@ -53,7 +53,7 @@ public function testImport() { $text_file = $this->getTestFiles('text')[0]; $edit = ['files[import_tarball]' => \Drupal::service('file_system')->realpath($text_file->uri)]; $this->drupalPostForm('admin/config/development/configuration/full/import', $edit, 'Upload'); - $this->assertText('Could not extract the contents of the tar file'); + $this->assertSession()->pageTextContains('Could not extract the contents of the tar file'); // Make the sync directory read-only. $directory = Settings::get('config_sync_directory'); diff --git a/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php b/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php index 6b3335354bed..2c3882deea97 100644 --- a/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php @@ -78,7 +78,7 @@ public function testSiteNameTranslation() { // we access the XX front page. // @see \Drupal\Core\PathProcessor::processInbound() $this->drupalGet('xx'); - $this->assertText('XX site name'); + $this->assertSession()->pageTextContains('XX site name'); // Set the xx language to be the default language and delete the English // language so the site is no longer multilingual and confirm configuration @@ -91,7 +91,7 @@ public function testSiteNameTranslation() { $this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.'); $this->drupalGet('xx'); - $this->assertText('XX site name'); + $this->assertSession()->pageTextContains('XX site name'); } diff --git a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php index 06c04b075cc1..c299b06e4e7f 100644 --- a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php +++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php @@ -54,7 +54,7 @@ public function testImport() { $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, 'Import'); // Assert the static portion of the error since different parsers could give different text in their error. - $this->assertText('The import failed with the following message: '); + $this->assertSession()->pageTextContains('The import failed with the following message: '); $import = <<<EOD label: First @@ -68,7 +68,7 @@ public function testImport() { ]; // Attempt an import with a missing ID. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, 'Import'); - $this->assertText('Missing ID key "id" for this Test configuration import.'); + $this->assertSession()->pageTextContains('Missing ID key "id" for this Test configuration import.'); // Perform an import with no specified UUID and a unique ID. $this->assertNull($storage->load('first')); @@ -84,12 +84,12 @@ public function testImport() { // Attempt an import with an existing ID but missing UUID. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, 'Import'); - $this->assertText('An entity with this machine name already exists but the import did not specify a UUID.'); + $this->assertSession()->pageTextContains('An entity with this machine name already exists but the import did not specify a UUID.'); // Attempt an import with a mismatched UUID and existing ID. $edit['import'] .= "\nuuid: " . $uuid->generate(); $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, 'Import'); - $this->assertText('An entity with this machine name already exists but the UUID does not match.'); + $this->assertSession()->pageTextContains('An entity with this machine name already exists but the UUID does not match.'); // Attempt an import with a custom ID. $edit['custom_entity_id'] = 'custom_id'; @@ -216,7 +216,7 @@ public function testImportSimpleConfiguration() { $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration'])); $this->submitForm([], 'Confirm'); $this->drupalGet(''); - $this->assertText('Test simple import'); + $this->assertSession()->pageTextContains('Test simple import'); // Ensure that ConfigImporter validation is running when importing simple // configuration. @@ -229,12 +229,12 @@ public function testImportSimpleConfiguration() { 'import' => Yaml::encode($config_data), ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, 'Import'); - $this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); + $this->assertSession()->pageTextContains('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); // Try to import without any values. $this->drupalPostForm('admin/config/development/configuration/single/import', [], 'Import'); - $this->assertText('Configuration type field is required.'); - $this->assertText('Paste your configuration here field is required.'); + $this->assertSession()->pageTextContains('Configuration type field is required.'); + $this->assertSession()->pageTextContains('Paste your configuration here field is required.'); } /** diff --git a/core/modules/config/tests/src/Functional/LanguageNegotiationFormOverrideTest.php b/core/modules/config/tests/src/Functional/LanguageNegotiationFormOverrideTest.php index 2d17f5003662..68e330ba1198 100644 --- a/core/modules/config/tests/src/Functional/LanguageNegotiationFormOverrideTest.php +++ b/core/modules/config/tests/src/Functional/LanguageNegotiationFormOverrideTest.php @@ -44,7 +44,7 @@ public function testFormWithOverride() { $this->drupalGet('admin/config/regional/language/detection/url'); // The language-negotiation form should be found. - $this->assertText('Path prefix configuration'); + $this->assertSession()->pageTextContains('Path prefix configuration'); // The English override should not be found. $this->assertSession()->fieldValueNotEquals('prefix[en]', $overridden_value_en); @@ -53,7 +53,7 @@ public function testFormWithOverride() { $this->drupalGet($overridden_value_es . '/admin/config/regional/language/detection/url'); // The language-negotiation form should be found. - $this->assertText('Path prefix configuration'); + $this->assertSession()->pageTextContains('Path prefix configuration'); // The Spanish override should not be found. $this->assertSession()->fieldValueNotEquals('prefix[es]', $overridden_value_es); diff --git a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php index 8dc70195e21b..3d78745758e8 100644 --- a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php +++ b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php @@ -60,7 +60,7 @@ public function testConfigSchemaChecker() { // Test that the config event listener is working in the child site. $this->drupalGet('config_test/schema_listener'); - $this->assertText('No schema for config_schema_test.schemaless'); + $this->assertSession()->pageTextContains('No schema for config_schema_test.schemaless'); } } diff --git a/core/modules/config/tests/src/Functional/TransformedConfigExportImportUITest.php b/core/modules/config/tests/src/Functional/TransformedConfigExportImportUITest.php index 6df2a9ff485e..625bf44839b3 100644 --- a/core/modules/config/tests/src/Functional/TransformedConfigExportImportUITest.php +++ b/core/modules/config/tests/src/Functional/TransformedConfigExportImportUITest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\config\Functional; -use Drupal\Component\Utility\Html; use Drupal\Tests\BrowserTestBase; /** @@ -54,8 +53,8 @@ public function testTransformedExportImport() { // Tests changes of system.site. $this->drupalGet('admin/config/development/configuration/sync/diff/system.site'); - $this->assertText('name: Drupal'); - $this->assertText(Html::escape("name: 'Drupal Arrr'")); + $this->assertSession()->pageTextContains('name: Drupal'); + $this->assertSession()->pageTextContains("name: 'Drupal Arrr'"); // Add a slogan. $originalSlogan = $this->config('system.site')->get('slogan'); @@ -69,8 +68,8 @@ public function testTransformedExportImport() { // Tests changes of system.site. $this->drupalGet('admin/config/development/configuration/sync/diff/system.site'); - $this->assertText(Html::escape("slogan: ''")); - $this->assertText(Html::escape("slogan: $newSlogan")); + $this->assertSession()->pageTextContains("slogan: ''"); + $this->assertSession()->pageTextContains("slogan: $newSlogan"); // Export the configuration. $this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export'); @@ -83,8 +82,8 @@ public function testTransformedExportImport() { // Assert the new name and slogan. $this->drupalGet('admin/config/development/configuration/sync/diff/system.site'); - $this->assertText(Html::escape("name: 'Drupal Arrr'")); - $this->assertText(Html::escape("slogan: '$originalSlogan Arrr'")); + $this->assertSession()->pageTextContains("name: 'Drupal Arrr'"); + $this->assertSession()->pageTextContains("slogan: '$originalSlogan Arrr'"); $this->assertEquals('Drupal', $this->config('system.site')->get('name')); $this->assertEquals($newSlogan, $this->config('system.site')->get('slogan')); @@ -95,7 +94,7 @@ public function testTransformedExportImport() { // Assert that the event was dispatched again on the new config. $this->drupalGet('admin/config/development/configuration/sync/diff/system.site'); - $this->assertText(Html::escape("name: 'Drupal Arrr Arrr'")); + $this->assertSession()->pageTextContains("name: 'Drupal Arrr Arrr'"); } } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationCacheTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationCacheTest.php index 1f18877a3ff1..80dee13b8048 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationCacheTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationCacheTest.php @@ -147,9 +147,9 @@ public function testFieldConfigTranslation() { $this->drupalGet("/entity_test/structure/$bundle/fields/entity_test.$bundle.$field_name/translate"); $this->clickLink('Add'); - $this->assertText('Translatable field setting'); + $this->assertSession()->pageTextContains('Translatable field setting'); $this->assertSession()->assertEscaped($translatable_field_setting); - $this->assertText('Translatable storage setting'); + $this->assertSession()->pageTextContains('Translatable storage setting'); $this->assertSession()->assertEscaped($translatable_storage_setting); // Add translation for label. diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php index 8cbbfe59ab58..0a8dc7959e96 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php @@ -137,17 +137,17 @@ public function testHiddenEntities() { // Hidden languages are only available to translate through the // configuration translation listings. $this->drupalGet('admin/config/regional/config-translation/configurable_language'); - $this->assertText('Not applicable'); + $this->assertSession()->pageTextContains('Not applicable'); $this->assertSession()->linkByHrefExists('admin/config/regional/language/edit/zxx/translate'); - $this->assertText('Not specified'); + $this->assertSession()->pageTextContains('Not specified'); $this->assertSession()->linkByHrefExists('admin/config/regional/language/edit/und/translate'); // Hidden date formats are only available to translate through the // configuration translation listings. Test a couple of them. $this->drupalGet('admin/config/regional/config-translation/date_format'); - $this->assertText('HTML Date'); + $this->assertSession()->pageTextContains('HTML Date'); $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/html_date/translate'); - $this->assertText('HTML Year'); + $this->assertSession()->pageTextContains('HTML Year'); $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/html_year/translate'); } @@ -172,7 +172,7 @@ public function testListingPageWithOverrides() { // Test that the original label on the listing page is intact. $this->drupalGet('admin/config/regional/config-translation/config_test'); - $this->assertText($original_label); + $this->assertSession()->pageTextContains($original_label); $this->assertNoText($overridden_label); } @@ -198,8 +198,8 @@ public function testListingFieldsPage() { $field->save(); $this->drupalGet('admin/config/regional/config-translation/node_fields'); - $this->assertText('Body'); - $this->assertText('Basic'); + $this->assertSession()->pageTextContains('Body'); + $this->assertSession()->pageTextContains('Basic'); $this->assertSession()->linkByHrefExists('admin/structure/types/manage/basic/fields/node.basic.body/translate'); } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php index 32a3bb6cf1a9..ec995c60c433 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php @@ -193,8 +193,8 @@ public function testSiteInformationTranslationUi() { // Visit French site to ensure base language string present as source. $this->drupalGet("fr/$translation_base_url/fr/edit"); - $this->assertText($site_name); - $this->assertText($site_slogan); + $this->assertSession()->pageTextContains($site_name); + $this->assertSession()->pageTextContains($site_slogan); // Translate 'Site name' label in French. $search = [ @@ -213,18 +213,18 @@ public function testSiteInformationTranslationUi() { // Ensure that the label is in French (and not in English). $this->drupalGet("fr/$translation_base_url/fr/edit"); - $this->assertText($fr_site_name_label); + $this->assertSession()->pageTextContains($fr_site_name_label); $this->assertNoText($site_name_label); // Ensure that the label is also in French (and not in English) // when editing another language with the interface in French. $this->drupalGet("fr/$translation_base_url/ta/edit"); - $this->assertText($fr_site_name_label); + $this->assertSession()->pageTextContains($fr_site_name_label); $this->assertNoText($site_name_label); // Ensure that the label is not translated when the interface is in English. $this->drupalGet("$translation_base_url/fr/edit"); - $this->assertText($site_name_label); + $this->assertSession()->pageTextContains($site_name_label); $this->assertNoText($fr_site_name_label); } @@ -335,7 +335,7 @@ public function testContactConfigEntityTranslation() { // Visit the form to confirm the changes. $this->drupalGet('contact/feedback'); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); foreach ($this->langcodes as $langcode) { $this->drupalGet($translation_base_url); @@ -347,7 +347,7 @@ public function testContactConfigEntityTranslation() { // Make sure original text is present on this page. $this->drupalGet($translation_page_url); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); // Update translatable fields. $edit = [ @@ -373,7 +373,7 @@ public function testContactConfigEntityTranslation() { // Visit language specific version of form to check label. $this->drupalGet($langcode . '/contact/feedback'); - $this->assertText('Website feedback - ' . $langcode); + $this->assertSession()->pageTextContains('Website feedback - ' . $langcode); // Submit feedback. $edit = [ @@ -391,7 +391,7 @@ public function testContactConfigEntityTranslation() { foreach ($langcode_prefixes as $langcode_prefix) { $this->drupalGet(ltrim("$langcode_prefix/$translation_base_url/$langcode/edit", '/')); $this->assertSession()->fieldValueEquals('translation[config_names][contact.form.feedback][label]', 'Website feedback - ' . $langcode); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); } } @@ -476,7 +476,7 @@ public function testDateFormatTranslation() { // Make sure original text is present on this page. $this->drupalGet($translation_page_url); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); // Make sure that the date library is added. $this->assertRaw('core/modules/system/js/system.date.js'); @@ -538,8 +538,8 @@ public function testAccountSettingsConfigurationTranslation() { $this->assertSession()->fieldValueEquals($key, $value); } // Check that labels for email settings appear. - $this->assertText('Account cancellation confirmation'); - $this->assertText('Password recovery'); + $this->assertSession()->pageTextContains('Account cancellation confirmation'); + $this->assertSession()->pageTextContains('Password recovery'); } /** @@ -757,9 +757,9 @@ public function testFieldConfigTranslation() { $this->drupalGet("/entity_test/structure/$bundle/fields/entity_test.$bundle.$field_name/translate"); $this->clickLink('Add'); - $this->assertText('Translatable field setting'); + $this->assertSession()->pageTextContains('Translatable field setting'); $this->assertSession()->assertEscaped($translatable_field_setting); - $this->assertText('Translatable storage setting'); + $this->assertSession()->pageTextContains('Translatable storage setting'); $this->assertSession()->assertEscaped($translatable_storage_setting); } @@ -796,7 +796,7 @@ public function testBooleanFieldConfigTranslation() { // Checks the text of details summary element that surrounds the translation // options. - $this->assertText(Html::escape(strip_tags($on_label)) . ' Boolean settings'); + $this->assertSession()->responseContains(Html::escape(strip_tags($on_label)) . ' Boolean settings'); // Checks that the correct on and off labels appear on the form. $this->assertSession()->assertEscaped($on_label); @@ -890,7 +890,7 @@ public function testAlterInfo() { // Check if the translation page does not have the altered out settings. $this->drupalGet('admin/config/people/accounts/translate/fr/add'); - $this->assertText('Name'); + $this->assertSession()->pageTextContains('Name'); $this->assertNoText('Account cancellation confirmation'); $this->assertNoText('Password recovery'); } @@ -1061,7 +1061,7 @@ public function testNodeFieldTranslation() { 'translation[config_names][field.field.node.article.translatable_field][label]' => 'FR label', ]; $this->submitForm($form_values, 'Save translation'); - $this->assertText('Successfully saved French translation.'); + $this->assertSession()->pageTextContains('Successfully saved French translation.'); // Check that the translations are saved. $this->clickLink('Add'); diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php index 64caf83a7b4b..09951b0faa7b 100644 --- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -203,7 +203,7 @@ public function testPersonalContactAccess() { $this->drupalLogin($this->adminUser); $edit = ['contact_default_status' => FALSE]; $this->drupalPostForm('admin/config/people/accounts', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $this->drupalLogout(); // Re-create our contacted user with personal contact forms disabled by @@ -265,7 +265,7 @@ public function testPersonalContactFlood() { // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_limit; $i++) { $this->submitPersonalContact($this->contactUser); - $this->assertText('Your message has been sent.'); + $this->assertSession()->pageTextContains('Your message has been sent.'); } // Submit contact form one over limit. diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php index 651420f5fb99..abbe71420c6b 100644 --- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php +++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php @@ -108,7 +108,7 @@ public function testSiteWideContact() { $edit = []; $edit['contact_default_status'] = TRUE; $this->drupalPostForm('admin/config/people/accounts', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $this->drupalGet('admin/structure/contact'); // Default form exists. @@ -131,7 +131,7 @@ public function testSiteWideContact() { // Delete old forms to ensure that new forms are used. $this->deleteContactForms(); $this->drupalGet('admin/structure/contact'); - $this->assertText('Personal'); + $this->assertSession()->pageTextContains('Personal'); $this->assertSession()->linkByHrefNotExists('admin/structure/contact/manage/feedback'); // Ensure that the contact form won't be shown without forms. @@ -143,7 +143,7 @@ public function testSiteWideContact() { $this->drupalLogin($admin_user); $this->drupalGet('contact'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The contact form has not been configured.'); + $this->assertSession()->pageTextContains('The contact form has not been configured.'); // Test access personal form via site-wide contact page. $this->drupalGet('contact/personal'); $this->assertSession()->statusCodeEquals(403); @@ -158,25 +158,25 @@ public function testSiteWideContact() { // Test validation of empty form and recipients fields. $this->addContactForm('', '', '', '', TRUE); - $this->assertText('Label field is required.'); - $this->assertText('Machine-readable name field is required.'); - $this->assertText('Recipients field is required.'); + $this->assertSession()->pageTextContains('Label field is required.'); + $this->assertSession()->pageTextContains('Machine-readable name field is required.'); + $this->assertSession()->pageTextContains('Recipients field is required.'); // Test validation of max_length machine name. $recipients = ['simpletest&@example.com', 'simpletest2@example.com', 'simpletest3@example.com']; $max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH; $max_length_exceeded = $max_length + 1; $this->addContactForm($id = mb_strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', [$recipients[0]]), '', TRUE); - $this->assertText('Machine-readable name cannot be longer than ' . $max_length . ' characters but is currently ' . $max_length_exceeded . ' characters long.'); + $this->assertSession()->pageTextContains('Machine-readable name cannot be longer than ' . $max_length . ' characters but is currently ' . $max_length_exceeded . ' characters long.'); $this->addContactForm($id = mb_strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', [$recipients[0]]), '', TRUE); - $this->assertText('Contact form ' . $label . ' has been added.'); + $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); // Verify that the creation message contains a link to a contact form. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "contact/")]'); // Create first valid form. $this->addContactForm($id = mb_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0]]), '', TRUE); - $this->assertText('Contact form ' . $label . ' has been added.'); + $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); // Verify that the creation message contains a link to a contact form. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "contact/")]'); @@ -200,10 +200,10 @@ public function testSiteWideContact() { $this->assertEquals([$recipients[0], $recipients[1]], $config['recipients']); $this->assertEquals($reply, $config['reply']); $this->assertNotEquals($this->config('contact.settings')->get('default_form'), $id); - $this->assertText('Contact form ' . $label . ' has been updated.'); + $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been updated.'); // Ensure the label is displayed on the contact page for this form. $this->drupalGet('contact/' . $id); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); // Reset the form back to be the default form. $this->config('contact.settings')->set('default_form', $id)->save(); @@ -212,16 +212,16 @@ public function testSiteWideContact() { user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalLogout(); $this->drupalGet('contact'); - $this->assertText('Your email address'); + $this->assertSession()->pageTextContains('Your email address'); $this->assertNoText('Form'); $this->drupalLogin($admin_user); // Add more forms. $this->addContactForm(mb_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1]]), '', FALSE); - $this->assertText('Contact form ' . $label . ' has been added.'); + $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); $this->addContactForm($name = mb_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1], $recipients[2]]), '', FALSE); - $this->assertText('Contact form ' . $label . ' has been added.'); + $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); // Try adding a form that already exists. $this->addContactForm($name, $label, '', '', FALSE); @@ -242,19 +242,19 @@ public function testSiteWideContact() { // Submit contact form with invalid values. $this->submitContact('', $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); - $this->assertText('Your name field is required.'); + $this->assertSession()->pageTextContains('Your name field is required.'); $this->submitContact($this->randomMachineName(16), '', $this->randomMachineName(16), $id, $this->randomMachineName(64)); - $this->assertText('Your email address field is required.'); + $this->assertSession()->pageTextContains('Your email address field is required.'); $this->submitContact($this->randomMachineName(16), $invalid_recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid'])); $this->submitContact($this->randomMachineName(16), $recipients[0], '', $id, $this->randomMachineName(64)); - $this->assertText('Subject field is required.'); + $this->assertSession()->pageTextContains('Subject field is required.'); $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, ''); - $this->assertText('Message field is required.'); + $this->assertSession()->pageTextContains('Message field is required.'); // Test contact form with no default form selected. $this->config('contact.settings') @@ -272,7 +272,7 @@ public function testSiteWideContact() { // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_limit; $i++) { $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); - $this->assertText('Your message has been sent.'); + $this->assertSession()->pageTextContains('Your message has been sent.'); } // Submit contact form one over limit. $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); @@ -325,11 +325,11 @@ public function testSiteWideContact() { // Check preview field can be ordered. $this->drupalGet('admin/structure/contact/manage/' . $contact_form . '/form-display'); - $this->assertText('Preview'); + $this->assertSession()->pageTextContains('Preview'); // Check that the field is displayed. $this->drupalGet('contact/' . $contact_form); - $this->assertText($field_label); + $this->assertSession()->pageTextContains($field_label); // Submit the contact form and verify the content. $edit = [ @@ -360,7 +360,7 @@ public function testSiteWideContact() { $field_name . '[0][value]' => $this->randomMachineName(), ]; $this->submitForm($edit, 'Send message'); - $this->assertText('Thanks for your submission.'); + $this->assertSession()->pageTextContains('Thanks for your submission.'); $this->assertSession()->addressEquals('user/' . $admin_user->id()); // Test Empty message. diff --git a/core/modules/contact/tests/src/Functional/ContactStorageTest.php b/core/modules/contact/tests/src/Functional/ContactStorageTest.php index 5b1514f34660..a2671caf15d8 100644 --- a/core/modules/contact/tests/src/Functional/ContactStorageTest.php +++ b/core/modules/contact/tests/src/Functional/ContactStorageTest.php @@ -54,16 +54,16 @@ public function testContactStorage() { $this->addContactForm($id = mb_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$mail]), '', TRUE, 'Your message has been sent.', [ 'send_a_pony' => 1, ]); - $this->assertText('Contact form ' . $label . ' has been added.'); + $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); // Ensure that anonymous can submit site-wide contact form. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalLogout(); $this->drupalGet('contact'); - $this->assertText('Your email address'); + $this->assertSession()->pageTextContains('Your email address'); $this->assertNoText('Form'); $this->submitContact($name = $this->randomMachineName(16), $mail, $subject = $this->randomMachineName(16), $id, $message = $this->randomMachineName(64)); - $this->assertText('Your message has been sent.'); + $this->assertSession()->pageTextContains('Your message has been sent.'); $messages = Message::loadMultiple(); /** @var \Drupal\contact\Entity\Message $message */ diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php index 38da3557031b..3c668bc23374 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php @@ -165,7 +165,7 @@ public function testModerationForm() { $this->drupalGet($latest_version_path); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldExists('edit-new-state'); - $this->assertText('Draft'); + $this->assertSession()->pageTextContains('Draft'); // Submit the moderation form to change status to published. $this->drupalPostForm($latest_version_path, [ @@ -229,8 +229,8 @@ public function testNonBundleModerationForm() { // status, because the pending revision is in "Draft". $this->drupalGet('entity_test_mulrevpub/manage/1/latest'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Moderation state'); - $this->assertText('Draft'); + $this->assertSession()->pageTextContains('Moderation state'); + $this->assertSession()->pageTextContains('Draft'); // Submit the moderation form to change status to published. $this->drupalPostForm('entity_test_mulrevpub/manage/1/latest', [ @@ -263,7 +263,7 @@ public function testModerationFormSetsRevisionAuthor() { ], 'Apply'); $this->drupalGet(sprintf('node/%d/revisions', $node->id())); - $this->assertText('by ' . $another_user->getAccountName()); + $this->assertSession()->pageTextContains('by ' . $another_user->getAccountName()); // Verify the revision creation time has been updated. $node = $node->load($node->id()); diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php index 7c5c4773f713..88b05f89ccdf 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php @@ -72,7 +72,7 @@ public function testTranslateModeratedContent() { 'moderation_state[0][state]' => 'published', ]; $this->drupalPostForm('node/add/article', $edit, 'Save'); - $this->assertText('Article Published English node has been created.'); + $this->assertSession()->pageTextContains('Article Published English node has been created.'); $english_node = $this->drupalGetNodeByTitle('Published English node'); // Add a French translation. @@ -86,7 +86,7 @@ public function testTranslateModeratedContent() { // Here the error has occurred "The website encountered an unexpected error. // Please try again later." // If the translation has got lost. - $this->assertText('Article French node Draft has been updated.'); + $this->assertSession()->pageTextContains('Article French node Draft has been updated.'); // Create an article in English. $edit = [ @@ -95,7 +95,7 @@ public function testTranslateModeratedContent() { 'moderation_state[0][state]' => 'draft', ]; $this->drupalPostForm('node/add/article', $edit, 'Save'); - $this->assertText('Article English node has been created.'); + $this->assertSession()->pageTextContains('Article English node has been created.'); $english_node = $this->drupalGetNodeByTitle('English node'); // Add a French translation. @@ -106,7 +106,7 @@ public function testTranslateModeratedContent() { 'moderation_state[0][state]' => 'draft', ]; $this->submitForm($edit, 'Save (this translation)'); - $this->assertText('Article French node has been updated.'); + $this->assertSession()->pageTextContains('Article French node has been updated.'); $english_node = $this->drupalGetNodeByTitle('English node', TRUE); // Publish the English article and check that the translation stays @@ -114,7 +114,7 @@ public function testTranslateModeratedContent() { $this->drupalPostForm('node/' . $english_node->id() . '/edit', [ 'moderation_state[0][state]' => 'published', ], 'Save (this translation)'); - $this->assertText('Article English node has been updated.'); + $this->assertSession()->pageTextContains('Article English node has been updated.'); $english_node = $this->drupalGetNodeByTitle('English node', TRUE); $french_node = $english_node->getTranslation('fr'); $this->assertEquals('French node', $french_node->label()); @@ -131,7 +131,7 @@ public function testTranslateModeratedContent() { 'moderation_state[0][state]' => 'draft', ]; $this->drupalPostForm('node/add/article', $edit, 'Save'); - $this->assertText('Article Another node has been created.'); + $this->assertSession()->pageTextContains('Article Another node has been created.'); $english_node = $this->drupalGetNodeByTitle('Another node'); // Add a French translation. @@ -142,7 +142,7 @@ public function testTranslateModeratedContent() { 'moderation_state[0][state]' => 'draft', ]; $this->submitForm($edit, 'Save (this translation)'); - $this->assertText('Article Translated node has been updated.'); + $this->assertSession()->pageTextContains('Article Translated node has been updated.'); $english_node = $this->drupalGetNodeByTitle('Another node', TRUE); // Publish the translation and check that the source language version stays @@ -150,7 +150,7 @@ public function testTranslateModeratedContent() { $this->drupalPostForm('fr/node/' . $english_node->id() . '/edit', [ 'moderation_state[0][state]' => 'published', ], 'Save (this translation)'); - $this->assertText('Article Translated node has been updated.'); + $this->assertSession()->pageTextContains('Article Translated node has been updated.'); $english_node = $this->drupalGetNodeByTitle('Another node', TRUE); $french_node = $english_node->getTranslation('fr'); $this->assertEquals('published', $french_node->moderation_state->value); @@ -164,7 +164,7 @@ public function testTranslateModeratedContent() { 'moderation_state[0][state]' => 'draft', ]; $this->drupalPostForm('fr/node/' . $english_node->id() . '/edit', $edit, 'Save (this translation)'); - $this->assertText('Article New draft of translated node has been updated.'); + $this->assertSession()->pageTextContains('Article New draft of translated node has been updated.'); $english_node = $this->drupalGetNodeByTitle('Another node', TRUE); $french_node = $english_node->getTranslation('fr'); $this->assertEquals('published', $french_node->moderation_state->value); @@ -175,7 +175,7 @@ public function testTranslateModeratedContent() { $this->drupalPostForm('fr/node/' . $english_node->id() . '/edit', [ 'moderation_state[0][state]' => 'published', ], 'Save (this translation)'); - $this->assertText('Article New draft of translated node has been updated.'); + $this->assertSession()->pageTextContains('Article New draft of translated node has been updated.'); $english_node = $this->drupalGetNodeByTitle('Another node', TRUE); $french_node = $english_node->getTranslation('fr'); $this->assertEquals('published', $french_node->moderation_state->value); @@ -186,7 +186,7 @@ public function testTranslateModeratedContent() { $this->drupalPostForm('node/' . $english_node->id() . '/edit', [ 'moderation_state[0][state]' => 'published', ], 'Save (this translation)'); - $this->assertText('Article Another node has been updated.'); + $this->assertSession()->pageTextContains('Article Another node has been updated.'); $english_node = $this->drupalGetNodeByTitle('Another node', TRUE); $this->assertEquals('published', $english_node->moderation_state->value); @@ -194,11 +194,11 @@ public function testTranslateModeratedContent() { $this->drupalPostForm('node/' . $english_node->id() . '/edit', [ 'moderation_state[0][state]' => 'archived', ], 'Save (this translation)'); - $this->assertText('Article Another node has been updated.'); + $this->assertSession()->pageTextContains('Article Another node has been updated.'); $this->drupalPostForm('fr/node/' . $english_node->id() . '/edit', [ 'moderation_state[0][state]' => 'archived', ], 'Save (this translation)'); - $this->assertText('Article New draft of translated node has been updated.'); + $this->assertSession()->pageTextContains('Article New draft of translated node has been updated.'); $english_node = $this->drupalGetNodeByTitle('Another node', TRUE); $french_node = $english_node->getTranslation('fr'); $this->assertEquals('archived', $english_node->moderation_state->value); diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php index a2062ebc9492..92e3a94024cb 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateBlockTest.php @@ -68,7 +68,7 @@ public function testCustomBlockModeration() { 'body[0][value]' => $body, ]; $this->drupalPostForm('block/add', $edit, 'Save'); - $this->assertText('basic Moderated block has been created.'); + $this->assertSession()->pageTextContains('basic Moderated block has been created.'); // Place the block in the Sidebar First region. $instance = [ @@ -83,7 +83,7 @@ public function testCustomBlockModeration() { // Navigate to home page and check that the block is visible. It should be // visible because it is the default revision. $this->drupalGet(''); - $this->assertText($body); + $this->assertSession()->pageTextContains($body); // Update the block. $updated_body = 'This is the new body value'; @@ -92,13 +92,13 @@ public function testCustomBlockModeration() { 'moderation_state[0][state]' => 'draft', ]; $this->drupalPostForm('block/' . $block->id(), $edit, 'Save'); - $this->assertText('basic Moderated block has been updated.'); + $this->assertSession()->pageTextContains('basic Moderated block has been updated.'); // Navigate to the home page and check that the block shows the updated // content. It should show the updated content because the block's default // revision is not a published moderation state. $this->drupalGet(''); - $this->assertText($updated_body); + $this->assertSession()->pageTextContains($updated_body); // Publish the block so we can create a pending revision. $this->drupalPostForm('block/' . $block->id(), [ @@ -112,30 +112,30 @@ public function testCustomBlockModeration() { 'moderation_state[0][state]' => 'draft', ]; $this->drupalPostForm('block/' . $block->id(), $edit, 'Save'); - $this->assertText('basic Moderated block has been updated.'); + $this->assertSession()->pageTextContains('basic Moderated block has been updated.'); // Navigate to home page and check that the pending revision doesn't show, // since it should not be set as the default revision. $this->drupalGet(''); - $this->assertText($updated_body); + $this->assertSession()->pageTextContains($updated_body); // Open the latest tab and publish the new draft. $edit = [ 'new_state' => 'published', ]; $this->drupalPostForm('block/' . $block->id() . '/latest', $edit, 'Apply'); - $this->assertText('The moderation state has been updated.'); + $this->assertSession()->pageTextContains('The moderation state has been updated.'); // Navigate to home page and check that the pending revision is now the // default revision and therefore visible. $this->drupalGet(''); - $this->assertText($pending_revision_body); + $this->assertSession()->pageTextContains($pending_revision_body); // Check that revision is checked by default when content moderation is // enabled. $this->drupalGet('/block/' . $block->id()); $this->assertSession()->checkboxChecked('revision'); - $this->assertText('Revisions must be required when moderation is enabled.'); + $this->assertSession()->pageTextContains('Revisions must be required when moderation is enabled.'); $this->assertSession()->fieldDisabled('revision'); } diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php index bf434d63b976..5b4ec6cea771 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php @@ -57,7 +57,7 @@ public function testCreatingContent() { // Delete the node. $this->drupalPostForm('node/' . $node->id() . '/delete', [], 'Delete'); - $this->assertText('The Moderated content moderated content has been deleted.'); + $this->assertSession()->pageTextContains('The Moderated content moderated content has been deleted.'); // Disable content moderation. $edit['bundles[moderated_content]'] = FALSE; @@ -96,7 +96,7 @@ public function testFormSaveDestination() { // After saving, we should be at the canonical URL and viewing the first // revision. $this->assertSession()->addressEquals(Url::fromRoute('entity.node.canonical', ['node' => $node->id()])); - $this->assertText('First version of the content.'); + $this->assertSession()->pageTextContains('First version of the content.'); // Create a new draft; after saving, we should still be on the canonical // URL, but viewing the second revision. @@ -105,7 +105,7 @@ public function testFormSaveDestination() { 'moderation_state[0][state]' => 'draft', ], 'Save'); $this->assertSession()->addressEquals(Url::fromRoute('entity.node.canonical', ['node' => $node->id()])); - $this->assertText('Second version of the content.'); + $this->assertSession()->pageTextContains('Second version of the content.'); // Make a new published revision; after saving, we should be at the // canonical URL. @@ -114,7 +114,7 @@ public function testFormSaveDestination() { 'moderation_state[0][state]' => 'published', ], 'Save'); $this->assertSession()->addressEquals(Url::fromRoute('entity.node.canonical', ['node' => $node->id()])); - $this->assertText('Third version of the content.'); + $this->assertSession()->pageTextContains('Third version of the content.'); // Make a new pending revision; after saving, we should be on the "Latest // version" tab. @@ -123,7 +123,7 @@ public function testFormSaveDestination() { 'moderation_state[0][state]' => 'draft', ], 'Save'); $this->assertSession()->addressEquals(Url::fromRoute('entity.node.latest_version', ['node' => $node->id()])); - $this->assertText('Fourth version of the content.'); + $this->assertSession()->pageTextContains('Fourth version of the content.'); } /** diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php index a26d304ec63b..c72e879e6244 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php @@ -23,14 +23,14 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase { public function testNotModerated() { $this->drupalLogin($this->adminUser); $this->createContentTypeFromUi('Not moderated', 'not_moderated'); - $this->assertText('The content type Not moderated has been added.'); + $this->assertSession()->pageTextContains('The content type Not moderated has been added.'); $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'not_moderated'); $this->drupalGet('node/add/not_moderated'); $this->assertRaw('Save'); $this->submitForm([ 'title[0][value]' => 'Test', ], 'Save'); - $this->assertText('Not moderated Test has been created.'); + $this->assertSession()->pageTextContains('Not moderated Test has been created.'); } /** @@ -65,7 +65,7 @@ public function testEnablingOnExistingContent() { $this->submitForm([ 'title[0][value]' => 'Test', ], 'Save'); - $this->assertText('Not moderated Test has been created.'); + $this->assertSession()->pageTextContains('Not moderated Test has been created.'); // Check that the 'Create new revision' is not disabled. $this->drupalGet('/admin/structure/types/manage/not_moderated'); diff --git a/core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php b/core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php index 291c41f04adb..dcaaf7ef8888 100644 --- a/core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php +++ b/core/modules/content_moderation/tests/src/Functional/WorkspaceContentModerationIntegrationTest.php @@ -81,7 +81,7 @@ public function testModerationInWorkspace() { ], 'Save'); $this->drupalGet('/node/1'); - $this->assertText('First article - draft'); + $this->assertSession()->pageTextContains('First article - draft'); $this->drupalGet('/node/1/edit'); $this->assertEquals('Current state Draft', $this->cssSelect('#edit-moderation-state-0-current')[0]->getText()); @@ -97,7 +97,7 @@ public function testModerationInWorkspace() { ], 'Save'); $this->drupalGet('/node/1'); - $this->assertText('First article - archived'); + $this->assertSession()->pageTextContains('First article - archived'); // Get the second node to a default revision state and publish the // workspace. @@ -110,10 +110,10 @@ public function testModerationInWorkspace() { // The admin user can see unpublished nodes. $this->drupalGet('/node/1'); - $this->assertText('First article - archived'); + $this->assertSession()->pageTextContains('First article - archived'); $this->drupalGet('/node/2'); - $this->assertText('Second article - published'); + $this->assertSession()->pageTextContains('Second article - published'); } } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php index b05ad554c606..7ef80110b8bc 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php @@ -35,8 +35,8 @@ public function testEnable() { $this->drupalPostForm('admin/modules', $edit, 'Install'); // Status messages are shown. - $this->assertText('This site has only a single language enabled. Add at least one more language in order to translate content.'); - $this->assertText('Enable translation for content types, taxonomy vocabularies, accounts, or any other element you wish to translate.'); + $this->assertSession()->pageTextContains('This site has only a single language enabled. Add at least one more language in order to translate content.'); + $this->assertSession()->pageTextContains('Enable translation for content types, taxonomy vocabularies, accounts, or any other element you wish to translate.'); // No pending updates should be available. $this->drupalGet('admin/reports/status'); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php index cad90c9c8292..d79d96ee5db2 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php @@ -70,7 +70,7 @@ public function testSettingsUI() { // Check for the content_translation_menu_links_discovered_alter() changes. $this->drupalGet('admin/config'); $this->assertSession()->linkExists('Content language and translation'); - $this->assertText('Configure language and translation support for content.'); + $this->assertSession()->pageTextContains('Configure language and translation support for content.'); // Test that the translation settings are ignored if the bundle is marked // translatable but the entity type is not. $edit = ['settings[comment][comment_article][translatable]' => TRUE]; @@ -241,7 +241,7 @@ public function testAccountLanguageSettingsUI() { // Make sure account settings can be saved. $this->drupalPostForm('admin/config/people/accounts', ['anonymous' => 'Save me please!'], 'Save configuration'); $this->assertSession()->fieldValueEquals('anonymous', 'Save me please!'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); } /** @@ -285,7 +285,7 @@ public function testFieldTranslatableSettingsUI() { $path = 'admin/structure/types/manage/article/fields/node.article.field_article_text'; $this->drupalGet($path); $this->assertSession()->fieldDisabled('edit-translatable'); - $this->assertText('To configure translation for this field, enable language support for this type.'); + $this->assertSession()->pageTextContains('To configure translation for this field, enable language support for this type.'); // Tests that field has translatable setting if bundle is translatable. // Note: this field is not translatable when enable bundle translatability. diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php index 765a4bac6dda..960e0e06a1bc 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUISkipTest.php @@ -37,8 +37,8 @@ public function testUICheckSkip() { $this->drupalGet('admin/config/regional/content-language'); // Check the message regarding UI integration. - $this->assertText('Test entity - Translatable skip UI check'); - $this->assertText('Test entity - Translatable check UI (Translation is not supported)'); + $this->assertSession()->pageTextContains('Test entity - Translatable skip UI check'); + $this->assertSession()->pageTextContains('Test entity - Translatable check UI (Translation is not supported)'); } } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php index 03d65ccce3dc..4546d5143520 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php @@ -194,7 +194,7 @@ protected function doTestBasicTranslation() { $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); $this->drupalGet($entity->toUrl('drupal:content-translation-overview')); - $this->assertText('Source language'); + $this->assertSession()->pageTextContains('Source language'); // Check that the entered values have been correctly stored. foreach ($values as $langcode => $property_values) { diff --git a/core/modules/datetime/tests/src/Functional/DateFilterTest.php b/core/modules/datetime/tests/src/Functional/DateFilterTest.php index 9f9e197d437e..3048f44080ce 100644 --- a/core/modules/datetime/tests/src/Functional/DateFilterTest.php +++ b/core/modules/datetime/tests/src/Functional/DateFilterTest.php @@ -119,7 +119,7 @@ public function testLimitExposedOperators() { $edit['options[operator]'] = '='; $edit['options[expose][operator_list][]'] = ['<', '>']; $this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_filter_datetime/default/filter/field_date_value', $edit, 'Apply'); - $this->assertText('You selected the "Is equal to" operator as the default value but is not included in the list of limited operators.'); + $this->assertSession()->pageTextContains('You selected the "Is equal to" operator as the default value but is not included in the list of limited operators.'); } } diff --git a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php index d3851669f472..388dc98f4ec5 100644 --- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php +++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php @@ -77,7 +77,7 @@ public function testDateField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($date->format($date_format)); $this->assertNoRaw($date->format($time_format)); @@ -272,7 +272,7 @@ public function testDatetimeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($date->format($date_format)); $this->assertRaw($date->format($time_format)); @@ -499,7 +499,7 @@ public function testDatelistWidget() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected()); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected()); @@ -539,7 +539,7 @@ public function testDatelistWidget() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected()); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected()); @@ -576,7 +576,7 @@ public function testDatelistWidget() { $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); foreach ($expected as $expected_text) { - $this->assertText($expected_text); + $this->assertSession()->pageTextContains($expected_text); } } @@ -593,7 +593,7 @@ public function testDatelistWidget() { $this->assertSession()->statusCodeEquals(200); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Test the widget to ensure zeros are not deselected on validation. $this->drupalGet('entity_test/add'); @@ -728,7 +728,7 @@ public function testDefaultValue() { ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, 'Save settings'); - $this->assertText('The relative date value entered is invalid.'); + $this->assertSession()->pageTextContains('The relative date value entered is invalid.'); // Set a relative default_value. $field_edit = [ @@ -805,7 +805,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid year value. $date_value = 'aaaa-12-01'; @@ -814,7 +814,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => '00:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid month value. $date_value = '2012-75-01'; @@ -823,7 +823,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => '00:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid day value. $date_value = '2012-12-99'; @@ -832,7 +832,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => '00:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid time value. $date_value = '2012-12-01'; @@ -842,7 +842,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid hour value. $date_value = '2012-12-01'; @@ -852,7 +852,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid minutes value. $date_value = '2012-12-01'; @@ -862,7 +862,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid seconds value. $date_value = '2012-12-01'; @@ -872,7 +872,7 @@ public function testInvalidField() { "{$field_name}[0][value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); } /** @@ -915,7 +915,7 @@ public function testDateStorageSettings() { $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name . '/storage'); $result = $this->xpath("//*[@id='edit-settings-datetime-type' and contains(@disabled, 'disabled')]"); $this->assertCount(1, $result, "Changing datetime setting is disabled."); - $this->assertText('There is data for this field in the database. The field settings can no longer be changed.'); + $this->assertSession()->pageTextContains('There is data for this field in the database. The field settings can no longer be changed.'); } } diff --git a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php index 71560a3e17c4..ebc0caa21dea 100644 --- a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php +++ b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php @@ -92,7 +92,7 @@ public function testDateRangeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($start_date->format($date_format)); $this->assertNoRaw($start_date->format($time_format)); $this->assertRaw($end_date->format($date_format)); @@ -218,7 +218,7 @@ public function testDateRangeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->massageTestDate($start_date); @@ -325,7 +325,7 @@ public function testDatetimeRangeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($start_date->format($date_format)); $this->assertRaw($start_date->format($time_format)); $this->assertRaw($end_date->format($date_format)); @@ -410,7 +410,7 @@ public function testDatetimeRangeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->displayOptions = [ 'type' => 'daterange_default', @@ -498,7 +498,7 @@ public function testAlldayRangeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($start_date->format($date_format)); $this->assertNoRaw($start_date->format($time_format)); $this->assertRaw($end_date->format($date_format)); @@ -582,7 +582,7 @@ public function testAlldayRangeField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->displayOptions = [ 'type' => 'daterange_default', @@ -770,7 +770,7 @@ public function testDatelistWidget() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected()); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected()); @@ -825,7 +825,7 @@ public function testDatelistWidget() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected()); $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected()); @@ -871,7 +871,7 @@ public function testDatelistWidget() { $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); foreach ($expected as $expected_text) { - $this->assertText($expected_text); + $this->assertSession()->pageTextContains($expected_text); } } @@ -892,7 +892,7 @@ public function testDatelistWidget() { $this->assertSession()->statusCodeEquals(200); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Test the widget to ensure zeros are not deselected on validation. $this->drupalGet('entity_test/add'); @@ -1052,7 +1052,7 @@ public function testDefaultValue() { 'default_value_input[default_end_date]' => '+1 day', ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, 'Save settings'); - $this->assertText('The relative start date value entered is invalid.'); + $this->assertSession()->pageTextContains('The relative start date value entered is invalid.'); $field_edit = [ 'default_value_input[default_date_type]' => 'relative', @@ -1061,7 +1061,7 @@ public function testDefaultValue() { 'default_value_input[default_end_date]' => 'invalid date', ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, 'Save settings'); - $this->assertText('The relative end date value entered is invalid.'); + $this->assertSession()->pageTextContains('The relative end date value entered is invalid.'); // Set a relative default_value. $field_edit = [ @@ -1181,7 +1181,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid year value. $date_value = 'aaaa-12-01'; @@ -1192,7 +1192,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid month value. $date_value = '2012-75-01'; @@ -1203,7 +1203,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid day value. $date_value = '2012-12-99'; @@ -1214,7 +1214,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Submit invalid start times and ensure they is not accepted. $time_value = ''; @@ -1225,7 +1225,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid hour value. $time_value = '49:00:00'; @@ -1236,7 +1236,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid minutes value. $time_value = '12:99:00'; @@ -1247,7 +1247,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid seconds value. $time_value = '12:15:99'; @@ -1258,7 +1258,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Submit invalid end dates and ensure they is not accepted. $date_value = ''; @@ -1269,7 +1269,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid year value. $date_value = 'aaaa-12-01'; @@ -1280,7 +1280,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '00:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid month value. $date_value = '2012-75-01'; @@ -1291,7 +1291,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '00:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid day value. $date_value = '2012-12-99'; @@ -1302,7 +1302,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '00:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Submit invalid start times and ensure they is not accepted. $time_value = ''; @@ -1313,7 +1313,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid hour value. $time_value = '49:00:00'; @@ -1324,7 +1324,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid minutes value. $time_value = '12:99:00'; @@ -1335,7 +1335,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // Invalid seconds value. $time_value = '12:15:99'; @@ -1346,7 +1346,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => $time_value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('date is invalid'); + $this->assertSession()->pageTextContains('date is invalid'); // End date before start date. $edit = [ @@ -1356,7 +1356,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '12:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('The ' . $field_label . ' end date cannot be before the start date'); + $this->assertSession()->pageTextContains('The ' . $field_label . ' end date cannot be before the start date'); // End date before start date. $edit = [ @@ -1366,7 +1366,7 @@ public function testInvalidField() { "{$field_name}[0][end_value][time]" => '11:00:00', ]; $this->submitForm($edit, 'Save'); - $this->assertText('The ' . $field_label . ' end date cannot be before the start date'); + $this->assertSession()->pageTextContains('The ' . $field_label . ' end date cannot be before the start date'); } /** @@ -1410,7 +1410,7 @@ public function testDateStorageSettings() { $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name . '/storage'); $result = $this->xpath("//*[@id='edit-settings-datetime-type' and contains(@disabled, 'disabled')]"); $this->assertCount(1, $result, "Changing datetime setting is disabled."); - $this->assertText('There is data for this field in the database. The field settings can no longer be changed.'); + $this->assertSession()->pageTextContains('There is data for this field in the database. The field settings can no longer be changed.'); } } diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php index 3eea9d2956b2..18ca0a74d224 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php @@ -139,7 +139,7 @@ public function testLogEventPage() { $this->assertRaw($context['request_uri']); // Verify severity. - $this->assertText('Notice'); + $this->assertSession()->pageTextContains('Notice'); } /** @@ -219,10 +219,10 @@ public function testLogEventPageWithMissingInfo() { $this->drupalGet('admin/reports/dblog/event/' . $wid); // Verify table headers are present, even though the referrer is missing. - $this->assertText('Referrer'); + $this->assertSession()->pageTextContains('Referrer'); // Verify severity. - $this->assertText('Notice'); + $this->assertSession()->pageTextContains('Notice'); // Test log event page with incorrect location. $request_uri = '/some/incorrect/url'; @@ -235,10 +235,10 @@ public function testLogEventPageWithMissingInfo() { $this->drupalGet('admin/reports/dblog/event/' . $wid); // Verify table headers are present. - $this->assertText('Location'); + $this->assertSession()->pageTextContains('Location'); // Verify severity. - $this->assertText('Notice'); + $this->assertSession()->pageTextContains('Notice'); // Verify location is available as plain text. $this->assertEquals($request_uri, $this->cssSelect('table.dblog-event > tbody > tr:nth-child(4) > td')[0]->getHtml()); @@ -300,34 +300,34 @@ private function verifyReports($response = 200) { $this->drupalGet('admin/help/dblog'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Database Logging'); + $this->assertSession()->pageTextContains('Database Logging'); } // View the database log report page. $this->drupalGet('admin/reports/dblog'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Recent log messages'); + $this->assertSession()->pageTextContains('Recent log messages'); } $this->drupalGet('admin/reports/dblog/confirm'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Are you sure you want to delete the recent logs?'); + $this->assertSession()->pageTextContains('Are you sure you want to delete the recent logs?'); } // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText("Top 'page not found' errors"); + $this->assertSession()->pageTextContains("Top 'page not found' errors"); } // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText("Top 'access denied' errors"); + $this->assertSession()->pageTextContains("Top 'access denied' errors"); } // View the database log event page. @@ -337,7 +337,7 @@ private function verifyReports($response = 200) { $this->drupalGet('admin/reports/dblog/event/' . $wid); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Details'); + $this->assertSession()->pageTextContains('Details'); } } @@ -382,7 +382,7 @@ private function verifyEvents() { public function verifySort($sort = 'asc', $order = 'Date') { $this->drupalGet('admin/reports/dblog', ['query' => ['sort' => $sort, 'order' => $order]]); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Recent log messages'); + $this->assertSession()->pageTextContains('Recent log messages'); } /** @@ -482,7 +482,7 @@ private function doUser() { $this->drupalGet('admin/reports/page-not-found'); $this->assertSession()->statusCodeEquals(200); // Check that full-length URL displayed. - $this->assertText($not_found_url); + $this->assertSession()->pageTextContains($not_found_url); } /** @@ -539,13 +539,13 @@ private function doNode($type) { $this->drupalGet('admin/reports/access-denied'); $this->assertSession()->statusCodeEquals(200); // Verify that the 'access denied' event was recorded. - $this->assertText('admin/reports/dblog'); + $this->assertSession()->pageTextContains('admin/reports/dblog'); // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); $this->assertSession()->statusCodeEquals(200); // Verify that the 'page not found' event was recorded. - $this->assertText('node/' . $node->id()); + $this->assertSession()->pageTextContains('node/' . $node->id()); } /** @@ -696,13 +696,13 @@ public function testFilter() { $this->drupalGet('admin/reports/dblog', ['query' => ['order' => 'Type']]); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Operations'); + $this->assertSession()->pageTextContains('Operations'); // Clear all logs and make sure the confirmation message is found. $this->clearLogsEntries(); // Confirm that the logs should be cleared. $this->submitForm([], 'Confirm'); - $this->assertText('Database log cleared.'); + $this->assertSession()->pageTextContains('Database log cleared.'); } /** @@ -822,7 +822,7 @@ public function testTemporaryUser() { // Check if the full message displays on the details page. $this->drupalGet('admin/reports/dblog/event/' . $wid); - $this->assertText('Dblog test log message'); + $this->assertSession()->pageTextContains('Dblog test log message'); // Delete the user. $tempuser->delete(); @@ -831,7 +831,7 @@ public function testTemporaryUser() { // Check if the full message displays on the details page. $this->drupalGet('admin/reports/dblog/event/' . $wid); - $this->assertText('Dblog test log message'); + $this->assertSession()->pageTextContains('Dblog test log message'); } /** diff --git a/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php b/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php index 52cd6ba9968e..69abdc30c0af 100644 --- a/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php +++ b/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php @@ -107,7 +107,7 @@ public function testBooleanField() { // Display creation form. $this->drupalGet('entity_test/add'); $this->assertSession()->fieldValueEquals("{$field_name}[value]", ''); - $this->assertText($this->field->label()); + $this->assertSession()->pageTextContains($this->field->label()); $this->assertNoRaw($on); // Submit and ensure it is accepted. @@ -117,7 +117,7 @@ public function testBooleanField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Verify that boolean value is displayed. $entity = EntityTest::load($id); @@ -157,7 +157,7 @@ public function testBooleanField() { // Click on the widget settings button to open the widget settings form. $this->submitForm([], $field_name . "_settings_edit"); - $this->assertText('Use field label instead of the "On" label as the label.'); + $this->assertSession()->pageTextContains('Use field label instead of the "On" label as the label.'); // Enable setting. $edit = ['fields[' . $field_name . '][settings_edit_form][settings][display_label]' => 1]; @@ -167,10 +167,10 @@ public function testBooleanField() { // Go again to the form display page and check if the setting // is stored and has the expected effect. $this->drupalGet($fieldEditUrl); - $this->assertText('Use field label: Yes'); + $this->assertSession()->pageTextContains('Use field label: Yes'); $this->submitForm([], $field_name . "_settings_edit"); - $this->assertText('Use field label instead of the "On" label as the label.'); + $this->assertSession()->pageTextContains('Use field label instead of the "On" label as the label.'); $this->getSession()->getPage()->hasCheckedField('fields[' . $field_name . '][settings_edit_form][settings][display_label]'); // Test the boolean field settings. @@ -230,7 +230,7 @@ public function testFormAccess() { $this->submitForm([], 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Tell the test module to disable access to the field. \Drupal::state()->set('field.test_boolean_field_access_field', $field_name); @@ -241,7 +241,7 @@ public function testFormAccess() { $this->submitForm([], 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); } } diff --git a/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php b/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php index fdeced892aa2..09ad6ff24811 100644 --- a/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php +++ b/core/modules/field/tests/src/Functional/Email/EmailFieldTest.php @@ -100,7 +100,7 @@ public function testEmailField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($value); // Verify that a mailto link is displayed. diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php index 08c38705093e..5431c493ee41 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php @@ -173,7 +173,7 @@ public function testFieldAdminHandler() { $this->drupalPostForm('node/add/' . $this->type, $edit, 'Save'); // Assert that entity reference autocomplete field is validated. - $this->assertText('There are no content items matching "Test"'); + $this->assertSession()->pageTextContains('There are no content items matching "Test"'); $edit = [ 'title[0][value]' => 'Test', @@ -183,10 +183,10 @@ public function testFieldAdminHandler() { // Assert the results multiple times to avoid sorting problem of nodes with // the same title. - $this->assertText('Multiple content items match this reference;'); - $this->assertText($node1->getTitle() . ' (' . $node1->id() . ')'); - $this->assertText($node2->getTitle() . ' (' . $node2->id() . ')'); - $this->assertText('Specify the one you want by appending the id in parentheses, like "' . $node2->getTitle() . ' (' . $node2->id() . ')' . '".'); + $this->assertSession()->pageTextContains('Multiple content items match this reference;'); + $this->assertSession()->pageTextContains($node1->getTitle() . ' (' . $node1->id() . ')'); + $this->assertSession()->pageTextContains($node2->getTitle() . ' (' . $node2->id() . ')'); + $this->assertSession()->pageTextContains('Specify the one you want by appending the id in parentheses, like "' . $node2->getTitle() . ' (' . $node2->id() . ')' . '".'); $edit = [ 'title[0][value]' => 'Test', diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php index cd2bc1c36da1..64d776fc5279 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php @@ -145,8 +145,8 @@ public function testAutoCreate() { // Now try to view the node and check that the referenced node is shown. $this->drupalGet('node/' . $referencing_node->id()); - $this->assertText($referencing_node->label()); - $this->assertText($referenced_node->label()); + $this->assertSession()->pageTextContains($referencing_node->label()); + $this->assertSession()->pageTextContains($referenced_node->label()); } /** diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php index d1ea6b56c90e..2e0286c5ea4a 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php @@ -180,13 +180,13 @@ protected function assertEntityReferenceDisplay() { $translation_url = $this->referrerEntity->toUrl('canonical', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]); $this->drupalGet($url); - $this->assertText($this->labelOfNotTranslatedReference); - $this->assertText($this->originalLabel); + $this->assertSession()->pageTextContains($this->labelOfNotTranslatedReference); + $this->assertSession()->pageTextContains($this->originalLabel); $this->assertNoText($this->translatedLabel); $this->drupalGet($translation_url); - $this->assertText($this->labelOfNotTranslatedReference); + $this->assertSession()->pageTextContains($this->labelOfNotTranslatedReference); $this->assertNoText($this->originalLabel); - $this->assertText($this->translatedLabel); + $this->assertSession()->pageTextContains($this->translatedLabel); } /** diff --git a/core/modules/field/tests/src/Functional/FieldAccessTest.php b/core/modules/field/tests/src/Functional/FieldAccessTest.php index 4070f6eb3907..d28dd2734e67 100644 --- a/core/modules/field/tests/src/Functional/FieldAccessTest.php +++ b/core/modules/field/tests/src/Functional/FieldAccessTest.php @@ -85,7 +85,7 @@ public function testFieldAccess() { // Assert the text is visible. $this->drupalGet('node/' . $this->node->id()); - $this->assertText($this->testViewFieldValue); + $this->assertSession()->pageTextContains($this->testViewFieldValue); // Assert the text is not visible for anonymous users. // The field_test module implements hook_entity_field_access() which will diff --git a/core/modules/field/tests/src/Functional/FieldHelpTest.php b/core/modules/field/tests/src/Functional/FieldHelpTest.php index 3de717969ea7..e114e3031c3c 100644 --- a/core/modules/field/tests/src/Functional/FieldHelpTest.php +++ b/core/modules/field/tests/src/Functional/FieldHelpTest.php @@ -55,7 +55,7 @@ public function testFieldHelp() { $this->assertSession()->linkExists('Options', 0, 'Options module is listed on the Field help page.'); // Verify that modules with field types that do not implement hook_help are // listed. - $this->assertText('Field API Test'); + $this->assertSession()->pageTextContains('Field API Test'); $this->assertSession()->linkNotExists('Field API Test', 'Modules with field types that do not implement hook_help are not linked.'); $this->assertSession()->linkNotExists('Link', 'Modules that have not been installed, are not listed.'); } diff --git a/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php b/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php index 860aadee44e0..c2f9a51ba24d 100644 --- a/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php @@ -104,7 +104,7 @@ public function testImportDeleteUninstall() { $this->drupalGet('admin/config/development/configuration'); // Test that the message for one field being purged during a configuration // synchronization is correct. - $this->assertText('This synchronization will delete data from the field entity_test.field_tel.'); + $this->assertSession()->pageTextContains('This synchronization will delete data from the field entity_test.field_tel.'); // Stage an uninstall of the datetime module to test the message for // multiple fields. @@ -112,7 +112,7 @@ public function testImportDeleteUninstall() { $sync->write('core.extension', $core_extension); $this->drupalGet('admin/config/development/configuration'); - $this->assertText('This synchronization will delete data from the fields: entity_test.field_tel, entity_test.field_date.'); + $this->assertSession()->pageTextContains('This synchronization will delete data from the fields: entity_test.field_tel, entity_test.field_date.'); // This will purge all the data, delete the field and uninstall the // Telephone and Text modules. diff --git a/core/modules/field/tests/src/Functional/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php index 04b2783d8aa5..15f91e9fa0ba 100644 --- a/core/modules/field/tests/src/Functional/FormTest.php +++ b/core/modules/field/tests/src/Functional/FormTest.php @@ -121,7 +121,7 @@ public function testFieldFormSingle() { // Create token value expected for description. $token_description = Html::escape($this->config('system.site')->get('name')) . '_description'; - $this->assertText($token_description); + $this->assertSession()->pageTextContains($token_description); $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", ''); // Verify that no extraneous widget is displayed. $this->assertSession()->fieldNotExists("{$field_name}[1][value]"); @@ -149,7 +149,7 @@ public function testFieldFormSingle() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $entity = EntityTest::load($id); $this->assertEquals($value, $entity->{$field_name}->value, 'Field value was saved'); @@ -166,7 +166,7 @@ public function testFieldFormSingle() { "{$field_name}[0][value]" => $value, ]; $this->submitForm($edit, 'Save'); - $this->assertText('entity_test ' . $id . ' has been updated.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been updated.'); $this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]); $entity = EntityTest::load($id); $this->assertEquals($value, $entity->{$field_name}->value, 'Field value was updated'); @@ -177,7 +177,7 @@ public function testFieldFormSingle() { "{$field_name}[0][value]" => $value, ]; $this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, 'Save'); - $this->assertText('entity_test ' . $id . ' has been updated.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been updated.'); $this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]); $entity = EntityTest::load($id); $this->assertTrue($entity->{$field_name}->isEmpty(), 'Field was emptied'); @@ -211,7 +211,7 @@ public function testFieldFormDefaultValue() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $entity = EntityTest::load($id); $this->assertTrue($entity->{$field_name}->isEmpty(), 'Field is now empty.'); } @@ -241,7 +241,7 @@ public function testFieldFormSingleRequired() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $entity = EntityTest::load($id); $this->assertEquals($value, $entity->{$field_name}->value, 'Field value was saved'); @@ -327,7 +327,7 @@ public function testFieldFormUnlimited() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $entity = EntityTest::load($id); ksort($field_values); $field_values = array_values($field_values); @@ -601,7 +601,7 @@ public function testHiddenField() { $this->submitForm([], 'Save'); preg_match('|' . $entity_type . '/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test_rev ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test_rev ' . $id . ' has been created.'); $storage = $this->container->get('entity_type.manager') ->getStorage($entity_type); @@ -627,7 +627,7 @@ public function testHiddenField() { $value = mt_rand(1, 127); $edit = ["{$field_name}[0][value]" => $value]; $this->submitForm($edit, 'Save'); - $this->assertText('entity_test_rev ' . $id . ' has been updated.'); + $this->assertSession()->pageTextContains('entity_test_rev ' . $id . ' has been updated.'); $storage->resetCache([$id]); $entity = $storage->load($id); $this->assertEquals($value, $entity->{$field_name}->value, 'Field value was updated'); @@ -679,7 +679,7 @@ public function testLabelOnMultiValueFields() { $this->drupalGet('entity_test_base_field_display/manage/' . $entity->id()); $this->assertSession()->statusCodeEquals(200); - $this->assertText('A field with multiple values'); + $this->assertSession()->pageTextContains('A field with multiple values'); // Test if labels were XSS filtered. $this->assertSession()->assertEscaped("<script>alert('a configurable field');</script>"); } diff --git a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php index b0b6e984213a..50bb3e60aa30 100644 --- a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php +++ b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php @@ -86,7 +86,7 @@ public function testNumberDecimalField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($value); // Try to create entries with more than one decimal separator; assert fail. @@ -201,7 +201,7 @@ public function testNumberIntegerField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Try to set a value below the minimum value $this->drupalGet('entity_test/add'); @@ -250,7 +250,7 @@ public function testNumberIntegerField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw($valid_entry); // Verify that the "content" attribute is not present since the Prefix is // not being displayed. @@ -274,7 +274,7 @@ public function testNumberIntegerField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->drupalGet('entity_test/' . $id); // Verify that the "content" attribute has been set to the value of the // field, and the prefix is being displayed. @@ -330,7 +330,7 @@ public function testNumberFloatField() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Ensure that the 'number_decimal' formatter displays the number with the // expected rounding. diff --git a/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php b/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php index d8e7a9e849af..efb517c09826 100644 --- a/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php +++ b/core/modules/field/tests/src/Functional/ReEnableModuleFieldTest.php @@ -102,7 +102,7 @@ public function testReEnabledField() { ]); $this->drupalLogin($admin_user); $this->drupalGet('admin/modules/uninstall'); - $this->assertText("The Telephone number field type is used in the following field: node.field_telephone"); + $this->assertSession()->pageTextContains("The Telephone number field type is used in the following field: node.field_telephone"); // Add another telephone field to a different entity type in order to test // the message for the case when multiple fields are blocking the @@ -120,14 +120,14 @@ public function testReEnabledField() { ])->save(); $this->drupalGet('admin/modules/uninstall'); - $this->assertText("The Telephone number field type is used in the following fields: node.field_telephone, user.field_telephone_2"); + $this->assertSession()->pageTextContains("The Telephone number field type is used in the following fields: node.field_telephone, user.field_telephone_2"); // Delete both fields. $field_storage->delete(); $field_storage2->delete(); $this->drupalGet('admin/modules/uninstall'); - $this->assertText('Fields pending deletion'); + $this->assertSession()->pageTextContains('Fields pending deletion'); $this->cronRun(); $this->assertNoText("The Telephone number field type is used in the following field: node.field_telephone"); $this->assertNoText('Fields pending deletion'); diff --git a/core/modules/field/tests/src/Functional/String/StringFieldTest.php b/core/modules/field/tests/src/Functional/String/StringFieldTest.php index 28c66f157630..827ad9ec6cf6 100644 --- a/core/modules/field/tests/src/Functional/String/StringFieldTest.php +++ b/core/modules/field/tests/src/Functional/String/StringFieldTest.php @@ -102,7 +102,7 @@ public function _testTextfieldWidgets($field_type, $widget_type) { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Display the entity. $entity = EntityTest::load($id); diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php index 304ad1b5d144..4b947357de7a 100644 --- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php +++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php @@ -52,7 +52,7 @@ public function testEntityViewModeUI() { $this->drupalLogin($this->drupalCreateUser(['administer display modes'])); $this->drupalGet('admin/structure/display-modes/view'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Add view mode'); + $this->assertSession()->pageTextContains('Add view mode'); $this->assertSession()->linkByHrefExists('admin/structure/display-modes/view/add'); $this->assertSession()->linkByHrefExists('admin/structure/display-modes/view/add/entity_test'); @@ -107,7 +107,7 @@ public function testEntityFormModeUI() { $this->drupalLogin($this->drupalCreateUser(['administer display modes'])); $this->drupalGet('admin/structure/display-modes/form'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Add form mode'); + $this->assertSession()->pageTextContains('Add form mode'); $this->assertSession()->linkByHrefExists('admin/structure/display-modes/form/add'); $this->drupalGet('admin/structure/display-modes/form/add/entity_test_no_label'); diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIDeleteTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIDeleteTest.php index 64a515a73d0c..1feba737135e 100644 --- a/core/modules/field_ui/tests/src/Functional/FieldUIDeleteTest.php +++ b/core/modules/field_ui/tests/src/Functional/FieldUIDeleteTest.php @@ -121,9 +121,9 @@ public function testDeleteField() { // Check the config dependencies of the first field. $this->drupalGet("$bundle_path2/fields/node.$type_name2.$field_name/delete"); - $this->assertText('The listed configuration will be updated.'); - $this->assertText('View'); - $this->assertText('test_view_field_delete'); + $this->assertSession()->pageTextContains('The listed configuration will be updated.'); + $this->assertSession()->pageTextContains('View'); + $this->assertSession()->pageTextContains('test_view_field_delete'); $xml = $this->cssSelect('#edit-entity-deletes'); // Test that nothing is scheduled for deletion. diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php index b300a0ed7150..263514d91b5a 100644 --- a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php +++ b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php @@ -40,7 +40,7 @@ protected function setUp(): void { */ public function testFieldUIRoutes() { $this->drupalGet('entity_test_no_id/structure/entity_test/fields'); - $this->assertText('No fields are present yet.'); + $this->assertSession()->pageTextContains('No fields are present yet.'); $this->drupalGet('admin/config/people/accounts/fields'); $this->assertSession()->titleEquals('Manage fields | Drupal'); diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php index 3a2789dbe743..f031130fe2ec 100644 --- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php @@ -239,7 +239,7 @@ public function updateField() { $edit = [ 'settings[test_field_setting]' => $string, ]; - $this->assertText('Default value'); + $this->assertSession()->pageTextContains('Default value'); $this->submitForm($edit, 'Save settings'); // Assert the field settings are correct. @@ -283,7 +283,7 @@ public function cardinalitySettings() { 'cardinality_number' => '', ]; $this->drupalPostForm($field_edit_path, $edit, 'Save field settings'); - $this->assertText('Number of values is required.'); + $this->assertSession()->pageTextContains('Number of values is required.'); // Submit a custom number. $edit = [ @@ -291,7 +291,7 @@ public function cardinalitySettings() { 'cardinality_number' => 6, ]; $this->drupalPostForm($field_edit_path, $edit, 'Save field settings'); - $this->assertText('Updated field Body field settings.'); + $this->assertSession()->pageTextContains('Updated field Body field settings.'); $this->drupalGet($field_edit_path); $this->assertSession()->fieldValueEquals('cardinality', 'number'); $this->assertSession()->fieldValueEquals('cardinality_number', 6); @@ -324,7 +324,7 @@ public function cardinalitySettings() { 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, ]; $this->drupalPostForm($field_edit_path, $edit, 'Save field settings'); - $this->assertText('Updated field Body field settings.'); + $this->assertSession()->pageTextContains('Updated field Body field settings.'); $this->drupalGet($field_edit_path); $this->assertSession()->fieldValueEquals('cardinality', FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); $this->assertSession()->fieldValueEquals('cardinality_number', 1); @@ -467,7 +467,7 @@ public function testFieldPrefix() { 'field_name' => $field_exceed_max_length_input, ]; $this->drupalPostForm('admin/structure/types/manage/' . $this->contentType . '/fields/add-field', $edit, 'Save and continue'); - $this->assertText('Machine-readable name cannot be longer than 22 characters but is currently 23 characters long.'); + $this->assertSession()->pageTextContains('Machine-readable name cannot be longer than 22 characters but is currently 23 characters long.'); // Create a valid field. $this->fieldUIAddNewField('admin/structure/types/manage/' . $this->contentType, $this->fieldNameInput, $this->fieldLabel); @@ -509,12 +509,12 @@ public function testDefaultValue() { // Check that invalid default values are rejected. $edit = [$element_name => '-1']; $this->drupalPostForm($admin_path, $edit, 'Save settings'); - $this->assertText("$field_name does not accept the value -1"); + $this->assertSession()->pageTextContains("$field_name does not accept the value -1"); // Check that the default value is saved. $edit = [$element_name => '1']; $this->drupalPostForm($admin_path, $edit, 'Save settings'); - $this->assertText("Saved $field_name configuration"); + $this->assertSession()->pageTextContains("Saved $field_name configuration"); $field = FieldConfig::loadByName('node', $this->contentType, $field_name); $this->assertEquals([['value' => 1]], $field->getDefaultValueLiteral(), 'The default value was correctly saved.'); @@ -525,7 +525,7 @@ public function testDefaultValue() { // Check that the default value can be emptied. $edit = [$element_name => '']; $this->submitForm($edit, 'Save settings'); - $this->assertText("Saved $field_name configuration"); + $this->assertSession()->pageTextContains("Saved $field_name configuration"); $field = FieldConfig::loadByName('node', $this->contentType, $field_name); $this->assertEquals([], $field->getDefaultValueLiteral(), 'The default value was correctly saved.'); @@ -543,7 +543,7 @@ public function testDefaultValue() { $this->drupalGet($admin_path); $this->submitForm([], 'Save settings'); - $this->assertText("Saved $field_name configuration"); + $this->assertSession()->pageTextContains("Saved $field_name configuration"); $field = FieldConfig::loadByName('node', $this->contentType, $field_name); $this->assertEquals([], $field->getDefaultValueLiteral(), 'The default value was correctly saved.'); @@ -606,13 +606,13 @@ public function testDisallowedFieldNames() { $edit['field_name'] = 'title'; $bundle_path = 'admin/structure/types/manage/' . $this->contentType; $this->drupalPostForm("$bundle_path/fields/add-field", $edit, 'Save and continue'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); // Try with a base field. $edit['field_name'] = 'sticky'; $bundle_path = 'admin/structure/types/manage/' . $this->contentType; $this->drupalPostForm("$bundle_path/fields/add-field", $edit, 'Save and continue'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); } /** @@ -715,7 +715,7 @@ public function testDuplicateFieldName() { $url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field'; $this->drupalPostForm($url, $edit, 'Save and continue'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); $this->assertSession()->addressEquals($url); } @@ -782,7 +782,7 @@ public function testHelpDescriptions() { // Check that hook_field_widget_single_element_form_alter() does believe // this is the default value form. $this->drupalGet('admin/structure/types/manage/article/fields/node.article.field_tags'); - $this->assertText('From hook_field_widget_single_element_form_alter(): Default form is true.'); + $this->assertSession()->pageTextContains('From hook_field_widget_single_element_form_alter(): Default form is true.'); $edit = [ 'description' => '<em>Test with a non upload field.', @@ -799,7 +799,7 @@ public function testHelpDescriptions() { */ public function fieldListAdminPage() { $this->drupalGet('admin/reports/fields'); - $this->assertText($this->fieldName); + $this->assertSession()->pageTextContains($this->fieldName); $this->assertSession()->linkByHrefExists('admin/structure/types/manage/' . $this->contentType . '/fields'); } diff --git a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php index a649cf169c21..af12289bbc2e 100644 --- a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php @@ -41,7 +41,7 @@ public function testAnonymousNode() { $this->drupalLogout(); $this->drupalGet('node/add/article'); $this->assertSession()->statusCodeEquals(200); - $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); + $this->assertSession()->pageTextContains(strip_tags(t('Create @name', ['@name' => $bundle_label]))); $edit = [ 'title[0][value]' => $node_title, @@ -50,7 +50,7 @@ public function testAnonymousNode() { $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextContains(strip_tags(t('@type %title has been created.', $t_args))); $matches = []; if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); @@ -72,7 +72,7 @@ public function testAnonymousNodeWithFile() { $this->drupalLogout(); $this->drupalGet('node/add/article'); $this->assertSession()->statusCodeEquals(200); - $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); + $this->assertSession()->pageTextContains(strip_tags(t('Create @name', ['@name' => $bundle_label]))); // Generate an image file. $image = $this->getTestFile('image'); @@ -86,7 +86,7 @@ public function testAnonymousNodeWithFile() { $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextContains(strip_tags(t('@type %title has been created.', $t_args))); $matches = []; if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); @@ -129,7 +129,7 @@ protected function doTestNodeWithFileWithoutTitle() { // Load the node form. $this->drupalGet('node/add/article'); $this->assertSession()->statusCodeEquals(200); - $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); + $this->assertSession()->pageTextContains(strip_tags(t('Create @name', ['@name' => $bundle_label]))); // Generate an image file. $image = $this->getTestFile('image'); @@ -149,7 +149,7 @@ protected function doTestNodeWithFileWithoutTitle() { $this->assertSession()->statusCodeEquals(200); $t_args = ['@type' => $bundle_label, '%title' => $node_title]; $this->assertNoText(strip_tags(t('@type %title has been created.', $t_args))); - $this->assertText('Title field is required.'); + $this->assertSession()->pageTextContains('Title field is required.'); // Submit the form again but this time with the missing title field. This // should still work. @@ -160,7 +160,7 @@ protected function doTestNodeWithFileWithoutTitle() { // Confirm the final submission actually worked. $t_args = ['@type' => $bundle_label, '%title' => $node_title]; - $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); + $this->assertSession()->pageTextContains(strip_tags(t('@type %title has been created.', $t_args))); $matches = []; if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { $nid = end($matches); diff --git a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php index e8b07ccaf517..3ec5a4f2a847 100644 --- a/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php @@ -94,7 +94,7 @@ public function testNodeDisplay() { $field_name . '[0][display]' => TRUE, ]; $this->drupalPostForm('node/' . $nid . '/edit', $edit, 'Save'); - $this->assertText($description); + $this->assertSession()->pageTextContains($description); // Ensure the filename in the link's title attribute is escaped. $this->assertRaw('title="escaped-&-text.txt"'); @@ -183,7 +183,7 @@ public function testDescToggle() { $this->drupalPostForm('node/add/' . $type_name, $edit, 'Save'); $node = $this->drupalGetNodeByTitle($title); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertText('The description may be used as the label of the link to the file.'); + $this->assertSession()->pageTextContains('The description may be used as the label of the link to the file.'); } /** diff --git a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php index 4e36def69de2..46909cec0c43 100644 --- a/core/modules/file/tests/src/Functional/FileFieldValidateTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldValidateTest.php @@ -190,7 +190,7 @@ public function testFileRemoval() { // Check that the file can still be removed. $this->removeNodeFile($nid); $this->assertNoText('Only files with the following extensions are allowed: txt.'); - $this->assertText('Article ' . $node->getTitle() . ' has been updated.'); + $this->assertSession()->pageTextContains('Article ' . $node->getTitle() . ' has been updated.'); } } diff --git a/core/modules/file/tests/src/Functional/FileListingTest.php b/core/modules/file/tests/src/Functional/FileListingTest.php index dd946fa2cd96..395ec3ec797d 100644 --- a/core/modules/file/tests/src/Functional/FileListingTest.php +++ b/core/modules/file/tests/src/Functional/FileListingTest.php @@ -89,7 +89,7 @@ public function testFileListingPages() { $this->drupalGet('admin/content/files'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('No files available.'); + $this->assertSession()->pageTextContains('No files available.'); $this->drupalGet('admin/content/files'); $this->assertSession()->statusCodeEquals(200); @@ -115,7 +115,7 @@ public function testFileListingPages() { foreach ($nodes as $node) { $file = File::load($node->file->target_id); - $this->assertText($file->getFilename()); + $this->assertSession()->pageTextContains($file->getFilename()); $this->assertSession()->linkByHrefExists(file_create_url($file->getFileUri())); $this->assertSession()->linkByHrefExists('admin/content/files/usage/' . $file->id()); } @@ -146,16 +146,16 @@ public function testFileListingPages() { $usage = $file_usage->listUsage($file); $this->drupalGet('admin/content/files/usage/' . $file->id()); $this->assertSession()->statusCodeEquals(200); - $this->assertText($node->getTitle()); + $this->assertSession()->pageTextContains($node->getTitle()); // Verify that registering entity type is found on usage page. - $this->assertText('node'); + $this->assertSession()->pageTextContains('node'); // Verify that registering module is found on usage page. - $this->assertText('file'); + $this->assertSession()->pageTextContains('file'); foreach ($usage as $module) { foreach ($module as $entity_type) { foreach ($entity_type as $entity) { // Verify that usage count is found on usage page. - $this->assertText($entity); + $this->assertSession()->pageTextContains($entity); } } } @@ -207,7 +207,7 @@ public function testFileListingUsageNoLink() { $this->assertSession()->statusCodeEquals(200); // Entity name should be displayed, but not linked if Entity::toUrl // throws an exception - $this->assertText($entity_name); + $this->assertSession()->pageTextContains($entity_name); $this->assertSession()->linkNotExists($entity_name, 'Linked entity name not added to file usage listing.'); $this->assertSession()->linkExists($node->getTitle()); } diff --git a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php index 27207e84a2ba..93b9a7e70dd0 100644 --- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php +++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php @@ -51,7 +51,7 @@ public function testManagedFile() { $file_field_name => \Drupal::service('file_system')->realpath($test_file->getFileUri()), ]; $this->submitForm($edit, 'Save'); - $this->assertText('The form has become outdated.'); + $this->assertSession()->pageTextContains('The form has become outdated.'); $last_fid = $this->getLastFileId(); $this->assertEquals($last_fid_prior, $last_fid, 'File was not saved when uploaded with an invalid form token.'); @@ -213,7 +213,7 @@ public function testUnusedPermanentFileValidation() { $this->drupalGet('file/test/1/0/1/' . $file->id()); $this->submitForm([], 'Save'); $this->assertNoText('The file used in the Managed file & butter field may not be referenced.'); - $this->assertText('The file ids are ' . $file->id()); + $this->assertSession()->pageTextContains('The file ids are ' . $file->id()); // Enable marking unused files as temporary, unused permanent files must not // be referenced now. @@ -222,7 +222,7 @@ public function testUnusedPermanentFileValidation() { ->save(); $this->drupalGet('file/test/1/0/1/' . $file->id()); $this->submitForm([], 'Save'); - $this->assertText('The file used in the Managed file & butter field may not be referenced.'); + $this->assertSession()->pageTextContains('The file used in the Managed file & butter field may not be referenced.'); $this->assertNoText('The file ids are ' . $file->id()); // Make the file temporary, now using it is allowed. @@ -232,7 +232,7 @@ public function testUnusedPermanentFileValidation() { $this->drupalGet('file/test/1/0/1/' . $file->id()); $this->submitForm([], 'Save'); $this->assertNoText('The file used in the Managed file & butter field may not be referenced.'); - $this->assertText('The file ids are ' . $file->id()); + $this->assertSession()->pageTextContains('The file ids are ' . $file->id()); // Make the file permanent again and add a usage from itself, referencing is // still allowed. @@ -246,7 +246,7 @@ public function testUnusedPermanentFileValidation() { $this->drupalGet('file/test/1/0/1/' . $file->id()); $this->submitForm([], 'Save'); $this->assertNoText('The file used in the Managed file & butter field may not be referenced.'); - $this->assertText('The file ids are ' . $file->id()); + $this->assertSession()->pageTextContains('The file ids are ' . $file->id()); } } diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php index 7b66adaaecd7..934ba58b73a7 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php @@ -485,7 +485,7 @@ public function testErrorMessagesAreNotChanged() { // Ensure the expected error message is present and the counts before and // after calling _file_save_upload_from_form() are correct. - $this->assertText($error); + $this->assertSession()->pageTextContains($error); $this->assertRaw('Number of error messages before _file_save_upload_from_form(): 1'); $this->assertRaw('Number of error messages after _file_save_upload_from_form(): 1'); @@ -501,7 +501,7 @@ public function testErrorMessagesAreNotChanged() { // Ensure the expected error message is present and the counts before and // after calling _file_save_upload_from_form() are correct. - $this->assertText($error); + $this->assertSession()->pageTextContains($error); $this->assertRaw('Number of error messages before _file_save_upload_from_form(): 1'); $this->assertRaw('Number of error messages after _file_save_upload_from_form(): 1'); diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php index 3bca5aa43178..156eecd52a30 100644 --- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php +++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php @@ -175,7 +175,7 @@ public function testFormatAdmin() { 'name' => 'New format', ]; $this->drupalPostForm('admin/config/content/formats/add', $edit, 'Save configuration'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); // Attempt to create a format of the same human readable name as the // disabled format but with a different machine name. @@ -302,7 +302,7 @@ public function testFilterAdmin() { $edit['body[0][value]'] = $text; $edit['body[0][format]'] = $basic; $this->drupalPostForm('node/add/page', $edit, 'Save'); - $this->assertText('Basic page ' . $edit['title[0][value]'] . ' has been created.'); + $this->assertSession()->pageTextContains('Basic page ' . $edit['title[0][value]'] . ' has been created.'); // Verify that the creation message contains a link to a node. $this->assertSession()->elementExists('xpath', '//div[contains(@class, "messages")]//a[contains(@href, "node/")]'); @@ -428,7 +428,7 @@ public function testDisabledFormat() { // The format is used and we should see the static text instead of the body // value. $this->drupalGet($node->toUrl()); - $this->assertText('filtered text'); + $this->assertSession()->pageTextContains('filtered text'); // Disable the format. $format->disable()->save(); diff --git a/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php b/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php index 2b0336f2e916..f85b768b2e4d 100644 --- a/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php +++ b/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php @@ -234,13 +234,13 @@ public function testFormatWidgetPermissions() { $new_edit = []; $new_edit['title[0][value]'] = $this->randomMachineName(8); $this->submitForm($new_edit, 'Preview'); - $this->assertText($edit[$body_value_key]); + $this->assertSession()->pageTextContains($edit[$body_value_key]); // Save and verify that only the title was changed. $this->drupalPostForm('node/' . $node->id() . '/edit', $new_edit, 'Save'); $this->assertNoText($edit['title[0][value]']); - $this->assertText($new_edit['title[0][value]']); - $this->assertText($edit[$body_value_key]); + $this->assertSession()->pageTextContains($new_edit['title[0][value]']); + $this->assertSession()->pageTextContains($edit[$body_value_key]); // Check that even an administrator with "administer filters" permission // cannot edit the body field if they do not have specific permission to @@ -278,16 +278,16 @@ public function testFormatWidgetPermissions() { $edit = []; $edit['title[0][value]'] = $new_title; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); - $this->assertText('Text format field is required.'); + $this->assertSession()->pageTextContains('Text format field is required.'); $this->drupalGet('node/' . $node->id()); - $this->assertText($old_title); + $this->assertSession()->pageTextContains($old_title); $this->assertNoText($new_title); // Now select a new text format and make sure the node can be saved. $edit[$body_format_key] = filter_fallback_format(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); $this->assertSession()->addressEquals('node/' . $node->id()); - $this->assertText($new_title); + $this->assertSession()->pageTextContains($new_title); $this->assertNoText($old_title); // Switch the text format to a new one, then disable that format and all @@ -313,14 +313,14 @@ public function testFormatWidgetPermissions() { $edit = []; $edit['title[0][value]'] = $new_title; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); - $this->assertText('Text format field is required.'); + $this->assertSession()->pageTextContains('Text format field is required.'); $this->drupalGet('node/' . $node->id()); - $this->assertText($old_title); + $this->assertSession()->pageTextContains($old_title); $this->assertNoText($new_title); $edit[$body_format_key] = filter_fallback_format(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); $this->assertSession()->addressEquals('node/' . $node->id()); - $this->assertText($new_title); + $this->assertSession()->pageTextContains($new_title); $this->assertNoText($old_title); } diff --git a/core/modules/filter/tests/src/Functional/FilterHooksTest.php b/core/modules/filter/tests/src/Functional/FilterHooksTest.php index 61d8c8e77d9b..d909958bbb81 100644 --- a/core/modules/filter/tests/src/Functional/FilterHooksTest.php +++ b/core/modules/filter/tests/src/Functional/FilterHooksTest.php @@ -51,7 +51,7 @@ public function testFilterHooks() { $edit['roles[' . RoleInterface::ANONYMOUS_ID . ']'] = 1; $this->drupalPostForm('admin/config/content/formats/add', $edit, 'Save configuration'); $this->assertRaw(t('Added text format %format.', ['%format' => $name])); - $this->assertText('hook_filter_format_insert invoked.'); + $this->assertSession()->pageTextContains('hook_filter_format_insert invoked.'); $format_id = $edit['format']; @@ -60,7 +60,7 @@ public function testFilterHooks() { $edit['roles[' . RoleInterface::AUTHENTICATED_ID . ']'] = 1; $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id, $edit, 'Save configuration'); $this->assertRaw(t('The text format %format has been updated.', ['%format' => $name])); - $this->assertText('hook_filter_format_update invoked.'); + $this->assertSession()->pageTextContains('hook_filter_format_update invoked.'); // Use the format created. $title = $this->randomMachineName(8); @@ -69,12 +69,12 @@ public function testFilterHooks() { $edit['body[0][value]'] = $this->randomMachineName(32); $edit['body[0][format]'] = $format_id; $this->drupalPostForm("node/add/{$type->id()}", $edit, 'Save'); - $this->assertText($type_name . ' ' . $title . ' has been created.'); + $this->assertSession()->pageTextContains($type_name . ' ' . $title . ' has been created.'); // Disable the text format. $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', [], 'Disable'); $this->assertRaw(t('Disabled text format %format.', ['%format' => $name])); - $this->assertText('hook_filter_format_disable invoked.'); + $this->assertSession()->pageTextContains('hook_filter_format_disable invoked.'); } } diff --git a/core/modules/filter/tests/src/Functional/FilterSecurityTest.php b/core/modules/filter/tests/src/Functional/FilterSecurityTest.php index cd43733b14ea..210c322f3431 100644 --- a/core/modules/filter/tests/src/Functional/FilterSecurityTest.php +++ b/core/modules/filter/tests/src/Functional/FilterSecurityTest.php @@ -66,7 +66,7 @@ public function testDisableFilterModule() { $body_raw = $node->body->value; $format_id = $node->body->format; $this->drupalGet('node/' . $node->id()); - $this->assertText($body_raw); + $this->assertSession()->pageTextContains($body_raw); // Enable the filter_test_replace filter. $edit = [ @@ -77,7 +77,7 @@ public function testDisableFilterModule() { // Verify that filter_test_replace filter replaced the content. $this->drupalGet('node/' . $node->id()); $this->assertNoText($body_raw); - $this->assertText('Filter: Testing filter'); + $this->assertSession()->pageTextContains('Filter: Testing filter'); // Disable the text format entirely. $this->drupalPostForm('admin/config/content/formats/manage/' . $format_id . '/disable', [], 'Disable'); diff --git a/core/modules/forum/tests/src/Functional/ForumIndexTest.php b/core/modules/forum/tests/src/Functional/ForumIndexTest.php index ae38122f0f35..159a4900431a 100644 --- a/core/modules/forum/tests/src/Functional/ForumIndexTest.php +++ b/core/modules/forum/tests/src/Functional/ForumIndexTest.php @@ -74,7 +74,7 @@ public function testForumIndexStatus() { // Verify that the node appears on the index. $this->drupalGet('forum/' . $tid); - $this->assertText($title); + $this->assertSession()->pageTextContains($title); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'node_list'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:node.type.forum'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'comment_list'); @@ -86,7 +86,7 @@ public function testForumIndexStatus() { $edit = ['status[value]' => FALSE]; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); $this->drupalGet('node/' . $node->id()); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); // Verify that the node no longer appears on the index. $this->drupalGet('forum/' . $tid); diff --git a/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php b/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php index a860019ad079..80569a51ae28 100644 --- a/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php +++ b/core/modules/forum/tests/src/Functional/ForumNodeAccessTest.php @@ -88,8 +88,8 @@ public function testForumNodeAccess() { $this->drupalGet(''); // Ensure private node and public node are found. - $this->assertText($private_node->getTitle()); - $this->assertText($public_node->getTitle()); + $this->assertSession()->pageTextContains($private_node->getTitle()); + $this->assertSession()->pageTextContains($public_node->getTitle()); // Test for $no_access_user. $this->drupalLogin($no_access_user); @@ -97,7 +97,7 @@ public function testForumNodeAccess() { // Ensure private node is not found but public is found. $this->assertNoText($private_node->getTitle()); - $this->assertText($public_node->getTitle()); + $this->assertSession()->pageTextContains($public_node->getTitle()); } } diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php index 21de6c87a4ae..36aff485f1a8 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -171,7 +171,7 @@ public function testForum() { $this->drupalLogin($this->webUser); // Verify that this user is shown a message that they may not post content. $this->drupalGet('forum/' . $this->forum['tid']); - $this->assertText('You are not allowed to post new content in the forum'); + $this->assertSession()->pageTextContains('You are not allowed to post new content in the forum'); // Log in, and do basic tests for a user with permission to edit any forum // content. @@ -322,7 +322,7 @@ private function doAdminTests($user) { // Verify "edit container" link exists and functions correctly. $this->drupalGet('admin/structure/forum'); // Verify help text is shown. - $this->assertText('Forums contain forum topics. Use containers to group related forums'); + $this->assertSession()->pageTextContains('Forums contain forum topics. Use containers to group related forums'); // Verify action links are there. $this->assertSession()->linkExists('Add forum'); $this->assertSession()->linkExists('Add container'); @@ -441,7 +441,7 @@ public function createForum($type, $parent = 0) { $this->drupalPostForm('admin/structure/forum/add/' . $type, $edit, 'Save'); $this->assertSession()->statusCodeEquals(200); $type = ($type == 'container') ? 'forum container' : 'forum'; - $this->assertText('Created new ' . $type . ' ' . $name . '.'); + $this->assertSession()->pageTextContains('Created new ' . $type . ' ' . $name . '.'); // Verify that the creation message contains a link to a term. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "term/")]'); @@ -482,7 +482,7 @@ public function deleteForum($tid) { // Delete the forum. $this->drupalGet('admin/structure/forum/edit/forum/' . $tid); $this->clickLink(t('Delete')); - $this->assertText('Are you sure you want to delete the forum'); + $this->assertSession()->pageTextContains('Are you sure you want to delete the forum'); $this->assertNoText('Add forum'); $this->assertNoText('Add forum container'); $this->submitForm([], 'Delete'); @@ -580,7 +580,7 @@ public function createForumTopic($forum, $container = FALSE) { return; } else { - $this->assertText($type . ' ' . $title . ' has been created.'); + $this->assertSession()->pageTextContains($type . ' ' . $title . ' has been created.'); $this->assertNoRaw(t('The item %title is a forum container, not a forum.', ['%title' => $forum['name']])); // Verify that the creation message contains a link to a node. @@ -618,7 +618,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { $this->assertSession()->statusCodeEquals($response2); if ($response2 == 200) { $this->assertSession()->titleEquals('Forum | Drupal'); - $this->assertText('Forum'); + $this->assertSession()->pageTextContains('Forum'); } // View forum container page. @@ -660,7 +660,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { $edit['taxonomy_forums'] = $this->rootForum['tid']; $edit['shadow'] = TRUE; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); - $this->assertText('Forum topic ' . $edit['title[0][value]'] . ' has been updated.'); + $this->assertSession()->pageTextContains('Forum topic ' . $edit['title[0][value]'] . ' has been updated.'); // Verify topic was moved to a different forum. $forum_tid = $this->container diff --git a/core/modules/forum/tests/src/Functional/ForumUninstallTest.php b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php index 92c98b56108f..514a06a9f235 100644 --- a/core/modules/forum/tests/src/Functional/ForumUninstallTest.php +++ b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php @@ -78,7 +78,7 @@ public function testForumUninstallWithField() { $this->drupalGet('admin/modules/uninstall'); // Assert forum is required. $this->assertSession()->fieldDisabled('uninstall[forum]'); - $this->assertText('To uninstall Forum, first delete all Forum content'); + $this->assertSession()->pageTextContains('To uninstall Forum, first delete all Forum content'); // Delete the node. $this->drupalPostForm('node/' . $node->id() . '/delete', [], 'Delete'); @@ -87,7 +87,7 @@ public function testForumUninstallWithField() { $this->drupalGet('admin/modules/uninstall'); // Assert forum is still required. $this->assertSession()->fieldDisabled('uninstall[forum]'); - $this->assertText('To uninstall Forum, first delete all Forums terms'); + $this->assertSession()->pageTextContains('To uninstall Forum, first delete all Forums terms'); // Delete any forum terms. $vid = $this->config('forum.settings')->get('vocabulary'); @@ -129,7 +129,7 @@ public function testForumUninstallWithField() { // Double check everything by reinstalling the forum module again. $this->drupalPostForm('admin/modules', ['modules[forum][enable]' => 1], 'Install'); - $this->assertText('Module Forum has been enabled.'); + $this->assertSession()->pageTextContains('Module Forum has been enabled.'); } /** diff --git a/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php b/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php index 76af811233b6..502557bb7365 100644 --- a/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php +++ b/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php @@ -51,7 +51,7 @@ protected function setUp(): void { public function testExperimentalHelp() { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/help/experimental_module_test'); - $this->assertText('This module is experimental.'); + $this->assertSession()->pageTextContains('This module is experimental.'); // Regular modules should not display the message. $this->drupalGet('admin/help/help_page_test'); @@ -59,7 +59,7 @@ public function testExperimentalHelp() { // Ensure the actual help page is displayed to avoid a false positive. $this->assertSession()->statusCodeEquals(200); - $this->assertText('online documentation for the Help Page Test module'); + $this->assertSession()->pageTextContains('online documentation for the Help Page Test module'); } } diff --git a/core/modules/help/tests/src/Functional/HelpBlockTest.php b/core/modules/help/tests/src/Functional/HelpBlockTest.php index fa2d9c33c975..4e56e40f626e 100644 --- a/core/modules/help/tests/src/Functional/HelpBlockTest.php +++ b/core/modules/help/tests/src/Functional/HelpBlockTest.php @@ -43,8 +43,8 @@ protected function setUp(): void { */ public function testHelp() { $this->drupalGet('help_page_test/has_help'); - $this->assertText('I have help!'); - $this->assertText($this->helpBlock->label()); + $this->assertSession()->pageTextContains('I have help!'); + $this->assertSession()->pageTextContains($this->helpBlock->label()); $this->drupalGet('help_page_test/no_help'); // The help block should not appear when there is no help. @@ -53,8 +53,8 @@ public function testHelp() { // Ensure that if two hook_help() implementations both return a render array // the output is as expected. $this->drupalGet('help_page_test/test_array'); - $this->assertText('Help text from more_help_page_test_help module.'); - $this->assertText('Help text from help_page_test_help module.'); + $this->assertSession()->pageTextContains('Help text from more_help_page_test_help module.'); + $this->assertSession()->pageTextContains('Help text from help_page_test_help module.'); } } diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php index 5eb541c92f1e..05eac025809c 100644 --- a/core/modules/help/tests/src/Functional/HelpTest.php +++ b/core/modules/help/tests/src/Functional/HelpTest.php @@ -82,7 +82,7 @@ public function testHelp() { // Verify that an empty section is handled correctly. $this->assertSession()->responseContains('<h2>Empty section</h2>'); $this->assertSession()->responseContains('<p>This description should appear.</p>'); - $this->assertText('There is currently nothing in this section.'); + $this->assertSession()->pageTextContains('There is currently nothing in this section.'); // Make sure links are properly added for modules implementing hook_help(). foreach ($this->getModuleList() as $module => $name) { @@ -120,7 +120,7 @@ protected function verifyHelp($response = 200) { $this->drupalGet('admin/index'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('This page shows you all available administration tasks for each module.'); + $this->assertSession()->pageTextContains('This page shows you all available administration tasks for each module.'); } else { $this->assertNoText('This page shows you all available administration tasks for each module.'); @@ -136,7 +136,7 @@ protected function verifyHelp($response = 200) { $info = \Drupal::service('extension.list.module')->getExtensionInfo($module); $admin_tasks = system_get_module_admin_tasks($module, $info); if (!empty($admin_tasks)) { - $this->assertText($name . ' administration pages'); + $this->assertSession()->pageTextContains($name . ' administration pages'); } foreach ($admin_tasks as $task) { $this->assertSession()->linkExists($task['title']); diff --git a/core/modules/help/tests/src/Functional/NoHelpTest.php b/core/modules/help/tests/src/Functional/NoHelpTest.php index 361f182646d5..1201f4743581 100644 --- a/core/modules/help/tests/src/Functional/NoHelpTest.php +++ b/core/modules/help/tests/src/Functional/NoHelpTest.php @@ -43,7 +43,7 @@ public function testMainPageNoHelp() { $this->drupalGet('admin/help'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Module overviews are provided by modules'); + $this->assertSession()->pageTextContains('Module overviews are provided by modules'); $this->assertFalse(\Drupal::moduleHandler()->implementsHook('menu_test', 'help'), 'The menu_test module does not implement hook_help'); // Make sure the test module menu_test does not display a help link on // admin/help. diff --git a/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php b/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php index dd9c6f8c2d67..9211158d233e 100644 --- a/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php +++ b/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php @@ -255,7 +255,7 @@ public function testUninstall() { $edit['uninstall[help_topics]'] = TRUE; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->drupalGet('admin/help'); $this->assertSession()->statusCodeEquals(200); } diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php index 42f833048c00..26ac0160cf33 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -348,7 +348,7 @@ public function testStyleReplacement() { 'label' => $new_style_label, ]; $this->drupalPostForm($style_path . $style_name, $edit, 'Save'); - $this->assertText('Changes to the style have been saved.'); + $this->assertSession()->pageTextContains('Changes to the style have been saved.'); $this->drupalGet('node/' . $nid); // Reload the image style using the new name. @@ -378,12 +378,12 @@ public function testEditEffect() { $this->submitForm(['label' => 'Test style effect edit', 'name' => $style_name], 'Create new style'); $this->submitForm(['new' => 'image_scale_and_crop'], 'Add'); $this->submitForm(['data[width]' => '300', 'data[height]' => '200'], 'Add effect'); - $this->assertText('Scale and crop 300×200'); + $this->assertSession()->pageTextContains('Scale and crop 300×200'); // There should normally be only one edit link on this page initially. $this->clickLink(t('Edit')); $this->submitForm(['data[width]' => '360', 'data[height]' => '240'], 'Update effect'); - $this->assertText('Scale and crop 360×240'); + $this->assertSession()->pageTextContains('Scale and crop 360×240'); // Check that the previous effect is replaced. $this->assertNoText('Scale and crop 300×200'); @@ -412,8 +412,8 @@ public function testEditEffect() { } $this->submitForm(['new' => 'image_scale'], 'Add'); $this->submitForm(['data[width]' => '12', 'data[height]' => '19'], 'Add effect'); - $this->assertText('Scale 24×19'); - $this->assertText('Scale 12×19'); + $this->assertSession()->pageTextContains('Scale 24×19'); + $this->assertSession()->pageTextContains('Scale 12×19'); // Try to edit a nonexistent effect. $uuid = $this->container->get('uuid'); diff --git a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php index fc64ed50a5e5..7cc89b1af83e 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php @@ -223,8 +223,8 @@ public function testDefaultImages() { $non_image = $this->drupalGetTestFiles('text'); $this->submitForm(['files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($non_image[0]->uri)], 'Upload'); - $this->assertText('The specified file text-0.txt could not be uploaded.'); - $this->assertText('Only files with the following extensions are allowed: png gif jpg jpeg.'); + $this->assertSession()->pageTextContains('The specified file text-0.txt could not be uploaded.'); + $this->assertSession()->pageTextContains('Only files with the following extensions are allowed: png gif jpg jpeg.'); // Confirm the default image is shown on the node form. $file = File::load($default_images['field_storage_new']->id()); diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index 72d4d65205f4..8bc07c4a4530 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -262,9 +262,9 @@ public function testImageFieldSettings() { $this->assertSession()->fieldValueEquals('settings[min_resolution][y]', '10'); $this->drupalGet('node/add/article'); - $this->assertText('50 KB limit.'); - $this->assertText('Allowed types: ' . $test_image_extension . '.'); - $this->assertText('Images must be larger than 10x10 pixels. Images larger than 100x100 pixels will be resized.'); + $this->assertSession()->pageTextContains('50 KB limit.'); + $this->assertSession()->pageTextContains('Allowed types: ' . $test_image_extension . '.'); + $this->assertSession()->pageTextContains('Images must be larger than 10x10 pixels. Images larger than 100x100 pixels will be resized.'); // We have to create the article first and then edit it because the alt // and title fields do not display until the image has been attached. @@ -336,7 +336,7 @@ public function testImageFieldSettings() { $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); // Add the required alt text. $this->submitForm([$field_name . '[1][alt]' => $alt], 'Save'); - $this->assertText('Article ' . $node->getTitle() . ' has been updated.'); + $this->assertSession()->pageTextContains('Article ' . $node->getTitle() . ' has been updated.'); // Assert ImageWidget::process() calls FieldWidget::process(). $this->drupalGet('node/' . $node->id() . '/edit'); diff --git a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php index a71614939d3b..d5fc366383c2 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php @@ -148,15 +148,15 @@ public function testResolution() { '%height' => $image_that_is_too_small_file->getHeight(), ])); $this->uploadNodeImage($image_that_is_too_big, $field_names[0], 'article'); - $this->assertText('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'); + $this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'); $this->uploadNodeImage($image_that_is_too_small, $field_names[1], 'article'); $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename])); $this->uploadNodeImage($image_that_is_too_big, $field_names[1], 'article'); - $this->assertText('The image was resized to fit within the maximum allowed width of 100 pixels.'); + $this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed width of 100 pixels.'); $this->uploadNodeImage($image_that_is_too_small, $field_names[2], 'article'); $this->assertRaw(t('The specified file %name could not be uploaded.', ['%name' => $image_that_is_too_small->filename])); $this->uploadNodeImage($image_that_is_too_big, $field_names[2], 'article'); - $this->assertText('The image was resized to fit within the maximum allowed height of 100 pixels.'); + $this->assertSession()->pageTextContains('The image was resized to fit within the maximum allowed height of 100 pixels.'); } /** @@ -186,8 +186,8 @@ public function testRequiredAttributes() { $this->assertTrue(isset($elements[0]), 'Required marker is shown for the required title text.'); - $this->assertText('Alternative text field is required.'); - $this->assertText('Title field is required.'); + $this->assertSession()->pageTextContains('Alternative text field is required.'); + $this->assertSession()->pageTextContains('Title field is required.'); $instance->setSetting('alt_field_required', 0); $instance->setSetting('title_field_required', 0); diff --git a/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php b/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php index 386c8b2fbfa0..b60b1d4c11bc 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldWidgetTest.php @@ -38,20 +38,20 @@ public function testWidgetElement() { $this->assertNoText('Image test on [site:name]'); // Check for allowed image file extensions - default. - $this->assertText('Allowed types: png gif jpg jpeg.'); + $this->assertSession()->pageTextContains('Allowed types: png gif jpg jpeg.'); // Try adding to the field config an unsupported extension, should not // appear in the allowed types. $field_config = FieldConfig::loadByName('node', 'article', $field_name); $field_config->setSetting('file_extensions', 'png gif jpg jpeg tiff')->save(); $this->drupalGet('node/add/article'); - $this->assertText('Allowed types: png gif jpg jpeg.'); + $this->assertSession()->pageTextContains('Allowed types: png gif jpg jpeg.'); // Add a supported extension and remove some supported ones, we should see // the intersect of those entered in field config with those supported. $field_config->setSetting('file_extensions', 'png jpe tiff')->save(); $this->drupalGet('node/add/article'); - $this->assertText('Allowed types: png jpe.'); + $this->assertSession()->pageTextContains('Allowed types: png jpe.'); } } diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php index 30f1afc0c5f3..3a7569d130f1 100644 --- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php +++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php @@ -75,7 +75,7 @@ public function testUIBrowserLanguageMappings() { // Add the same custom mapping again. $this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, 'Save configuration'); - $this->assertText('Browser language codes must be unique.'); + $this->assertSession()->pageTextContains('Browser language codes must be unique.'); // Change browser language code of our custom mapping to zh-sg. $edit = [ @@ -83,7 +83,7 @@ public function testUIBrowserLanguageMappings() { 'mappings[xx][drupal_langcode]' => 'en', ]; $this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, 'Save configuration'); - $this->assertText('Browser language codes must be unique.'); + $this->assertSession()->pageTextContains('Browser language codes must be unique.'); // Change Drupal language code of our custom mapping to zh-hans. $edit = [ diff --git a/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php b/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php index 64e576b02ba9..2600627b3abb 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigOverrideImportTest.php @@ -58,11 +58,11 @@ public function testConfigOverrideImport() { $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site'); $this->assertEquals('FR default site name', $override->get('name')); $this->drupalGet('fr'); - $this->assertText('FR default site name'); + $this->assertSession()->pageTextContains('FR default site name'); $this->drupalLogin($this->rootUser); $this->drupalGet('admin/config/development/maintenance/translate/fr/edit'); - $this->assertText('FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience'); + $this->assertSession()->pageTextContains('FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience'); } /** @@ -94,7 +94,7 @@ public function testConfigOverrideImportEvents() { $this->assertFalse($event_recorder); $this->drupalGet('fr'); - $this->assertText('FR default site name'); + $this->assertSession()->pageTextContains('FR default site name'); } } diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php index c8d754209be3..131afcd75528 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php @@ -55,7 +55,7 @@ public function testLanguageConfiguration() { 'predefined_langcode' => 'fr', ]; $this->submitForm($edit, 'Add language'); - $this->assertText('French'); + $this->assertSession()->pageTextContains('French'); $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection')); // Langcode for Languages is always 'en'. $language = $this->config('language.entity.fr')->get(); @@ -111,14 +111,14 @@ public function testLanguageConfiguration() { 'prefix[en]' => '', ]; $this->submitForm($edit, 'Save configuration'); - $this->assertText('The prefix may only be left blank for the selected detection fallback language.'); + $this->assertSession()->pageTextContains('The prefix may only be left blank for the selected detection fallback language.'); // Check that prefix cannot be changed to contain a slash. $edit = [ 'prefix[en]' => 'foo/bar', ]; $this->submitForm($edit, 'Save configuration'); - $this->assertText('The prefix may not contain a slash.'); + $this->assertSession()->pageTextContains('The prefix may not contain a slash.'); // Remove English language and add a new Language to check if langcode of // Language entity is 'en'. diff --git a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php index 374c95d1d32d..f2c624a86e24 100644 --- a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php @@ -44,8 +44,8 @@ public function testLanguageConfiguration() { ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add custom language'); // Test validation on missing values. - $this->assertText('Language code field is required.'); - $this->assertText('Language name field is required.'); + $this->assertSession()->pageTextContains('Language code field is required.'); + $this->assertSession()->pageTextContains('Language name field is required.'); $empty_language = new Language(); $this->assertSession()->checkboxChecked('edit-direction-' . $empty_language->getDirection()); $this->assertSession()->addressEquals(Url::fromRoute('language.add')); diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php index 323c320b8a06..ef2711fe9e1d 100644 --- a/core/modules/language/tests/src/Functional/LanguageListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageListTest.php @@ -48,7 +48,7 @@ public function testLanguageList() { 'predefined_langcode' => 'fr', ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language'); - $this->assertText('French'); + $this->assertSession()->pageTextContains('French'); $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection')); // Get the weight of the last language and check that the weight is one unit @@ -71,7 +71,7 @@ public function testLanguageList() { $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add custom language'); $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection')); $this->assertRaw('"edit-languages-' . $langcode . '-weight"'); - $this->assertText($name); + $this->assertSession()->pageTextContains($name); $language = \Drupal::service('language_manager')->getLanguage($langcode); $english = \Drupal::service('language_manager')->getLanguage('en'); @@ -115,7 +115,7 @@ public function testLanguageList() { // Ensure 'delete' link works. $this->drupalGet('admin/config/regional/language'); $this->clickLink(t('Delete')); - $this->assertText('Are you sure you want to delete the language'); + $this->assertSession()->pageTextContains('Are you sure you want to delete the language'); // Delete a language. $this->drupalGet('admin/config/regional/language/delete/' . $langcode); // First test the 'cancel' link. @@ -159,7 +159,7 @@ public function testLanguageList() { ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add custom language'); $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection')); - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Check if we can change the default language. $path = 'admin/config/regional/language'; @@ -199,7 +199,7 @@ public function testLanguageList() { $language_storage->load('nl')->delete(); $this->submitForm(['site_default_language' => 'nl'], 'Save configuration'); - $this->assertText('Selected default language no longer exists.'); + $this->assertSession()->pageTextContains('Selected default language no longer exists.'); $this->assertSession()->checkboxNotChecked('edit-site-default-language-xx'); } diff --git a/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php index eca2b77cbbe3..6bc7589e3729 100644 --- a/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php @@ -49,7 +49,7 @@ public function testLanguageLocaleList() { 'predefined_langcode' => 'fr', ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language'); - $this->assertText('The language French has been created and can now be used'); + $this->assertSession()->pageTextContains('The language French has been created and can now be used'); $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection')); $this->rebuildContainer(); diff --git a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php index 9f9a7c819ba1..7cd00d64f768 100644 --- a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php +++ b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php @@ -76,7 +76,7 @@ public function testPageLinks() { // Verify that links in this page can be followed and work. $this->clickLink(t('Languages')); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Add language'); + $this->assertSession()->pageTextContains('Add language'); } } diff --git a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php index 6ab0cc92ad68..d0c48c9b8c43 100644 --- a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php @@ -85,7 +85,7 @@ public function testLanguageBlock() { protected function doTestLanguageBlockAuthenticated($block_label) { // Assert that the language switching block is displayed on the frontpage. $this->drupalGet(''); - $this->assertText($block_label); + $this->assertSession()->pageTextContains($block_label); // Assert that each list item and anchor element has the appropriate data- // attributes. @@ -139,7 +139,7 @@ protected function doTestLanguageBlockAnonymous($block_label) { // Assert that the language switching block is displayed on the frontpage // and ensure that the active class is added when query params are present. $this->drupalGet('', ['query' => ['foo' => 'bar']]); - $this->assertText($block_label); + $this->assertSession()->pageTextContains($block_label); // Assert that only the current language is marked as active. $language_switchers = $this->xpath('//div[@id=:id]/ul/li', [':id' => 'block-test-language-block']); @@ -203,7 +203,7 @@ public function testLanguageBlockWithDomain() { 'domain[en]' => '', ]; $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, 'Save configuration'); - $this->assertText('The domain may not be left blank for English'); + $this->assertSession()->pageTextContains('The domain may not be left blank for English'); // Change the domain for the Italian language. $edit = [ @@ -212,7 +212,7 @@ public function testLanguageBlockWithDomain() { 'domain[it]' => 'it.example.com', ]; $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved'); + $this->assertSession()->pageTextContains('The configuration options have been saved'); // Enable the language switcher block. $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, ['id' => 'test_language_block']); diff --git a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php index 2d3d33dc94bb..e06840ce3501 100644 --- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @@ -409,8 +409,8 @@ protected function doRunTest($test) { } $this->container->get('language_manager')->reset(); $this->drupalGet($test['path'], $test['path_options'], $test['http_header']); - $this->assertText($test['expect']); - $this->assertText('Language negotiation method: ' . $test['expected_method_id']); + $this->assertSession()->pageTextContains($test['expect']); + $this->assertSession()->pageTextContains('Language negotiation method: ' . $test['expected_method_id']); // Get the private file and ensure it is a 200. It is important to // invalidate the router cache to ensure the routing system runs a full @@ -497,7 +497,7 @@ public function testLanguageDomain() { 'domain[en]' => '', ]; $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, 'Save configuration'); - $this->assertText('The domain may not be left blank for English'); + $this->assertSession()->pageTextContains('The domain may not be left blank for English'); $this->rebuildContainer(); // Change the domain for the Italian language. @@ -507,7 +507,7 @@ public function testLanguageDomain() { 'domain[it]' => 'it.example.com', ]; $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved'); + $this->assertSession()->pageTextContains('The configuration options have been saved'); $this->rebuildContainer(); // Try to use an invalid domain. diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php index fc5dd8380eb3..b917348fbe9f 100644 --- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php @@ -69,7 +69,7 @@ public function testUrlRewritingEdgeCases() { // Check that URL rewriting is not applied to subrequests. $this->drupalGet('language_test/subrequest'); - $this->assertText($this->webUser->getAccountName()); + $this->assertSession()->pageTextContains($this->webUser->getAccountName()); } /** diff --git a/core/modules/link/tests/src/Functional/LinkFieldTest.php b/core/modules/link/tests/src/Functional/LinkFieldTest.php index 74275bf12276..d2da5ce4aa35 100644 --- a/core/modules/link/tests/src/Functional/LinkFieldTest.php +++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php @@ -220,7 +220,7 @@ protected function assertValidEntries($field_name, array $valid_entries) { $this->drupalPostForm('entity_test/add', $edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw('"' . $string . '"'); } } @@ -239,7 +239,7 @@ protected function assertInvalidEntries($field_name, array $invalid_entries) { "{$field_name}[0][uri]" => $invalid_value, ]; $this->drupalPostForm('entity_test/add', $edit, 'Save'); - $this->assertText(strtr($error_message, ['@link_path' => $invalid_value])); + $this->assertSession()->responseContains(strtr($error_message, ['@link_path' => $invalid_value])); } } @@ -292,7 +292,7 @@ public function testLinkTitle() { // Display creation form. $this->drupalGet('entity_test/add'); // Assert label is shown. - $this->assertText('Read more about this entity'); + $this->assertSession()->pageTextContains('Read more about this entity'); $this->assertSession()->fieldValueEquals("{$field_name}[0][uri]", ''); $this->assertRaw('placeholder="http://example.com"'); @@ -310,7 +310,7 @@ public function testLinkTitle() { "{$field_name}[0][title]" => 'Example', ]; $this->submitForm($edit, 'Save'); - $this->assertText('The URL field is required when the Link text field is specified.'); + $this->assertSession()->pageTextContains('The URL field is required when the Link text field is specified.'); } if ($title_setting === DRUPAL_REQUIRED) { // Verify that the link text is required, if the URL is non-empty. @@ -318,7 +318,7 @@ public function testLinkTitle() { "{$field_name}[0][uri]" => 'http://www.example.com', ]; $this->submitForm($edit, 'Save'); - $this->assertText('Link text field is required if there is URL input.'); + $this->assertSession()->pageTextContains('Link text field is required if there is URL input.'); // Verify that the link text is not required, if the URL is empty. $edit = [ @@ -348,7 +348,7 @@ public function testLinkTitle() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $output = $this->renderTestEntity($id); $expected_link = (string) Link::fromTextAndUrl($value, Url::fromUri($value))->toString(); @@ -360,7 +360,7 @@ public function testLinkTitle() { "{$field_name}[0][title]" => $title, ]; $this->drupalPostForm("entity_test/manage/$id/edit", $edit, 'Save'); - $this->assertText('entity_test ' . $id . ' has been updated.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been updated.'); $output = $this->renderTestEntity($id); $expected_link = (string) Link::fromTextAndUrl($title, Url::fromUri($value))->toString(); @@ -428,11 +428,11 @@ public function testLinkFormatter() { "{$field_name}[2][title]" => $title3, ]; // Assert label is shown. - $this->assertText('Read more about this entity'); + $this->assertSession()->pageTextContains('Read more about this entity'); $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Verify that the link is output according to the formatter settings. // Not using generatePermutations(), since that leads to 32 cases, which @@ -583,7 +583,7 @@ public function testLinkSeparateFormatter() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Verify that the link is output according to the formatter settings. $options = [ diff --git a/core/modules/link/tests/src/Functional/LinkFieldUITest.php b/core/modules/link/tests/src/Functional/LinkFieldUITest.php index d108e087d73e..4b485c2955d6 100644 --- a/core/modules/link/tests/src/Functional/LinkFieldUITest.php +++ b/core/modules/link/tests/src/Functional/LinkFieldUITest.php @@ -172,7 +172,7 @@ public function runFieldUIItem($cardinality, $link_type, $title, $label, $field_ // generate warnings. // @todo Mess with the formatter settings a bit here. $this->drupalGet("$type_path/display"); - $this->assertText('Link text trimmed to 80 characters'); + $this->assertSession()->pageTextContains('Link text trimmed to 80 characters'); // Make the fields visible in the form display. $form_display_id = implode('.', ['node', $this->contentType->id(), 'default']); diff --git a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php index d141586d5850..35c6939c42fc 100644 --- a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php @@ -124,7 +124,7 @@ public function testConfigTranslationModuleInstall() { // Get the front page and ensure that the translated configuration appears. $this->drupalGet('af'); - $this->assertText('Test site slogan in Afrikaans'); + $this->assertSession()->pageTextContains('Test site slogan in Afrikaans'); $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings'); $this->assertEquals('Locale can translate Afrikaans', $override->get('translatable_default_with_translation')); @@ -138,12 +138,12 @@ public function testConfigTranslationModuleInstall() { // Install any module. $this->drupalPostForm('admin/modules', ['modules[dblog][enable]' => 'dblog'], 'Install'); - $this->assertText('Module Database Logging has been enabled.'); + $this->assertSession()->pageTextContains('Module Database Logging has been enabled.'); // Get the front page and ensure that the translated configuration still // appears. $this->drupalGet('af'); - $this->assertText('Test site slogan in Afrikaans'); + $this->assertSession()->pageTextContains('Test site slogan in Afrikaans'); $this->rebuildContainer(); $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings'); diff --git a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php index bfddc6a92e1a..e6ed45995524 100644 --- a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php @@ -201,7 +201,7 @@ public function testConfigTranslation() { // translation. This test ensures the entity loaded from the request // upcasting will already work. $this->drupalGet($this->langcode . '/contact/feedback'); - $this->assertText($category_label); + $this->assertSession()->pageTextContains($category_label); // Check if the UI does not show the translated String. $this->drupalGet('admin/structure/contact/manage/feedback'); diff --git a/core/modules/locale/tests/src/Functional/LocaleContentTest.php b/core/modules/locale/tests/src/Functional/LocaleContentTest.php index a518af33b486..dd1bea0ec7ef 100644 --- a/core/modules/locale/tests/src/Functional/LocaleContentTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleContentTest.php @@ -98,7 +98,7 @@ public function testContentTypeLanguageConfiguration() { // Set the content type to use multilingual support. $this->drupalGet("admin/structure/types/manage/{$type2->id()}"); - $this->assertText('Language settings'); + $this->assertSession()->pageTextContains('Language settings'); $edit = [ 'language_configuration[language_alterable]' => TRUE, ]; @@ -118,7 +118,7 @@ public function testContentTypeLanguageConfiguration() { // Verify language select list is present. $this->assertSession()->fieldExists('langcode[0][value]'); // Ensure language appears. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Create a node. $node_title = $this->randomMachineName(); @@ -139,7 +139,7 @@ public function testContentTypeLanguageConfiguration() { 'langcode[0][value]' => 'en', ]; $this->drupalPostForm($path, $edit, 'Save'); - $this->assertText($node_title . ' has been updated.'); + $this->assertSession()->pageTextContains($node_title . ' has been updated.'); // Verify that the creation message contains a link to a node. $xpath = $this->assertSession()->buildXPathQuery('//div[@data-drupal-messages]//a[contains(@href, :href)]', [ diff --git a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php index 34135c8c9d8b..7152b1616045 100644 --- a/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php @@ -146,7 +146,7 @@ public function testStandalonePoFile() { 'files[file]' => $name, ], 'Import'); $this->assertSession()->addressEquals(Url::fromRoute('locale.translate_import')); - $this->assertText('File to import not found.'); + $this->assertSession()->pageTextContains('File to import not found.'); // Try importing a .po file with overriding strings, and ensure existing // strings are kept. @@ -163,7 +163,7 @@ public function testStandalonePoFile() { 'translation' => 'translated', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // This import should not have changed number of plural forms. $locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr'); @@ -225,7 +225,7 @@ public function testStandalonePoFile() { 'translation' => 'translated', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // Try importing a .po file with overriding strings, and ensure existing // customized strings are overwritten. @@ -292,7 +292,7 @@ public function testEmptyMsgstr() { ]; // Check that search finds the string as untranslated. $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($str); + $this->assertSession()->pageTextContains($str); } /** @@ -348,7 +348,7 @@ public function testConfigPoFile() { 'translation' => 'all', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($config_string[1]); + $this->assertSession()->pageTextContains($config_string[1]); } // Test that translations got recorded in the config system. diff --git a/core/modules/locale/tests/src/Functional/LocalePathTest.php b/core/modules/locale/tests/src/Functional/LocalePathTest.php index c7f0d972afac..4f7b14a80198 100644 --- a/core/modules/locale/tests/src/Functional/LocalePathTest.php +++ b/core/modules/locale/tests/src/Functional/LocalePathTest.php @@ -76,7 +76,7 @@ public function testPathLanguageConfiguration() { // Check that the "xx" front page is readily available because path prefix // negotiation is pre-configured. $this->drupalGet($prefix); - $this->assertText('Welcome to Drupal'); + $this->assertSession()->pageTextContains('Welcome to Drupal'); // Create a node. $node = $this->drupalCreateNode(['type' => 'page']); @@ -102,11 +102,11 @@ public function testPathLanguageConfiguration() { // Confirm English language path alias works. $this->drupalGet($english_path); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); // Confirm custom language path alias works. $this->drupalGet($prefix . '/' . $custom_language_path); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); // Create a custom path. $custom_path = $this->randomMachineName(8); @@ -141,11 +141,11 @@ public function testPathLanguageConfiguration() { // Confirm that the custom path leads to the first node. $this->drupalGet($custom_path); - $this->assertText($first_node->label()); + $this->assertSession()->pageTextContains($first_node->label()); // Confirm that the custom path with prefix leads to the second node. $this->drupalGet($prefix . '/' . $custom_path); - $this->assertText($second_node->label()); + $this->assertSession()->pageTextContains($second_node->label()); } diff --git a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php index b4ea5316c31f..9a67e2cb7ed9 100644 --- a/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php +++ b/core/modules/locale/tests/src/Functional/LocalePluralFormatTest.php @@ -178,7 +178,7 @@ public function testPluralEditDateFormatter() { $this->drupalGet('user'); // Member for time should be translated. - $this->assertText("seconde"); + $this->assertSession()->pageTextContains("seconde"); $path = 'admin/config/regional/translate/'; $search = [ @@ -189,8 +189,8 @@ public function testPluralEditDateFormatter() { ]; $this->drupalPostForm($path, $search, 'Filter'); // Plural values for the langcode fr. - $this->assertText('@count seconde'); - $this->assertText('@count secondes'); + $this->assertSession()->pageTextContains('@count seconde'); + $this->assertSession()->pageTextContains('@count secondes'); // Inject a plural source string to the database. We need to use a specific // langcode here because the language will be English by default and will @@ -225,7 +225,7 @@ public function testPluralEditDateFormatter() { // second or minute. $this->adminUser->set('created', time() - 2)->save(); $this->drupalGet('user'); - $this->assertText("secondes updated"); + $this->assertSession()->pageTextContains("secondes updated"); } /** @@ -265,8 +265,8 @@ public function testPluralEditExport() { // Check if the source appears on the translation page. $this->drupalGet('admin/config/regional/translate'); - $this->assertText("1 hour"); - $this->assertText("@count hours"); + $this->assertSession()->pageTextContains("1 hour"); + $this->assertSession()->pageTextContains("@count hours"); // Look up editing page for this plural string and check fields. $path = 'admin/config/regional/translate/'; @@ -275,15 +275,15 @@ public function testPluralEditExport() { ]; $this->drupalPostForm($path, $search, 'Filter'); // Labels for plural editing elements. - $this->assertText('Singular form'); - $this->assertText('First plural form'); - $this->assertText('2. plural form'); + $this->assertSession()->pageTextContains('Singular form'); + $this->assertSession()->pageTextContains('First plural form'); + $this->assertSession()->pageTextContains('2. plural form'); $this->assertNoText('3. plural form'); // Plural values for langcode hr. - $this->assertText('@count sat'); - $this->assertText('@count sata'); - $this->assertText('@count sati'); + $this->assertSession()->pageTextContains('@count sat'); + $this->assertSession()->pageTextContains('@count sata'); + $this->assertSession()->pageTextContains('@count sati'); $connection = Database::getConnection(); // Edit langcode hr translations and see if that took effect. @@ -303,8 +303,8 @@ public function testPluralEditExport() { ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); // Plural values for the langcode fr. - $this->assertText('@count heure'); - $this->assertText('@count heures'); + $this->assertSession()->pageTextContains('@count heure'); + $this->assertSession()->pageTextContains('@count heures'); $this->assertNoText('2. plural form'); // Edit langcode fr translations and see if that took effect. diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php index 0e392c8deba7..0125829451ed 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php @@ -79,7 +79,7 @@ public function testStringTranslation() { $this->container->get('string_translation')->reset(); $this->assertRaw('"edit-languages-' . $langcode . '-weight"'); // Ensure that test language was added. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); $this->drupalLogout(); // Add a whitespace at the end of string to ensure it is found. @@ -94,10 +94,10 @@ public function testStringTranslation() { ]; // Check that search finds the string as untranslated. $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // No t() here, it's surely not translated yet. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Verify that there is no way to translate the string to English. $this->assertSession()->optionNotExists('edit-langcode', 'en'); $this->drupalLogout(); @@ -107,7 +107,7 @@ public function testStringTranslation() { $this->drupalLogin($translate_user); // Check that search finds the string as untranslated. $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Assume this is the only result, given the random name. $textarea = $this->assertSession()->elementExists('xpath', '//textarea'); @@ -116,7 +116,7 @@ public function testStringTranslation() { $lid => $translation, ]; $this->drupalPostForm('admin/config/regional/translate', $edit, 'Save translations'); - $this->assertText('The strings have been saved.'); + $this->assertSession()->pageTextContains('The strings have been saved.'); $url_bits = explode('?', $this->getUrl()); $this->assertEquals(Url::fromRoute('locale.translate_page', [], ['absolute' => TRUE])->toString(), $url_bits[0], 'Correct page redirection.'); $search = [ @@ -164,12 +164,12 @@ public function testStringTranslation() { 'translation' => 'untranslated', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // Test invalidation of 'rendered' cache tag after string translation. $this->drupalLogout(); $this->drupalGet('xx/user/login'); - $this->assertText('Enter the password that accompanies your username.'); + $this->assertSession()->pageTextContains('Enter the password that accompanies your username.'); $this->drupalLogin($translate_user); $search = [ @@ -187,7 +187,7 @@ public function testStringTranslation() { $this->drupalLogout(); $this->drupalGet('xx/user/login'); - $this->assertText('Please enter your Llama username.'); + $this->assertSession()->pageTextContains('Please enter your Llama username.'); // Delete the language. $this->drupalLogin($admin_user); @@ -411,7 +411,7 @@ public function testStringSearch() { // assertText() seems to remove the input field where $name always could be // found, so this is not a false assert. See how assertNoText succeeds // later. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Ensure untranslated string doesn't appear if searching on 'only // translated strings'. @@ -421,7 +421,7 @@ public function testStringSearch() { 'translation' => 'translated', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // Ensure untranslated string appears if searching on 'only untranslated // strings'. @@ -461,7 +461,7 @@ public function testStringSearch() { 'translation' => 'untranslated', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // Ensure translated string doesn't appear if searching on 'only // untranslated strings'. @@ -471,7 +471,7 @@ public function testStringSearch() { 'translation' => 'untranslated', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // Ensure translated string does appear if searching on the custom language. $search = [ @@ -489,7 +489,7 @@ public function testStringSearch() { 'translation' => 'all', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); // Search for a string that isn't in the system. $unavailable_string = $this->randomMachineName(16); @@ -499,7 +499,7 @@ public function testStringSearch() { 'translation' => 'all', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('No strings available.'); + $this->assertSession()->pageTextContains('No strings available.'); } /** @@ -541,7 +541,7 @@ public function testUICustomizedStrings() { ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($translation->getString()); + $this->assertSession()->pageTextContains($translation->getString()); // Submit the translations without changing the translation. $textarea = $this->assertSession()->elementExists('xpath', '//textarea'); @@ -560,7 +560,7 @@ public function testUICustomizedStrings() { 'customized' => '0', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($string->getString()); + $this->assertSession()->pageTextContains($string->getString()); // Submit the translations with a new translation. $textarea = $this->assertSession()->elementExists('xpath', '//textarea'); @@ -579,7 +579,7 @@ public function testUICustomizedStrings() { 'customized' => '1', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText($string->getString()); + $this->assertSession()->pageTextContains($string->getString()); } } diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php index 1d08311e7eef..1df2655a79cc 100644 --- a/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php @@ -64,10 +64,10 @@ public function testInterface() { // One language added, all translations up to date. $this->drupalGet('admin/reports/status'); - $this->assertText('Translation update status'); - $this->assertText('Up to date'); + $this->assertSession()->pageTextContains('Translation update status'); + $this->assertSession()->pageTextContains('Up to date'); $this->drupalGet('admin/reports/translations'); - $this->assertText('All translations up to date.'); + $this->assertSession()->pageTextContains('All translations up to date.'); // Set locale_test_translate module to have a local translation available. $status = locale_translation_get_status(); @@ -76,10 +76,10 @@ public function testInterface() { // Check if updates are available for German. $this->drupalGet('admin/reports/status'); - $this->assertText('Translation update status'); + $this->assertSession()->pageTextContains('Translation update status'); $this->assertRaw(t('Updates available for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()])); $this->drupalGet('admin/reports/translations'); - $this->assertText('Updates for: Locale test translate'); + $this->assertSession()->pageTextContains('Updates for: Locale test translate'); // Set locale_test_translate module to have a dev release and no // translation found. @@ -90,10 +90,10 @@ public function testInterface() { // Check if no updates were found. $this->drupalGet('admin/reports/status'); - $this->assertText('Translation update status'); + $this->assertSession()->pageTextContains('Translation update status'); $this->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', ['@languages' => t('German'), ':updates' => Url::fromRoute('locale.translate_status')->toString()])); $this->drupalGet('admin/reports/translations'); - $this->assertText('Missing translations for one project'); + $this->assertSession()->pageTextContains('Missing translations for one project'); $release_details = new FormattableMarkup('@module (@version). @info', [ '@module' => 'Locale test translate', '@version' => '1.3-dev', @@ -110,8 +110,8 @@ public function testInterface() { // Check if Drupal core is not translated. $this->drupalGet('admin/reports/translations'); - $this->assertText('Missing translations for 2 projects'); - $this->assertText('Drupal core (8.1.1).'); + $this->assertSession()->pageTextContains('Missing translations for 2 projects'); + $this->assertSession()->pageTextContains('Drupal core (8.1.1).'); // Override Drupal core translation status as 'translations available'. $status = locale_translation_get_status(); @@ -122,8 +122,8 @@ public function testInterface() { // Check if translations are available for Drupal core. $this->drupalGet('admin/reports/translations'); - $this->assertText('Updates for: Drupal core'); - $this->assertText('Drupal core (' . $this->container->get('date.formatter')->format(REQUEST_TIME, 'html_date') . ')'); + $this->assertSession()->pageTextContains('Updates for: Drupal core'); + $this->assertSession()->pageTextContains('Drupal core (' . $this->container->get('date.formatter')->format(REQUEST_TIME, 'html_date') . ')'); $this->assertSession()->buttonExists('Update translations'); } diff --git a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php index 10d4ac7dd277..920168ae03f8 100644 --- a/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleUpdateTest.php @@ -55,7 +55,7 @@ protected function setUp(): void { public function testUpdateCheckStatus() { // Case when contributed modules are absent. $this->drupalGet('admin/reports/translations'); - $this->assertText('Missing translations for one project'); + $this->assertSession()->pageTextContains('Missing translations for one project'); $config = $this->config('locale.settings'); // Set a flag to let the locale_test module replace the project data with a @@ -128,11 +128,11 @@ public function testUpdateImportSourceRemote() { // Check the status on the Available translation status page. $this->assertRaw('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>'); - $this->assertText('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test'); + $this->assertSession()->pageTextContains('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test'); /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */ $date_formatter = $this->container->get('date.formatter'); - $this->assertText('Contributed module one (' . $date_formatter->format($this->timestampNew, 'html_date') . ')'); - $this->assertText('Contributed module two (' . $date_formatter->format($this->timestampNew, 'html_date') . ')'); + $this->assertSession()->pageTextContains('Contributed module one (' . $date_formatter->format($this->timestampNew, 'html_date') . ')'); + $this->assertSession()->pageTextContains('Contributed module two (' . $date_formatter->format($this->timestampNew, 'html_date') . ')'); // Execute the translation update. $this->drupalPostForm('admin/reports/translations', [], 'Update translations'); @@ -426,8 +426,8 @@ public function testEnableCustomLanguage() { // Ensure the translation file is automatically imported when the language // was added. - $this->assertText('One translation file imported.'); - $this->assertText('One translation string was skipped because of disallowed or malformed HTML'); + $this->assertSession()->pageTextContains('One translation file imported.'); + $this->assertSession()->pageTextContains('One translation string was skipped because of disallowed or malformed HTML'); // Ensure the strings were successfully imported. $search = [ @@ -445,7 +445,7 @@ public function testEnableCustomLanguage() { 'translation' => 'all', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('Multiline translation string to make sure that import works with it.'); + $this->assertSession()->pageTextContains('Multiline translation string to make sure that import works with it.'); // Ensure 'Allowed HTML source string' was imported but the translation for // 'Another allowed HTML source string' was not because it contains invalid @@ -456,7 +456,7 @@ public function testEnableCustomLanguage() { 'translation' => 'all', ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); - $this->assertText('Allowed HTML source string'); + $this->assertSession()->pageTextContains('Allowed HTML source string'); $this->assertNoText('Another allowed HTML source string'); } diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php index 80a025833046..976de8e7e0a3 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php @@ -47,7 +47,7 @@ public function testMenuLinkContentDeleteForm() { ], 'Save' ); - $this->assertText('The menu link has been saved.'); + $this->assertSession()->pageTextContains('The menu link has been saved.'); $menu_link = MenuLinkContent::load(1); $this->drupalGet($menu_link->toUrl('delete-form')); diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php index 3c6259ecc1f6..fd88781a4bea 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php @@ -92,7 +92,7 @@ public function testMenuLinkContentForm() { 'title[0][value]' => t('Front page'), 'link[0][uri]' => '<front>', ], 'Save'); - $this->assertText('The menu link has been saved.'); + $this->assertSession()->pageTextContains('The menu link has been saved.'); } /** @@ -104,7 +104,7 @@ public function testMenuLinkContentFormValidation() { 'title[0][value]' => t('Test page'), 'link[0][uri]' => '<test>', ], 'Save'); - $this->assertText('Manually entered paths should start with one of the following characters: / ? #'); + $this->assertSession()->pageTextContains('Manually entered paths should start with one of the following characters: / ? #'); } } diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php index 38f64d07c3be..4b8e256b9a17 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php @@ -93,7 +93,7 @@ public function testMenuNodeFormWidget() { // Verify that no menu settings are displayed and nodes can be created. $this->drupalGet('node/add/page'); - $this->assertText('Create Basic page'); + $this->assertSession()->pageTextContains('Create Basic page'); $this->assertNoText('Menu settings'); $node_title = $this->randomMachineName(); $edit = [ @@ -111,7 +111,7 @@ public function testMenuNodeFormWidget() { 'menu_parent' => 'main:', ]; $this->drupalPostForm('admin/structure/types/manage/page', $edit, 'Save content type'); - $this->assertText('The selected menu link is not under one of the selected menus.'); + $this->assertSession()->pageTextContains('The selected menu link is not under one of the selected menus.'); $this->assertNoRaw(t('The content type %name has been updated.', ['%name' => 'Basic page'])); // Enable Tools menu as available menu. @@ -230,7 +230,7 @@ public function testMenuNodeFormWidget() { // Assert that disabled Administration menu is not shown on the // node/$nid/edit page. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertText('Provide a menu link'); + $this->assertSession()->pageTextContains('Provide a menu link'); // Assert that the link is still in the Administration menu after save. $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); $link = MenuLinkContent::load($item->id()); diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index 7b4690366c12..ca14d09c9963 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -161,7 +161,7 @@ public function testMenu() { $id = $instance->getPluginId(); $this->drupalPostForm("admin/structure/menu/link/$id/edit", $edit, 'Save'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The menu link has been saved.'); + $this->assertSession()->pageTextContains('The menu link has been saved.'); $menu_link_manager->resetDefinitions(); $instance = $menu_link_manager->createInstance($instance->getPluginId()); @@ -236,12 +236,12 @@ public function addCustomMenu() { // Verify that the confirmation message is displayed. $this->assertRaw(t('Menu %label has been added.', ['%label' => $label])); $this->drupalGet('admin/structure/menu'); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); // Confirm that the custom menu block is available. $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); $this->clickLink('Place block'); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); // Enable the block. $block = $this->drupalPlaceBlock('system_menu_block:' . $menu_name); @@ -275,7 +275,7 @@ public function deleteCustomMenu() { // Try to delete the main menu. $this->drupalGet('admin/structure/menu/manage/main/delete'); - $this->assertText('You are not authorized to access this page.'); + $this->assertSession()->pageTextContains('You are not authorized to access this page.'); } /** @@ -579,7 +579,7 @@ public function testSystemMenuRename() { $default_theme = $this->config('system.theme')->get('default'); $this->drupalget('admin/structure/block/list/' . $default_theme); $this->clickLink('Place block'); - $this->assertText($edit['label']); + $this->assertSession()->pageTextContains($edit['label']); } /** @@ -651,7 +651,7 @@ public function addMenuLink($parent = '', $path = '/', $menu_name = 'tools', $ex // Add menu link. $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The menu link has been saved.'); + $this->assertSession()->pageTextContains('The menu link has been saved.'); $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(['title' => $title]); @@ -794,10 +794,10 @@ public function modifyMenuLink(MenuLinkContent $item) { $edit['title[0][value]'] = $title; $this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, 'Save'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The menu link has been saved.'); + $this->assertSession()->pageTextContains('The menu link has been saved.'); // Verify menu link. $this->drupalGet('admin/structure/menu/manage/' . $item->getMenuName()); - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } /** @@ -855,7 +855,7 @@ public function toggleMenuLink(MenuLinkContent $item) { // Verify menu link is displayed. $this->drupalGet(''); - $this->assertText($item->getTitle()); + $this->assertSession()->pageTextContains($item->getTitle()); } /** @@ -974,21 +974,21 @@ private function verifyAccess($response = 200) { $this->drupalGet('admin/help/menu'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Menu', 'Menu help was displayed'); + $this->assertSession()->pageTextContains('Menu', 'Menu help was displayed'); } // View menu build overview page. $this->drupalGet('admin/structure/menu'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Menus', 'Menu build overview page was displayed'); + $this->assertSession()->pageTextContains('Menus', 'Menu build overview page was displayed'); } // View tools menu customization page. $this->drupalGet('admin/structure/menu/manage/' . $this->menu->id()); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Tools', 'Tools menu page was displayed'); + $this->assertSession()->pageTextContains('Tools', 'Tools menu page was displayed'); } // View menu edit page for a static link. @@ -996,14 +996,14 @@ private function verifyAccess($response = 200) { $this->drupalGet('admin/structure/menu/link/' . $item->getPluginId() . '/edit'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Edit menu item', 'Menu edit page was displayed'); + $this->assertSession()->pageTextContains('Edit menu item', 'Menu edit page was displayed'); } // View add menu page. $this->drupalGet('admin/structure/menu/add'); $this->assertSession()->statusCodeEquals($response); if ($response == 200) { - $this->assertText('Menus', 'Add menu page was displayed'); + $this->assertSession()->pageTextContains('Menus', 'Add menu page was displayed'); } } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php index 93d81b94bfac..edb64265cb71 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php @@ -30,7 +30,7 @@ public function testAccess() { $this->drupalLogin($this->rootUser); $this->drupalGet('upgrade'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Upgrade'); + $this->assertSession()->pageTextContains('Upgrade'); $user = $this->createUser(['administer software updates']); $this->drupalLogin($user); diff --git a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php index 86245962b65f..20215a77fdf2 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessFieldTest.php @@ -95,12 +95,12 @@ public function testNodeAccessAdministerField() { // Log in as the administrator and confirm that the field value is present. $this->drupalLogin($this->adminUser); $this->drupalGet('node/' . $node->id()); - $this->assertText($value); + $this->assertSession()->pageTextContains($value); // Log in as the content admin and try to view the node. $this->drupalLogin($this->contentAdminUser); $this->drupalGet('node/' . $node->id()); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); // Modify the field default as the content admin. $edit = []; @@ -117,7 +117,7 @@ public function testNodeAccessAdministerField() { // Confirm that the existing node still has the correct field value. $this->drupalGet('node/' . $node->id()); - $this->assertText($value); + $this->assertSession()->pageTextContains($value); // Confirm that the new default value appears when creating a new node. $this->drupalGet('node/add/page'); diff --git a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php index ced149d5916a..f7d3689de4ec 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php @@ -68,8 +68,8 @@ public function testCommentPager() { // View the node page. With the default 50 comments per page there should // be two pages (0, 1) but no third (2) page. $this->drupalGet('node/' . $node->id()); - $this->assertText($node->label()); - $this->assertText('Comments'); + $this->assertSession()->pageTextContains($node->label()); + $this->assertSession()->pageTextContains('Comments'); $this->assertRaw('page=1'); $this->assertNoRaw('page=2'); } diff --git a/core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php b/core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php index 94bebc4252e6..fd3e8c5b107d 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php @@ -81,7 +81,7 @@ public function testNodeAccessRebuildNodeGrants() { $this->drupalGet('admin/reports/status'); $this->clickLink(t('Rebuild permissions')); $this->submitForm([], 'Rebuild permissions'); - $this->assertText('The content access permissions have been rebuilt.'); + $this->assertSession()->pageTextContains('The content access permissions have been rebuilt.'); // Test if the rebuild by user that cannot bypass node access and does not // have access to the nodes has been successful. @@ -117,7 +117,7 @@ public function testNodeAccessRebuildNoAccessModules() { $this->drupalGet('admin/reports/status'); $this->clickLink(t('Rebuild permissions')); $this->submitForm([], 'Rebuild permissions'); - $this->assertText('Content permissions have been rebuilt.'); + $this->assertSession()->pageTextContains('Content permissions have been rebuilt.'); $this->assertNull(\Drupal::state()->get('node.node_access_needs_rebuild'), 'Node access permissions have been rebuilt'); // Default realm access is still present. diff --git a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php index 5c27e20b8900..e2cd8bb90cf1 100644 --- a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php +++ b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php @@ -52,10 +52,10 @@ public function testAssignOwnerNodeActionConfiguration() { $action_id = $edit['id']; // Make sure that the new action was saved properly. - $this->assertText('The action has been successfully saved.'); + $this->assertSession()->pageTextContains('The action has been successfully saved.'); // Check that the label of the node_assign_owner_action action appears on // the actions administration page after saving. - $this->assertText($action_label); + $this->assertSession()->pageTextContains($action_label); // Make another POST request to the action edit page. $this->clickLink(t('Configure')); @@ -67,13 +67,13 @@ public function testAssignOwnerNodeActionConfiguration() { $this->assertSession()->statusCodeEquals(200); // Make sure that the action updated properly. - $this->assertText('The action has been successfully saved.'); + $this->assertSession()->pageTextContains('The action has been successfully saved.'); // Check that the old label for the node_assign_owner_action action does not // appear on the actions administration page after updating. $this->assertNoText($action_label); // Check that the new label for the node_assign_owner_action action appears // on the actions administration page after updating. - $this->assertText($new_action_label); + $this->assertSession()->pageTextContains($new_action_label); // Make sure that deletions work properly. $this->drupalGet('admin/config/system/actions'); diff --git a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php index e4ccab95f5a0..24e442f8f19a 100644 --- a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php +++ b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php @@ -77,7 +77,7 @@ public function testRecentNodeBlock() { // Test that block is not visible without nodes. $this->drupalGet(''); - $this->assertText('No content available.'); + $this->assertSession()->pageTextContains('No content available.'); // Add some test nodes. $default_settings = ['uid' => $this->webUser->id(), 'type' => 'article']; @@ -115,8 +115,8 @@ public function testRecentNodeBlock() { // Test that only the 2 latest nodes are shown. $this->drupalLogin($this->webUser); $this->assertNoText($node1->label()); - $this->assertText($node2->label()); - $this->assertText($node3->label()); + $this->assertSession()->pageTextContains($node2->label()); + $this->assertSession()->pageTextContains($node3->label()); // Check to make sure nodes are in the right order. $this->assertSession()->elementExists('xpath', '//div[@id="block-test-block"]//div[@class="item-list"]/ul/li[1]/div/span/a[text() = "' . $node3->label() . '"]'); @@ -133,10 +133,10 @@ public function testRecentNodeBlock() { // Test that all four nodes are shown. $this->drupalGet(''); - $this->assertText($node1->label()); - $this->assertText($node2->label()); - $this->assertText($node3->label()); - $this->assertText($node4->label()); + $this->assertSession()->pageTextContains($node1->label()); + $this->assertSession()->pageTextContains($node2->label()); + $this->assertSession()->pageTextContains($node3->label()); + $this->assertSession()->pageTextContains($node4->label()); $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); @@ -173,7 +173,7 @@ public function testRecentNodeBlock() { $this->drupalGet('node/add/article'); // Check that block is displayed on the add article page. - $this->assertText($label); + $this->assertSession()->pageTextContains($label); $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'session', 'theme', 'url.path', 'url.query_args', 'user', 'route']); // The node/add/article page is an admin path and currently uncacheable. @@ -182,7 +182,7 @@ public function testRecentNodeBlock() { $this->drupalGet('node/' . $node1->id()); // Check that block is displayed on the node page when node is of type // 'article'. - $this->assertText($label); + $this->assertSession()->pageTextContains($label); $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.site', 'user', 'route', 'timezone']); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'MISS'); $this->drupalGet('node/' . $node1->id()); @@ -226,7 +226,7 @@ public function testRecentNodeBlock() { $this->drupalGet('admin/structure/block'); // Check that block is displayed on the admin/structure/block page. - $this->assertText($label); + $this->assertSession()->pageTextContains($label); $this->assertSession()->linkByHrefExists($block->toUrl()->toString()); } diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index b041abf2fdb0..60f2addeebd3 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -75,7 +75,7 @@ public function testNodeCreation() { $this->drupalPostForm('node/add/page', $edit, 'Save'); // Check that the Basic page has been created. - $this->assertText('Basic page ' . $edit['title[0][value]'] . ' has been created.'); + $this->assertSession()->pageTextContains('Basic page ' . $edit['title[0][value]'] . ' has been created.'); // Verify that the creation message contains a link to a node. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]'); @@ -96,8 +96,8 @@ public function testNodeCreation() { $node_type->save(); $this->drupalGet('node/' . $node->id()); - $this->assertText($node->getOwner()->getAccountName()); - $this->assertText($this->container->get('date.formatter')->format($node->getCreatedTime())); + $this->assertSession()->pageTextContains($node->getOwner()->getAccountName()); + $this->assertSession()->pageTextContains($this->container->get('date.formatter')->format($node->getCreatedTime())); // Check if the node revision checkbox is not rendered on node creation form. $admin_user = $this->drupalCreateUser([ @@ -163,10 +163,10 @@ public function testUnpublishedNodeCreation() { // Check that the user was redirected to the home page. $this->assertSession()->addressEquals(''); - $this->assertText('Test page text'); + $this->assertSession()->pageTextContains('Test page text'); // Confirm that the node was created. - $this->assertText('Basic page ' . $edit['title[0][value]'] . ' has been created.'); + $this->assertSession()->pageTextContains('Basic page ' . $edit['title[0][value]'] . ' has been created.'); // Verify that the creation message contains a link to a node. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]'); diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php index d4dd1c40cad6..5391a3cb3e18 100644 --- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php +++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php @@ -97,8 +97,8 @@ public function testNodeEdit() { $this->submitForm($edit, 'Save'); // Check that the title and body fields are displayed with the updated values. - $this->assertText($edit[$title_key]); - $this->assertText($edit[$body_key]); + $this->assertSession()->pageTextContains($edit[$title_key]); + $this->assertSession()->pageTextContains($edit[$body_key]); // Log in as a second administrator user. $second_web_user = $this->drupalCreateUser([ @@ -237,7 +237,7 @@ public function testNodeMetaInformation() { // information. $this->drupalLogin($this->adminUser); $this->drupalGet('node/add/page'); - $this->assertText('Not saved yet'); + $this->assertSession()->pageTextContains('Not saved yet'); // Create node to edit. $edit['title[0][value]'] = $this->randomMachineName(8); @@ -246,8 +246,8 @@ public function testNodeMetaInformation() { $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->drupalGet("node/" . $node->id() . "/edit"); - $this->assertText('Published'); - $this->assertText($this->container->get('date.formatter')->format($node->getChangedTime(), 'short')); + $this->assertSession()->pageTextContains('Published'); + $this->assertSession()->pageTextContains($this->container->get('date.formatter')->format($node->getChangedTime(), 'short')); } /** diff --git a/core/modules/node/tests/src/Functional/NodeEntityViewModeAlterTest.php b/core/modules/node/tests/src/Functional/NodeEntityViewModeAlterTest.php index b11a8265fd73..e2071338bccc 100644 --- a/core/modules/node/tests/src/Functional/NodeEntityViewModeAlterTest.php +++ b/core/modules/node/tests/src/Functional/NodeEntityViewModeAlterTest.php @@ -49,7 +49,7 @@ public function testNodeViewModeChange() { $this->drupalGet('node/' . $node->id()); // Check that teaser mode is viewed. - $this->assertText('Extra data that should appear only in the teaser for the node.'); + $this->assertSession()->pageTextContains('Extra data that should appear only in the teaser for the node.'); // Make sure body text is not present. $this->assertNoText('Data that should appear only in the body for the node.'); diff --git a/core/modules/node/tests/src/Functional/NodeHelpTest.php b/core/modules/node/tests/src/Functional/NodeHelpTest.php index b7a68bc8f9ee..cf464c606bf0 100644 --- a/core/modules/node/tests/src/Functional/NodeHelpTest.php +++ b/core/modules/node/tests/src/Functional/NodeHelpTest.php @@ -70,13 +70,13 @@ public function testNodeShowHelpText() { // Check the node add form. $this->drupalGet('node/add/' . $this->testType); $this->assertSession()->statusCodeEquals(200); - $this->assertText($this->testText); + $this->assertSession()->pageTextContains($this->testText); // Create node and check the node edit form. $node = $this->drupalCreateNode(['type' => $this->testType]); $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertSession()->statusCodeEquals(200); - $this->assertText($this->testText); + $this->assertSession()->pageTextContains($this->testText); } } diff --git a/core/modules/node/tests/src/Functional/NodeLinksTest.php b/core/modules/node/tests/src/Functional/NodeLinksTest.php index 5345ef6490f2..d8f2acf0cb22 100644 --- a/core/modules/node/tests/src/Functional/NodeLinksTest.php +++ b/core/modules/node/tests/src/Functional/NodeLinksTest.php @@ -34,7 +34,7 @@ public function testHideLinks() { // Links are displayed by default. $this->drupalGet('node'); - $this->assertText($node->getTitle()); + $this->assertSession()->pageTextContains($node->getTitle()); $this->assertSession()->linkExists('Read more'); // Hide links. @@ -44,7 +44,7 @@ public function testHideLinks() { ->save(); $this->drupalGet('node'); - $this->assertText($node->getTitle()); + $this->assertSession()->pageTextContains($node->getTitle()); $this->assertSession()->linkNotExists('Read more'); } diff --git a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php index 0a7ef920c2f8..c9a363f568b5 100644 --- a/core/modules/node/tests/src/Functional/NodeRSSContentTest.php +++ b/core/modules/node/tests/src/Functional/NodeRSSContentTest.php @@ -52,7 +52,7 @@ public function testNodeRSSContent() { // Check that content added in 'rss' view mode appear in RSS feed. $rss_only_content = 'Extra data that should appear only in the RSS feed for node ' . $node->id() . '.'; - $this->assertText($rss_only_content); + $this->assertSession()->responseContains($rss_only_content); // Check that content added in view modes other than 'rss' doesn't // appear in RSS feed. diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php index 8c4244a7121b..8652d8f59713 100644 --- a/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php +++ b/core/modules/node/tests/src/Functional/NodeRevisionsAllTest.php @@ -135,13 +135,13 @@ public function testRevisions() { // Confirm the correct revision text appears on "view revisions" page. $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view"); - $this->assertText($node->body->value); + $this->assertSession()->pageTextContains($node->body->value); // Confirm the correct revision log message appears on the "revisions // overview" page. $this->drupalGet("node/" . $node->id() . "/revisions"); foreach ($logs as $revision_log) { - $this->assertText($revision_log); + $this->assertSession()->pageTextContains($revision_log); } // Confirm that this is the current revision. @@ -170,8 +170,8 @@ public function testRevisions() { // Confirm that the node can still be updated. $this->drupalPostForm("node/" . $reverted_node->id() . "/edit", ['body[0][value]' => 'We are Drupal.'], 'Save'); - $this->assertText('Basic page ' . $reverted_node->getTitle() . ' has been updated.'); - $this->assertText('We are Drupal.'); + $this->assertSession()->pageTextContains('Basic page ' . $reverted_node->getTitle() . ' has been updated.'); + $this->assertSession()->pageTextContains('We are Drupal.'); // Confirm revisions delete properly. $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", [], 'Delete'); @@ -221,12 +221,12 @@ public function testRevisions() { $this->assertRaw('page=1'); // Check that the last revision is displayed on the first page. - $this->assertText(end($logs)); + $this->assertSession()->pageTextContains(end($logs)); // Go to the second page and check that one of the initial three revisions // is displayed. $this->clickLink(t('Page 2')); - $this->assertText($logs[2]); + $this->assertSession()->pageTextContains($logs[2]); } } diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php index 85bbae62174c..ac610d23c09d 100644 --- a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php +++ b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php @@ -154,18 +154,18 @@ public function testRevisions() { // Confirm the correct revision text appears on "view revisions" page. $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view"); - $this->assertText($node->body->value); + $this->assertSession()->pageTextContains($node->body->value); // Confirm the correct log message appears on "revisions overview" page. $this->drupalGet("node/" . $node->id() . "/revisions"); foreach ($logs as $revision_log) { - $this->assertText($revision_log); + $this->assertSession()->pageTextContains($revision_log); } // Original author, and editor names should appear on revisions overview. $web_user = $nodes[0]->revision_uid->entity; - $this->assertText('by ' . $web_user->getAccountName()); + $this->assertSession()->pageTextContains('by ' . $web_user->getAccountName()); $editor = $nodes[2]->revision_uid->entity; - $this->assertText('by ' . $editor->getAccountName()); + $this->assertSession()->pageTextContains('by ' . $editor->getAccountName()); // Confirm that this is the default revision. $this->assertTrue($node->isDefaultRevision(), 'Third node revision is the default one.'); @@ -237,7 +237,7 @@ public function testRevisions() { // Verify that the new body text is present on the revision. $this->drupalGet("node/" . $node->id() . "/revisions/" . $new_node_revision->getRevisionId() . "/view"); - $this->assertText($new_body); + $this->assertSession()->pageTextContains($new_body); // Verify that the non-default revision vid is greater than the default // revision vid. @@ -259,7 +259,7 @@ public function testRevisions() { // Verify revisions is accessible since the type has revisions enabled. $this->assertSession()->statusCodeEquals(200); // Check initial revision is shown on the node revisions overview page. - $this->assertText('Simple revision message (EN)'); + $this->assertSession()->pageTextContains('Simple revision message (EN)'); // Verify that delete operation is inaccessible for the default revision. $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/delete"); @@ -278,8 +278,8 @@ public function testRevisions() { // Check both revisions are shown on the node revisions overview page. $this->drupalGet("node/" . $node->id() . "/revisions"); - $this->assertText('Simple revision message (EN)'); - $this->assertText('New revision message (EN)'); + $this->assertSession()->pageTextContains('Simple revision message (EN)'); + $this->assertSession()->pageTextContains('New revision message (EN)'); // Create an 'EN' node with a revision log message. $node = $this->drupalCreateNode(); @@ -292,7 +292,7 @@ public function testRevisions() { // Verify revisions is accessible since the type has revisions enabled. $this->assertSession()->statusCodeEquals(200); // Check initial revision is shown on the node revisions overview page. - $this->assertText('Simple revision message (EN)'); + $this->assertSession()->pageTextContains('Simple revision message (EN)'); // Add a translation in 'DE' and create a new revision and new log message. $translation = $node->addTranslation('de'); @@ -304,17 +304,17 @@ public function testRevisions() { // View the revision UI in 'IT', only the original node revision is shown. $this->drupalGet("it/node/" . $node->id() . "/revisions"); - $this->assertText('Simple revision message (EN)'); + $this->assertSession()->pageTextContains('Simple revision message (EN)'); $this->assertNoText('New revision message (DE)'); // View the revision UI in 'DE', only the translated node revision is shown. $this->drupalGet("de/node/" . $node->id() . "/revisions"); $this->assertNoText('Simple revision message (EN)'); - $this->assertText('New revision message (DE)'); + $this->assertSession()->pageTextContains('New revision message (DE)'); // View the revision UI in 'EN', only the original node revision is shown. $this->drupalGet("node/" . $node->id() . "/revisions"); - $this->assertText('Simple revision message (EN)'); + $this->assertSession()->pageTextContains('Simple revision message (EN)'); $this->assertNoText('New revision message (DE)'); } @@ -340,7 +340,7 @@ public function testNodeRevisionWithoutLogMessage() { $node->save(); $this->drupalGet('node/' . $node->id()); - $this->assertText($new_title); + $this->assertSession()->pageTextContains($new_title); $node_storage->resetCache([$node->id()]); $node_revision = $node_storage->load($node->id()); $this->assertEquals($revision_log, $node_revision->revision_log->value, 'After an existing node revision is re-saved without a log message, the original log message is preserved.'); @@ -359,7 +359,7 @@ public function testNodeRevisionWithoutLogMessage() { $node->save(); $this->drupalGet('node/' . $node->id()); - $this->assertText($new_title); + $this->assertSession()->pageTextContains($new_title); $node_storage->resetCache([$node->id()]); $node_revision = $node_storage->load($node->id()); $this->assertTrue(empty($node_revision->revision_log->value), 'After a new node revision is saved with an empty log message, the log message for the node is empty.'); diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php index d535a1b9cd6b..033f3470048c 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -392,7 +392,7 @@ protected function doTestTranslations($path, array $values) { $languages = $this->container->get('language_manager')->getLanguages(); foreach ($this->langcodes as $langcode) { $this->drupalGet($path, ['language' => $languages[$langcode]]); - $this->assertText($values[$langcode]['title'][0]['value']); + $this->assertSession()->pageTextContains($values[$langcode]['title'][0]['value']); } } @@ -526,7 +526,7 @@ public function testRevisionTranslationRendering() { $this->assertSession()->statusCodeEquals(200); // Contents should be in English, of correct revision. - $this->assertText('First rev en title'); + $this->assertSession()->pageTextContains('First rev en title'); $this->assertNoText('First rev fr title'); // Get a French view. @@ -539,7 +539,7 @@ public function testRevisionTranslationRendering() { $this->assertSession()->statusCodeEquals(200); // Contents should be in French, of correct revision. - $this->assertText('First rev fr title'); + $this->assertSession()->pageTextContains('First rev fr title'); $this->assertNoText('First rev en title'); } diff --git a/core/modules/node/tests/src/Functional/NodeTypeTest.php b/core/modules/node/tests/src/Functional/NodeTypeTest.php index 85467036c0cb..1a7ba87a02e9 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php @@ -197,7 +197,7 @@ public function testNodeTypeDeletion() { $this->assertRaw( t('Are you sure you want to delete the content type %type?', ['%type' => $type->label()]) ); - $this->assertText('This action cannot be undone.'); + $this->assertSession()->pageTextContains('This action cannot be undone.'); // Test that a locked node type could not be deleted. $this->container->get('module_installer')->install(['node_test_config']); diff --git a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php index 412184e4a26d..0a77a693eda8 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php @@ -144,7 +144,7 @@ public function testNodeTypeTitleLabelTranslation() { // Assert that the title label is displayed on the translation form with the right value. $this->drupalGet("admin/structure/types/manage/$type/translate/$langcode/add"); - $this->assertText('Edited title'); + $this->assertSession()->pageTextContains('Edited title'); // Translate the title label. $this->submitForm(["translation[config_names][core.base_field_override.node.$type.title][label]" => 'Translated title'], 'Save translation'); @@ -154,9 +154,9 @@ public function testNodeTypeTitleLabelTranslation() { // use t(). If t() were used then the correct langcodes would need to be // provided. $this->drupalGet("node/add/$type"); - $this->assertText('Edited title'); + $this->assertSession()->pageTextContains('Edited title'); $this->drupalGet("$langcode/node/add/$type"); - $this->assertText('Translated title'); + $this->assertSession()->pageTextContains('Translated title'); // Add an e-mail field. $this->drupalPostForm("admin/structure/types/manage/$type/fields/add-field", ['new_storage_type' => 'email', 'label' => 'Email', 'field_name' => 'email'], 'Save and continue'); @@ -179,7 +179,7 @@ public function testNodeTypeTitleLabelTranslation() { $this->assertSession()->statusCodeEquals(200); $this->drupalGet("es/admin/structure/types/manage/$type/fields/node.$type.field_email/translate"); $this->assertSession()->statusCodeEquals(200); - $this->assertText("The configuration objects have different language codes so they cannot be translated"); + $this->assertSession()->pageTextContains("The configuration objects have different language codes so they cannot be translated"); } } diff --git a/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php b/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php index c2f83c03b228..33af4fe801ea 100644 --- a/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php +++ b/core/modules/node/tests/src/Functional/NodeViewLanguageTest.php @@ -40,7 +40,7 @@ public function testViewLanguage() { $node = $this->drupalCreateNode(['langcode' => 'es']); $this->drupalGet($node->toUrl()); - $this->assertText('Spanish'); + $this->assertSession()->pageTextContains('Spanish'); } } diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php index 8864e66fab6a..3334f260d89f 100644 --- a/core/modules/node/tests/src/Functional/PagePreviewTest.php +++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php @@ -206,8 +206,8 @@ public function testPagePreview() { $expected_title = $edit[$title_key] . ' | Drupal'; $this->assertSession()->titleEquals($expected_title); $this->assertSession()->assertEscaped($edit[$title_key]); - $this->assertText($edit[$body_key]); - $this->assertText($edit[$term_key]); + $this->assertSession()->pageTextContains($edit[$body_key]); + $this->assertSession()->pageTextContains($edit[$term_key]); $this->assertSession()->linkExists('Back to content editing'); // Check that we see the class of the node type on the body element. @@ -246,8 +246,8 @@ public function testPagePreview() { $this->submitForm([], 'Preview'); $this->assertSession()->titleEquals($expected_title); $this->assertSession()->assertEscaped($edit[$title_key]); - $this->assertText($edit[$body_key]); - $this->assertText($edit[$term_key]); + $this->assertSession()->pageTextContains($edit[$body_key]); + $this->assertSession()->pageTextContains($edit[$term_key]); $this->assertSession()->linkExists('Back to content editing'); // Assert the content is kept when reloading the page. @@ -263,7 +263,7 @@ public function testPagePreview() { // Check the term was displayed on the saved node. $this->drupalGet('node/' . $node->id()); - $this->assertText($edit[$term_key]); + $this->assertSession()->pageTextContains($edit[$term_key]); // Check the term appears again on the edit form. $this->drupalGet('node/' . $node->id() . '/edit'); @@ -305,7 +305,7 @@ public function testPagePreview() { $title_key => $this->randomMachineName(8), ]; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Preview'); - $this->assertText($edit[$title_key]); + $this->assertSession()->pageTextContains($edit[$title_key]); $this->clickLink(t('Back to content editing')); $this->assertSession()->fieldValueEquals($title_key, $edit[$title_key]); // Navigate away from the node without saving. @@ -378,7 +378,7 @@ public function testPagePreview() { $this->assertRaw('Storage is set'); $this->assertSession()->fieldExists('field_test_multi[0][value]'); $this->submitForm([], 'Save'); - $this->assertText('Basic page ' . $title . ' has been created.'); + $this->assertSession()->pageTextContains('Basic page ' . $title . ' has been created.'); $node = $this->drupalGetNodeByTitle($title); $this->drupalGet('node/' . $node->id() . '/edit'); $this->getSession()->getPage()->pressButton('Add another item'); @@ -397,9 +397,9 @@ public function testPagePreview() { // Now save the node and make sure all values got saved. $this->submitForm([], 'Save'); - $this->assertText($example_text_1); - $this->assertText($example_text_2); - $this->assertText($example_text_3); + $this->assertSession()->pageTextContains($example_text_1); + $this->assertSession()->pageTextContains($example_text_2); + $this->assertSession()->pageTextContains($example_text_3); // Edit again, change the menu_ui settings and click on preview. $this->drupalGet('node/' . $node->id() . '/edit'); @@ -446,9 +446,9 @@ public function testPagePreviewWithRevisions() { // Check that the preview is displaying the title, body and term. $this->assertSession()->titleEquals($edit[$title_key] . ' | Drupal'); - $this->assertText($edit[$title_key]); - $this->assertText($edit[$body_key]); - $this->assertText($edit[$term_key]); + $this->assertSession()->pageTextContains($edit[$title_key]); + $this->assertSession()->pageTextContains($edit[$body_key]); + $this->assertSession()->pageTextContains($edit[$term_key]); // Check that the title and body fields are displayed with the correct // values after going back to the content edit page. @@ -488,7 +488,7 @@ public function testSimultaneousPreview() { $edit = [$title_key => 'New page title']; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Preview'); - $this->assertText($edit[$title_key]); + $this->assertSession()->pageTextContains($edit[$title_key]); $user2 = $this->drupalCreateUser(['edit any page content']); $this->drupalLogin($user2); @@ -498,7 +498,7 @@ public function testSimultaneousPreview() { $edit2 = [$title_key => 'Another page title']; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit2, 'Preview'); $this->assertSession()->addressEquals(Url::fromRoute('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'])); - $this->assertText($edit2[$title_key]); + $this->assertSession()->pageTextContains($edit2[$title_key]); } /** diff --git a/core/modules/node/tests/src/Functional/Views/BulkFormTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormTest.php index f25ee958ffb9..f8de141767b6 100644 --- a/core/modules/node/tests/src/Functional/Views/BulkFormTest.php +++ b/core/modules/node/tests/src/Functional/Views/BulkFormTest.php @@ -254,14 +254,14 @@ public function testBulkDeletion() { $this->submitForm($edit, 'Apply to selected items'); $label = $this->loadNode(1)->label(); - $this->assertText("$label (Original translation) - The following content item translations will be deleted:"); + $this->assertSession()->pageTextContains("$label (Original translation) - The following content item translations will be deleted:"); $label = $this->loadNode(2)->label(); - $this->assertText("$label (Original translation) - The following content item translations will be deleted:"); + $this->assertSession()->pageTextContains("$label (Original translation) - The following content item translations will be deleted:"); $label = $this->loadNode(3)->getTranslation('en')->label(); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); $this->assertNoText("$label (Original translation) - The following content item translations will be deleted:"); $label = $this->loadNode(4)->label(); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); $this->assertNoText("$label (Original translation) - The following content item translations will be deleted:"); $this->submitForm([], 'Delete'); @@ -278,7 +278,7 @@ public function testBulkDeletion() { $node = $this->loadNode(5); $this->assertNotEmpty($node, '5: Node has not been deleted'); - $this->assertText('Deleted 8 content items.'); + $this->assertSession()->pageTextContains('Deleted 8 content items.'); } /** diff --git a/core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php b/core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php index e102e3fb6b8e..399ba9e05a43 100644 --- a/core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php +++ b/core/modules/node/tests/src/Functional/Views/FilterNodeAccessTest.php @@ -87,18 +87,18 @@ public function testFilterNodeAccess() { $this->drupalLogin($this->users[0]); $this->drupalGet('test_filter_node_access'); // Test that the private node of the current user is shown. - $this->assertText('Private Article created by ' . $this->users[0]->getAccountName()); + $this->assertSession()->pageTextContains('Private Article created by ' . $this->users[0]->getAccountName()); // Test that the private node of the other use isn't shown. $this->assertNoText('Private Article created by ' . $this->users[1]->getAccountName()); // Test that both public nodes are shown. - $this->assertText('Public Article created by ' . $this->users[0]->getAccountName()); - $this->assertText('Public Article created by ' . $this->users[1]->getAccountName()); + $this->assertSession()->pageTextContains('Public Article created by ' . $this->users[0]->getAccountName()); + $this->assertSession()->pageTextContains('Public Article created by ' . $this->users[1]->getAccountName()); // Switch users and test the other private node is shown. $this->drupalLogin($this->users[1]); $this->drupalGet('test_filter_node_access'); // Test that the private node of the current user is shown. - $this->assertText('Private Article created by ' . $this->users[1]->getAccountName()); + $this->assertSession()->pageTextContains('Private Article created by ' . $this->users[1]->getAccountName()); // Test that the private node of the other use isn't shown. $this->assertNoText('Private Article created by ' . $this->users[0]->getAccountName()); @@ -111,8 +111,8 @@ public function testFilterNodeAccess() { $this->drupalGet('test_filter_node_access'); $this->assertNoText('Private Article created by ' . $this->users[0]->getAccountName()); $this->assertNoText('Private Article created by ' . $this->users[1]->getAccountName()); - $this->assertText('Public Article created by ' . $this->users[0]->getAccountName()); - $this->assertText('Public Article created by ' . $this->users[1]->getAccountName()); + $this->assertSession()->pageTextContains('Public Article created by ' . $this->users[0]->getAccountName()); + $this->assertSession()->pageTextContains('Public Article created by ' . $this->users[1]->getAccountName()); // Test that a user with bypass node access can see all nodes. $bypass_access_user = $this->drupalCreateUser([ @@ -121,10 +121,10 @@ public function testFilterNodeAccess() { ]); $this->drupalLogin($bypass_access_user); $this->drupalGet('test_filter_node_access'); - $this->assertText('Private Article created by ' . $this->users[0]->getAccountName()); - $this->assertText('Private Article created by ' . $this->users[1]->getAccountName()); - $this->assertText('Public Article created by ' . $this->users[0]->getAccountName()); - $this->assertText('Public Article created by ' . $this->users[1]->getAccountName()); + $this->assertSession()->pageTextContains('Private Article created by ' . $this->users[0]->getAccountName()); + $this->assertSession()->pageTextContains('Private Article created by ' . $this->users[1]->getAccountName()); + $this->assertSession()->pageTextContains('Public Article created by ' . $this->users[0]->getAccountName()); + $this->assertSession()->pageTextContains('Public Article created by ' . $this->users[1]->getAccountName()); } } diff --git a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php index a5bfe44f2362..bf1cc6ac20d7 100644 --- a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php +++ b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php @@ -372,7 +372,7 @@ protected function doTestFrontPageViewCacheTags($do_assert_views_caches) { $node->save(); $this->drupalGet(Url::fromRoute('view.frontpage.page_1')); - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } } diff --git a/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php b/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php index 3255241927cd..029ab634e955 100644 --- a/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php @@ -124,15 +124,15 @@ public function testLanguages() { $this->assertNoText($title); } else { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } } } // Test that the language field value is shown. $this->assertNoText('English'); - $this->assertText('French'); - $this->assertText('Spanish'); + $this->assertSession()->pageTextContains('French'); + $this->assertSession()->pageTextContains('Spanish'); // Test page sorting, which is by language code, ascending. So the // Spanish nodes should appear before the French nodes. @@ -153,7 +153,7 @@ public function testLanguages() { $message = 'Spanish argument page'; $this->assertNoText('English'); $this->assertNoText('French'); - $this->assertText('Spanish'); + $this->assertSession()->pageTextContains('Spanish'); // Test the front page view filter. Only node titles in the current language // should be displayed on the front page by default. @@ -164,7 +164,7 @@ public function testLanguages() { } $this->drupalGet(($langcode == 'en' ? '' : "$langcode/") . 'node'); foreach ($titles as $title) { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } foreach ($this->nodeTitles as $control_langcode => $control_titles) { if ($langcode != $control_langcode) { @@ -179,14 +179,14 @@ public function testLanguages() { $this->drupalGet('admin/content'); foreach ($this->nodeTitles as $titles) { foreach ($titles as $title) { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } } // When filtered, only the specific languages should show. foreach ($this->nodeTitles as $langcode => $titles) { $this->drupalGet('admin/content', ['query' => ['langcode' => $langcode]]); foreach ($titles as $title) { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } foreach ($this->nodeTitles as $control_langcode => $control_titles) { if ($langcode != $control_langcode) { @@ -211,7 +211,7 @@ public function testLanguages() { foreach ($this->nodeTitles as $control_langcode => $control_titles) { foreach ($control_titles as $title) { if ($control_langcode == 'en') { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } else { $this->assertNoText($title); @@ -239,7 +239,7 @@ public function testLanguages() { foreach ($this->nodeTitles as $control_langcode => $control_titles) { foreach ($control_titles as $title) { if ($control_langcode == 'es') { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } else { $this->assertNoText($title); @@ -285,16 +285,16 @@ public function testNativeLanguageField() { protected function assertLanguageNames($native = FALSE) { $this->drupalGet('test-language'); if ($native) { - $this->assertText('Français'); - $this->assertText('Español'); + $this->assertSession()->pageTextContains('Français'); + $this->assertSession()->pageTextContains('Español'); $this->assertNoText('French'); $this->assertNoText('Spanish'); } else { $this->assertNoText('Français'); $this->assertNoText('Español'); - $this->assertText('French'); - $this->assertText('Spanish'); + $this->assertSession()->pageTextContains('French'); + $this->assertSession()->pageTextContains('Spanish'); } } diff --git a/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php b/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php index a876ca3e039c..2c9a54c0a984 100644 --- a/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php +++ b/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php @@ -53,31 +53,31 @@ public function testStatusExtra() { // The administrator should simply see all nodes. $this->drupalLogin($admin_user); $this->drupalGet('test_status_extra'); - $this->assertText($node_published->label()); - $this->assertText($node_unpublished->label()); - $this->assertText($node_unpublished2->label()); - $this->assertText($node_unpublished3->label()); + $this->assertSession()->pageTextContains($node_published->label()); + $this->assertSession()->pageTextContains($node_unpublished->label()); + $this->assertSession()->pageTextContains($node_unpublished2->label()); + $this->assertSession()->pageTextContains($node_unpublished3->label()); // The privileged user should simply see all nodes. $this->drupalLogin($privileged_user); $this->drupalGet('test_status_extra'); - $this->assertText($node_published->label()); - $this->assertText($node_unpublished->label()); - $this->assertText($node_unpublished2->label()); - $this->assertText($node_unpublished3->label()); + $this->assertSession()->pageTextContains($node_published->label()); + $this->assertSession()->pageTextContains($node_unpublished->label()); + $this->assertSession()->pageTextContains($node_unpublished2->label()); + $this->assertSession()->pageTextContains($node_unpublished3->label()); // The node author should see the published node and their own node. $this->drupalLogin($node_author); $this->drupalGet('test_status_extra'); - $this->assertText($node_published->label()); + $this->assertSession()->pageTextContains($node_published->label()); $this->assertNoText($node_unpublished->label()); - $this->assertText($node_unpublished2->label()); + $this->assertSession()->pageTextContains($node_unpublished2->label()); $this->assertNoText($node_unpublished3->label()); // The normal user should just see the published node. $this->drupalLogin($normal_user); $this->drupalGet('test_status_extra'); - $this->assertText($node_published->label()); + $this->assertSession()->pageTextContains($node_published->label()); $this->assertNoText($node_unpublished->label()); $this->assertNoText($node_unpublished2->label()); $this->assertNoText($node_unpublished3->label()); @@ -86,7 +86,7 @@ public function testStatusExtra() { // just see the published node. $this->drupalLogin($node_author_not_unpublished); $this->drupalGet('test_status_extra'); - $this->assertText($node_published->label()); + $this->assertSession()->pageTextContains($node_published->label()); $this->assertNoText($node_unpublished->label()); $this->assertNoText($node_unpublished2->label()); $this->assertNoText($node_unpublished3->label()); diff --git a/core/modules/options/tests/src/Functional/OptionsFieldUITest.php b/core/modules/options/tests/src/Functional/OptionsFieldUITest.php index 3632a07e6b41..97f45e036f2f 100644 --- a/core/modules/options/tests/src/Functional/OptionsFieldUITest.php +++ b/core/modules/options/tests/src/Functional/OptionsFieldUITest.php @@ -322,7 +322,7 @@ public function assertAllowedValuesInput($input_string, $result, $message) { $this->assertNoRaw('&lt;'); if (is_string($result)) { - $this->assertText($result); + $this->assertSession()->pageTextContains($result); } else { $field_storage = FieldStorageConfig::loadByName('node', $this->fieldName); @@ -347,7 +347,7 @@ public function testNodeDisplay() { ]; $this->drupalPostForm($this->adminPath, $edit, 'Save field settings'); - $this->assertText('Updated field ' . $this->fieldName . ' field settings.'); + $this->assertSession()->pageTextContains('Updated field ' . $this->fieldName . ' field settings.'); // Select a default value. $edit = [ diff --git a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php index dde72e39d87c..0a09b5c8ee06 100644 --- a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php +++ b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php @@ -245,7 +245,7 @@ public function testCheckBoxes() { 'card_2[2]' => TRUE, ]; $this->submitForm($edit, 'Save'); - $this->assertText('this field cannot hold more than 2 values'); + $this->assertSession()->pageTextContains('this field cannot hold more than 2 values'); // Submit form: uncheck all options. $edit = [ @@ -427,7 +427,7 @@ public function testSelectListMultiple() { // Submit form: select the three options while the field accepts only 2. $edit = ['card_2[]' => [0 => 0, 1 => 1, 2 => 2]]; $this->submitForm($edit, 'Save'); - $this->assertText('this field cannot hold more than 2 values'); + $this->assertSession()->pageTextContains('this field cannot hold more than 2 values'); // Submit form: uncheck all options. $edit = ['card_2[]' => []]; diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php index 5f2c286aeae9..536e67dc67d2 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -325,7 +325,7 @@ public function testPageCacheAnonymousRolePermissions() { // 1. anonymous user, without permission. $this->drupalGet($content_url); - $this->assertText('Permission to pet llamas: no!'); + $this->assertSession()->pageTextContains('Permission to pet llamas: no!'); $this->assertCacheContext('user.permissions'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:user.role.anonymous'); $this->drupalGet($route_access_url); @@ -335,7 +335,7 @@ public function testPageCacheAnonymousRolePermissions() { // 2. anonymous user, with permission. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['pet llamas']); $this->drupalGet($content_url); - $this->assertText('Permission to pet llamas: yes!'); + $this->assertSession()->pageTextContains('Permission to pet llamas: yes!'); $this->assertCacheContext('user.permissions'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:user.role.anonymous'); $this->drupalGet($route_access_url); @@ -346,7 +346,7 @@ public function testPageCacheAnonymousRolePermissions() { $auth_user = $this->drupalCreateUser(); $this->drupalLogin($auth_user); $this->drupalGet($content_url); - $this->assertText('Permission to pet llamas: no!'); + $this->assertSession()->pageTextContains('Permission to pet llamas: no!'); $this->assertCacheContext('user.permissions'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'config:user.role.authenticated'); $this->drupalGet($route_access_url); @@ -356,7 +356,7 @@ public function testPageCacheAnonymousRolePermissions() { // 4. authenticated user, with permission. user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['pet llamas']); $this->drupalGet($content_url); - $this->assertText('Permission to pet llamas: yes!'); + $this->assertSession()->pageTextContains('Permission to pet llamas: yes!'); $this->assertCacheContext('user.permissions'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'config:user.role.authenticated'); $this->drupalGet($route_access_url); @@ -480,7 +480,7 @@ public function testFormImmutability() { $this->drupalGet('page_cache_form_test_immutability'); - $this->assertText("Immutable: TRUE"); + $this->assertSession()->pageTextContains("Immutable: TRUE"); // The immutable flag is set unconditionally by system_form_alter(), set // a flag to tell page_cache_form_test_module_implements_alter() to disable @@ -491,7 +491,7 @@ public function testFormImmutability() { $this->drupalGet('page_cache_form_test_immutability'); - $this->assertText("Immutable: FALSE"); + $this->assertSession()->pageTextContains("Immutable: FALSE"); } /** diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php index 82037ba17195..d9f3c78ff349 100644 --- a/core/modules/path/tests/src/Functional/PathAliasTest.php +++ b/core/modules/path/tests/src/Functional/PathAliasTest.php @@ -88,17 +88,17 @@ public function testAdminAlias() { // Confirm that the alias works. $this->drupalGet($edit['alias[0][value]']); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertSession()->statusCodeEquals(200); // Confirm that the alias works in a case-insensitive way. $this->assertTrue(ctype_lower(ltrim($edit['alias[0][value]'], '/'))); $this->drupalGet($edit['alias[0][value]']); // Lower case. - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertSession()->statusCodeEquals(200); $this->drupalGet(mb_strtoupper($edit['alias[0][value]'])); // Upper case. - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertSession()->statusCodeEquals(200); // Change alias to one containing "exotic" characters. @@ -126,7 +126,7 @@ public function testAdminAlias() { // Confirm that the alias works. $this->drupalGet(mb_strtoupper($edit['alias[0][value]'])); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertSession()->statusCodeEquals(200); $this->container->get('path_alias.manager')->cacheClear(); @@ -176,7 +176,7 @@ public function testAdminAlias() { // The untruncated alias should not be found. $this->assertNoText($alias); // The 'truncated' alias will always be found. - $this->assertText($truncated_alias); + $this->assertSession()->pageTextContains($truncated_alias); // Create third test node. $node3 = $this->drupalCreateNode(); @@ -201,7 +201,7 @@ public function testAdminAlias() { // Confirm that the alias with trailing slash is not found. $this->assertNoText($edit['alias[0][value]']); // The alias without trailing flash is found. - $this->assertText(trim($edit['alias[0][value]'], '/')); + $this->assertSession()->pageTextContains(trim($edit['alias[0][value]'], '/')); // Update an existing alias to point to a different source. $pid = $this->getPID($node4_alias); @@ -209,12 +209,12 @@ public function testAdminAlias() { $edit['alias[0][value]'] = $node4_alias; $edit['path[0][value]'] = '/node/' . $node2->id(); $this->drupalPostForm('admin/config/search/path/edit/' . $pid, $edit, 'Save'); - $this->assertText('The alias has been saved.'); + $this->assertSession()->pageTextContains('The alias has been saved.'); $this->drupalGet($edit['alias[0][value]']); // Previous alias should no longer work. $this->assertNoText($node4->label()); // Alias should work. - $this->assertText($node2->label()); + $this->assertSession()->pageTextContains($node2->label()); $this->assertSession()->statusCodeEquals(200); // Update an existing alias to use a duplicate alias. @@ -235,8 +235,8 @@ public function testAdminAlias() { $this->drupalPostForm('admin/config/search/path/add', $edit, 'Save'); $this->assertSession()->addressEquals('admin/config/search/path/add'); - $this->assertText('The source path has to start with a slash.'); - $this->assertText('The alias path has to start with a slash.'); + $this->assertSession()->pageTextContains('The source path has to start with a slash.'); + $this->assertSession()->pageTextContains('The alias path has to start with a slash.'); } /** @@ -253,7 +253,7 @@ public function testNodeAlias() { // Confirm that the alias works. $this->drupalGet($edit['path[0][alias]']); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertSession()->statusCodeEquals(200); // Confirm the 'canonical' and 'shortlink' URLs. @@ -285,7 +285,7 @@ public function testNodeAlias() { // Confirm that the alias works. $this->drupalGet(mb_strtoupper($edit['path[0][alias]'])); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertSession()->statusCodeEquals(200); // Make sure that previous alias no longer works. @@ -320,7 +320,7 @@ public function testNodeAlias() { // Confirm that the alias was converted to a relative path. $this->drupalGet(trim($edit['path[0][alias]'], '/')); - $this->assertText($node3->label()); + $this->assertSession()->pageTextContains($node3->label()); $this->assertSession()->statusCodeEquals(200); // Create fourth test node. @@ -332,7 +332,7 @@ public function testNodeAlias() { // Confirm that the alias was converted to a relative path. $this->drupalGet(trim($edit['path[0][alias]'], '/')); - $this->assertText($node4->label()); + $this->assertSession()->pageTextContains($node4->label()); $this->assertSession()->statusCodeEquals(200); // Create fifth test node. diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php index 9d066b50eadb..e1ad8df14666 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php @@ -92,7 +92,7 @@ public function testAliasTranslation() { // Confirm that the alias works. $this->drupalGet($english_alias); - $this->assertText($english_node->body->value); + $this->assertSession()->pageTextContains($english_node->body->value); // Translate the node into French. $this->drupalGet('node/' . $english_node->id() . '/translations'); @@ -121,7 +121,7 @@ public function testAliasTranslation() { // Confirm that the alias works. $this->drupalGet('fr' . $edit['path[0][alias]']); - $this->assertText($english_node_french_translation->body->value); + $this->assertSession()->pageTextContains($english_node_french_translation->body->value); // Confirm that the alias is returned for the URL. Languages are cached on // many levels, and we need to clear those caches. @@ -154,11 +154,11 @@ public function testAliasTranslation() { // path alias for French matching the english alias. So the alias manager // needs to use the URL language to check whether the alias is valid. $this->drupalGet($english_alias); - $this->assertText($english_node_french_translation->body->value); + $this->assertSession()->pageTextContains($english_node_french_translation->body->value); // Check that the French alias works. $this->drupalGet("fr/$french_alias"); - $this->assertText($english_node_french_translation->body->value); + $this->assertSession()->pageTextContains($english_node_french_translation->body->value); // Disable URL language negotiation. $edit = ['language_interface[enabled][language-url]' => FALSE]; @@ -166,7 +166,7 @@ public function testAliasTranslation() { // Check that the English alias still works. $this->drupalGet($english_alias); - $this->assertText($english_node_french_translation->body->value); + $this->assertSession()->pageTextContains($english_node_french_translation->body->value); // Check that the French alias is not available. We check the unprefixed // alias because we disabled URL language negotiation above. In this @@ -199,7 +199,7 @@ public function testAliasTranslation() { // Check that the English alias still works. $this->drupalGet($english_alias); $this->assertPathAliasExists('/' . $english_alias, 'en', NULL, 'English alias is not deleted when French translation is removed.'); - $this->assertText($english_node->body->value); + $this->assertSession()->pageTextContains($english_node->body->value); } } diff --git a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php index be76a8f878ee..8c03409a3699 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php @@ -59,7 +59,7 @@ public function testLanguageNeutralUrl() { $this->drupalPostForm('admin/config/search/path/add', $edit, 'Save'); $this->drupalGet($name); - $this->assertText('Filter aliases'); + $this->assertSession()->pageTextContains('Filter aliases'); } /** @@ -74,7 +74,7 @@ public function testDefaultLanguageUrl() { $this->drupalPostForm('admin/config/search/path/add', $edit, 'Save'); $this->drupalGet($name); - $this->assertText('Filter aliases'); + $this->assertSession()->pageTextContains('Filter aliases'); } /** @@ -89,7 +89,7 @@ public function testNonDefaultUrl() { $this->drupalPostForm('admin/config/search/path/add', $edit, 'Save'); $this->drupalGet('fr/' . $name); - $this->assertText('Filter aliases'); + $this->assertSession()->pageTextContains('Filter aliases'); } /** diff --git a/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php b/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php index 607d90d61ccd..bcddbc4c697f 100644 --- a/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php +++ b/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php @@ -64,7 +64,7 @@ public function testTermAlias() { // Confirm that the alias works. $this->drupalGet($edit['path[0][alias]']); - $this->assertText($description); + $this->assertSession()->pageTextContains($description); // Confirm the 'canonical' and 'shortlink' URLs. $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . $edit['path[0][alias]'] . "')]"); @@ -79,7 +79,7 @@ public function testTermAlias() { // Confirm that the changed alias works. $this->drupalGet(trim($edit2['path[0][alias]'], '/')); - $this->assertText($description); + $this->assertSession()->pageTextContains($description); // Confirm that the old alias no longer works. $this->drupalGet(trim($edit['path[0][alias]'], '/')); diff --git a/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php b/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php index 6acdfee062bd..cfc6b2a4dc51 100644 --- a/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php +++ b/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php @@ -59,7 +59,7 @@ public function testUrlAlter() { // Test adding an alias via the UI. $edit = ['path[0][value]' => "/user/$uid/edit", 'alias[0][value]' => '/alias/test2']; $this->drupalPostForm('admin/config/search/path/add', $edit, 'Save'); - $this->assertText('The alias has been saved.'); + $this->assertSession()->pageTextContains('The alias has been saved.'); $this->drupalGet('alias/test2'); $this->assertSession()->statusCodeEquals(200); $this->assertUrlOutboundAlter("/user/$uid/edit", '/alias/test2'); @@ -71,7 +71,7 @@ public function testUrlAlter() { // Test that 'forum' is altered to 'community' correctly, both at the root // level and for a specific existing forum. $this->drupalGet('community'); - $this->assertText('General discussion'); + $this->assertSession()->pageTextContains('General discussion'); $this->assertUrlOutboundAlter('/forum', '/community'); $forum_vid = $this->config('forum.settings')->get('vocabulary'); $term_name = $this->randomMachineName(); @@ -81,7 +81,7 @@ public function testUrlAlter() { ]); $term->save(); $this->drupalGet("community/" . $term->id()); - $this->assertText($term_name); + $this->assertSession()->pageTextContains($term_name); $this->assertUrlOutboundAlter("/forum/" . $term->id(), "/community/" . $term->id()); // Test outbound query string altering. diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php index bb8efbd99daa..a5d79d7b2e8a 100644 --- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php +++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php @@ -44,7 +44,7 @@ protected function setUp(): void { public function testResponsiveImageAdmin() { // We start without any default styles. $this->drupalGet('admin/config/media/responsive-image-style'); - $this->assertText('There are no responsive image styles yet.'); + $this->assertSession()->pageTextContains('There are no responsive image styles yet.'); // Add a responsive image style. $this->drupalGet('admin/config/media/responsive-image-style/add'); @@ -64,7 +64,7 @@ public function testResponsiveImageAdmin() { $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/config/media/responsive-image-style'); $this->assertNoText('There are no responsive image styles yet.'); - $this->assertText('Style One'); + $this->assertSession()->pageTextContains('Style One'); // Edit the group. $this->drupalGet('admin/config/media/responsive-image-style/style_one'); @@ -140,7 +140,7 @@ public function testResponsiveImageAdmin() { $this->drupalGet('admin/config/media/responsive-image-style/style_one/delete'); $this->submitForm([], 'Delete'); $this->drupalGet('admin/config/media/responsive-image-style'); - $this->assertText('There are no responsive image styles yet.'); + $this->assertSession()->pageTextContains('There are no responsive image styles yet.'); } } diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php index e8fb69ce9033..86080f5bf9a8 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php @@ -490,7 +490,7 @@ public function testUIFieldAlias() { $edit = ['row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']]; $this->drupalPostForm($row_options, $edit, 'Apply'); - $this->assertText('The machine-readable name must contain only letters, numbers, dashes and underscores.'); + $this->assertSession()->pageTextContains('The machine-readable name must contain only letters, numbers, dashes and underscores.'); // Change the map alias value to a valid one. $alias_map['nothing'] = $this->randomMachineName(); diff --git a/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php b/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php index b17664e98636..838a3a8c7070 100644 --- a/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php @@ -65,19 +65,19 @@ public function testNodeType() { // Search for the title of the node with a GET query. $this->drupalGet('search/node', ['query' => ['keys' => $this->node->label()]]); - $this->assertText($this->node->label()); + $this->assertSession()->pageTextContains($this->node->label()); // Search for the title of the node with a POST query. $edit = ['or' => $this->node->label()]; $this->drupalPostForm('search/node', $edit, 'edit-submit--2'); - $this->assertText($this->node->label()); + $this->assertSession()->pageTextContains($this->node->label()); // Search by node type. $this->drupalPostForm('search/node', array_merge($edit, ['type[page]' => 'page']), 'edit-submit--2'); - $this->assertText($this->node->label()); + $this->assertSession()->pageTextContains($this->node->label()); $this->drupalPostForm('search/node', array_merge($edit, ['type[article]' => 'article']), 'edit-submit--2'); - $this->assertText('search yielded no results'); + $this->assertSession()->pageTextContains('search yielded no results'); } /** @@ -96,7 +96,7 @@ public function testFormRefill() { // Test that the encoded query appears in the page title. Only test the // part not including the quote, because assertText() cannot seem to find // the quote marks successfully. - $this->assertText('Search for cat dog OR gerbil -fish -snake'); + $this->assertSession()->pageTextContains('Search for cat dog OR gerbil -fish -snake'); // Verify that all of the form fields are filled out. foreach ($edit as $key => $value) { @@ -113,7 +113,7 @@ public function testFormRefill() { // (It shouldn't be filled out unless you submit values in those fields.) $edit2 = ['keys' => 'cat dog OR gerbil -fish -snake']; $this->drupalPostForm('search/node', $edit2, 'edit-submit--2'); - $this->assertText('Search for cat dog OR gerbil -fish -snake'); + $this->assertSession()->pageTextContains('Search for cat dog OR gerbil -fish -snake'); foreach ($edit as $key => $value) { if ($key != 'type[page]') { $this->assertSession()->fieldValueNotEquals($key, $value); diff --git a/core/modules/search/tests/src/Functional/SearchBlockTest.php b/core/modules/search/tests/src/Functional/SearchBlockTest.php index a665f8ee21fa..509f8f7fa061 100644 --- a/core/modules/search/tests/src/Functional/SearchBlockTest.php +++ b/core/modules/search/tests/src/Functional/SearchBlockTest.php @@ -59,7 +59,7 @@ public function testSearchFormBlock() { $block = $this->drupalPlaceBlock('search_form_block'); $this->drupalGet(''); - $this->assertText($block->label()); + $this->assertSession()->pageTextContains($block->label()); // Check that name attribute is not empty. $pattern = "//input[@type='submit' and @name='']"; @@ -70,14 +70,14 @@ public function testSearchFormBlock() { $terms = ['keys' => 'test']; $this->drupalPostForm('', $terms, 'Search'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Your search yielded no results'); + $this->assertSession()->pageTextContains('Your search yielded no results'); // Test a search from the block on a 404 page. $this->drupalGet('foo'); $this->assertSession()->statusCodeEquals(404); $this->submitForm($terms, 'Search'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Your search yielded no results'); + $this->assertSession()->pageTextContains('Your search yielded no results'); $visibility = $block->getVisibility(); $visibility['request_path']['pages'] = 'search'; @@ -85,7 +85,7 @@ public function testSearchFormBlock() { $this->drupalPostForm('', $terms, 'Search'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Your search yielded no results'); + $this->assertSession()->pageTextContains('Your search yielded no results'); // Confirm that the form submits to the default search page. /** @var \Drupal\search\SearchPageRepositoryInterface $search_page_repository */ @@ -101,7 +101,7 @@ public function testSearchFormBlock() { $terms = ['keys' => '']; $this->drupalPostForm('', $terms, 'Search'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Please enter some keywords'); + $this->assertSession()->pageTextContains('Please enter some keywords'); // Confirm that the user is redirected to the search page, when form is // submitted empty. @@ -114,7 +114,7 @@ public function testSearchFormBlock() { // Test that after entering a too-short keyword in the form, you can then // search again with a longer keyword. First test using the block form. $this->drupalPostForm('node', ['keys' => $this->randomMachineName(1)], 'Search'); - $this->assertText('You must include at least one keyword to match in the content'); + $this->assertSession()->pageTextContains('You must include at least one keyword to match in the content'); $this->assertNoText('Please enter some keywords'); $this->submitForm(['keys' => $this->randomMachineName()], 'Search', 'search-block-form'); $this->assertNoText('You must include at least one keyword to match in the content'); diff --git a/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php b/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php index 247465c54073..55a24a54e2c4 100644 --- a/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php +++ b/core/modules/search/tests/src/Functional/SearchCommentCountToggleTest.php @@ -95,8 +95,8 @@ public function testSearchCommentCountToggle() { // Test comment count display for nodes with comment status set to Open $this->submitForm($edit, 'Search'); - $this->assertText('0 comments'); - $this->assertText('1 comment'); + $this->assertSession()->pageTextContains('0 comments'); + $this->assertSession()->pageTextContains('1 comment'); // Test comment count display for nodes with comment status set to Closed $this->searchableNodes['0 comments']->set('comment', CommentItemInterface::CLOSED); @@ -106,7 +106,7 @@ public function testSearchCommentCountToggle() { $this->submitForm($edit, 'Search'); $this->assertNoText('0 comments'); - $this->assertText('1 comment'); + $this->assertSession()->pageTextContains('1 comment'); // Test comment count display for nodes with comment status set to Hidden $this->searchableNodes['0 comments']->set('comment', CommentItemInterface::HIDDEN); diff --git a/core/modules/search/tests/src/Functional/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php index 97da6e1527e9..7f522e4f5fa3 100644 --- a/core/modules/search/tests/src/Functional/SearchCommentTest.php +++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php @@ -160,18 +160,18 @@ public function testSearchResultsComment() { $this->drupalPostForm('search/node', $edit, 'Search'); $node_storage->resetCache([$node->id()]); $node2 = $node_storage->load($node->id()); - $this->assertText($node2->label()); - $this->assertText($edit_comment['subject[0][value]']); + $this->assertSession()->pageTextContains($node2->label()); + $this->assertSession()->pageTextContains($edit_comment['subject[0][value]']); // Search for the comment body. $edit = [ 'keys' => "'" . $comment_body . "'", ]; $this->submitForm($edit, 'Search'); - $this->assertText($node2->label()); + $this->assertSession()->pageTextContains($node2->label()); // Verify that comment is rendered using proper format. - $this->assertText($comment_body); + $this->assertSession()->pageTextContains($comment_body); // Verify that HTML in comment body is not hidden. $this->assertNoRaw(t('n/a')); $this->assertSession()->assertNoEscaped($edit_comment['comment_body[0][value]']); @@ -220,7 +220,7 @@ public function testSearchResultsComment() { // Search for $title. $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('Your search yielded no results.'); + $this->assertSession()->pageTextContains('Your search yielded no results.'); } /** @@ -347,7 +347,7 @@ public function testAddNewComment() { // Verify that if you view the node on its own page, 'add new comment' // is there. $this->drupalGet('node/' . $node->id()); - $this->assertText('Add new comment'); + $this->assertSession()->pageTextContains('Add new comment'); // Run cron to index this page. $this->drupalLogout(); @@ -356,12 +356,12 @@ public function testAddNewComment() { // Search for 'comment'. Should be no results. $this->drupalLogin($user); $this->drupalPostForm('search/node', ['keys' => 'comment'], 'Search'); - $this->assertText('Your search yielded no results'); + $this->assertSession()->pageTextContains('Your search yielded no results'); // Search for the node title. Should be found, and 'Add new comment' should // not be part of the search snippet. $this->drupalPostForm('search/node', ['keys' => 'short'], 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); $this->assertNoText('Add new comment'); } diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index 79ffa062c3b3..0abe5ed7a7d0 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -87,19 +87,19 @@ public function testSearchSettingsPage() { // Test that the settings form displays the correct count of items left to index. $this->drupalGet('admin/config/search/pages'); - $this->assertText('There are 0 items left to index.'); + $this->assertSession()->pageTextContains('There are 0 items left to index.'); // Test the re-index button. $this->drupalPostForm('admin/config/search/pages', [], 'Re-index site'); - $this->assertText('Are you sure you want to re-index the site'); + $this->assertSession()->pageTextContains('Are you sure you want to re-index the site'); $this->drupalPostForm('admin/config/search/pages/reindex', [], 'Re-index site'); - $this->assertText('All search indexes will be rebuilt'); + $this->assertSession()->pageTextContains('All search indexes will be rebuilt'); $this->drupalGet('admin/config/search/pages'); - $this->assertText('There is 1 item left to index.'); + $this->assertSession()->pageTextContains('There is 1 item left to index.'); // Test that the form saves with the default values. $this->drupalPostForm('admin/config/search/pages', [], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); // Test that the form does not save with an invalid word length. $edit = [ @@ -183,7 +183,7 @@ public function testSearchModuleDisabling() { $this->drupalGet('search/' . $entity->getPath(), ['query' => ['keys' => $info['keys']]]); $this->assertSession()->statusCodeEquals(200); $this->assertNoText('no results'); - $this->assertText($info['text']); + $this->assertSession()->pageTextContains($info['text']); // Verify that other plugin search tab labels are not visible. foreach ($plugins as $other) { @@ -228,7 +228,7 @@ public function testSearchModuleDisabling() { $this->drupalGet($item['path'], $item['options']); foreach ($plugins as $entity_id) { $label = $entities[$entity_id]->label(); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); } } } @@ -256,7 +256,7 @@ public function testMultipleSearchPages() { // Ensure that no search pages are configured. $this->drupalGet('admin/config/search/pages'); - $this->assertText('No search pages have been configured.'); + $this->assertSession()->pageTextContains('No search pages have been configured.'); // Add a search page. $edit = []; @@ -281,7 +281,7 @@ public function testMultipleSearchPages() { $edit['id'] = strtolower($this->randomMachineName(8)); $edit['path'] = $first['path']; $this->submitForm($edit, 'Save'); - $this->assertText('The search page path must be unique.'); + $this->assertSession()->pageTextContains('The search page path must be unique.'); // Add a second search page. $second = []; diff --git a/core/modules/search/tests/src/Functional/SearchEmbedFormTest.php b/core/modules/search/tests/src/Functional/SearchEmbedFormTest.php index 2e351bc71d9b..5f4b4e06422f 100644 --- a/core/modules/search/tests/src/Functional/SearchEmbedFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchEmbedFormTest.php @@ -63,16 +63,16 @@ protected function setUp(): void { public function testEmbeddedForm() { // First verify we can submit the form from the module's page. $this->drupalPostForm('search_embedded_form', ['name' => 'John'], 'Send away'); - $this->assertText('Test form was submitted'); + $this->assertSession()->pageTextContains('Test form was submitted'); $count = \Drupal::state()->get('search_embedded_form.submit_count'); $this->assertEquals($this->submitCount + 1, $count, 'Form submission count is correct'); $this->submitCount = $count; // Now verify that we can see and submit the form from the search results. $this->drupalGet('search/node', ['query' => ['keys' => $this->node->label()]]); - $this->assertText('Your name'); + $this->assertSession()->pageTextContains('Your name'); $this->submitForm(['name' => 'John'], 'Send away'); - $this->assertText('Test form was submitted'); + $this->assertSession()->pageTextContains('Test form was submitted'); $count = \Drupal::state()->get('search_embedded_form.submit_count'); $this->assertEquals($this->submitCount + 1, $count, 'Form submission count is correct'); $this->submitCount = $count; diff --git a/core/modules/search/tests/src/Functional/SearchExactTest.php b/core/modules/search/tests/src/Functional/SearchExactTest.php index 281541d2e69f..54d60078fac8 100644 --- a/core/modules/search/tests/src/Functional/SearchExactTest.php +++ b/core/modules/search/tests/src/Functional/SearchExactTest.php @@ -76,8 +76,8 @@ public function testExactQuery() { $edit = ['keys' => 'Druplicon']; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText($user->getAccountName()); - $this->assertText($this->container->get('date.formatter')->format($node->getChangedTime(), 'short')); + $this->assertSession()->pageTextContains($user->getAccountName()); + $this->assertSession()->pageTextContains($this->container->get('date.formatter')->format($node->getChangedTime(), 'short')); // Check that with post settings turned off the user and changed date // information is not displayed. diff --git a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php index 81ae44582be4..563fcedf65ee 100644 --- a/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php +++ b/core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php @@ -62,14 +62,14 @@ public function testSearchKeywordsConditions() { // With keys - get results. $keys = 'bike shed ' . $this->randomMachineName(); $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]); - $this->assertText("Dummy search snippet to display. Keywords: {$keys}"); + $this->assertSession()->pageTextContains("Dummy search snippet to display. Keywords: {$keys}"); $keys = 'blue drop ' . $this->randomMachineName(); $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]); - $this->assertText("Dummy search snippet to display. Keywords: {$keys}"); + $this->assertSession()->pageTextContains("Dummy search snippet to display. Keywords: {$keys}"); // Add some conditions and keys. $keys = 'moving drop ' . $this->randomMachineName(); $this->drupalGet("search/dummy_path", ['query' => ['keys' => 'bike', 'search_conditions' => $keys]]); - $this->assertText("Dummy search snippet to display."); + $this->assertSession()->pageTextContains("Dummy search snippet to display."); $this->assertRaw(Html::escape(print_r(['keys' => 'bike', 'search_conditions' => $keys], TRUE))); } diff --git a/core/modules/search/tests/src/Functional/SearchLanguageTest.php b/core/modules/search/tests/src/Functional/SearchLanguageTest.php index 5b18be2774f1..710a1bdbf7bf 100644 --- a/core/modules/search/tests/src/Functional/SearchLanguageTest.php +++ b/core/modules/search/tests/src/Functional/SearchLanguageTest.php @@ -104,13 +104,13 @@ public function testLanguages() { // Add predefined language. $edit = ['predefined_langcode' => 'fr']; $this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language'); - $this->assertText('French'); + $this->assertSession()->pageTextContains('French'); // Now we should have languages displayed. $this->drupalGet('search/node'); - $this->assertText('Languages'); - $this->assertText('English'); - $this->assertText('French'); + $this->assertSession()->pageTextContains('Languages'); + $this->assertSession()->pageTextContains('English'); + $this->assertSession()->pageTextContains('French'); // Ensure selecting no language does not make the query different. $this->drupalPostForm('search/node', [], 'edit-submit--2'); diff --git a/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php b/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php index 2d8c2799ba38..fc55dcd1d0bb 100644 --- a/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php +++ b/core/modules/search/tests/src/Functional/SearchMultilingualEntityTest.php @@ -296,17 +296,17 @@ protected function assertIndexCounts($remaining, $total, $message) { $indexed = $total - $remaining; $percent = ($total > 0) ? floor(100 * $indexed / $total) : 100; $this->drupalGet('admin/config/search/pages'); - $this->assertText($percent . '% of the site has been indexed.'); - $this->assertText($remaining . ' item'); + $this->assertSession()->pageTextContains($percent . '% of the site has been indexed.'); + $this->assertSession()->pageTextContains($remaining . ' item'); // Check text in pages section of Search settings page. - $this->assertText($indexed . ' of ' . $total . ' indexed'); + $this->assertSession()->pageTextContains($indexed . ' of ' . $total . ' indexed'); // Check text on status report page. $this->drupalGet('admin/reports/status'); - $this->assertText('Search index progress'); - $this->assertText($percent . '%'); - $this->assertText('(' . $remaining . ' remaining)'); + $this->assertSession()->pageTextContains('Search index progress'); + $this->assertSession()->pageTextContains($percent . '%'); + $this->assertSession()->pageTextContains('(' . $remaining . ' remaining)'); } /** diff --git a/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php b/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php index 98ceb351c810..a26c6ab24811 100644 --- a/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php +++ b/core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php @@ -61,7 +61,7 @@ public function testPhraseSearchPunctuation() { // Submit a phrase wrapped in double quotes to include the punctuation. $edit = ['keys' => '"bunny\'s"']; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); // Check if the author is linked correctly to the user profile page. $username = $node->getOwner()->getAccountName(); @@ -71,12 +71,12 @@ public function testPhraseSearchPunctuation() { $edit = ['keys' => '&']; $this->drupalPostForm('search/node', $edit, 'Search'); $this->assertNoRaw('<strong>&</strong>amp;'); - $this->assertText('You must include at least one keyword'); + $this->assertSession()->pageTextContains('You must include at least one keyword'); $edit = ['keys' => '&']; $this->drupalPostForm('search/node', $edit, 'Search'); $this->assertNoRaw('<strong>&</strong>amp;'); - $this->assertText('You must include at least one keyword'); + $this->assertSession()->pageTextContains('You must include at least one keyword'); } } diff --git a/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php b/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php index 5f7fc07e4123..719faccc8f5d 100644 --- a/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php +++ b/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php @@ -63,7 +63,7 @@ public function testSearchIndexUpdateOnNodeChange() { // Search the node to verify it appears in search results $edit = ['keys' => 'knights']; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); // Update the node $node->body->value = "We want a shrubbery!"; @@ -75,7 +75,7 @@ public function testSearchIndexUpdateOnNodeChange() { // Search again to verify the new text appears in test results. $edit = ['keys' => 'shrubbery']; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } /** @@ -96,7 +96,7 @@ public function testSearchIndexUpdateOnNodeDeletion() { // Search the node to verify it appears in search results $edit = ['keys' => 'dragons']; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); // Get the node info from the search index tables. $connection = Database::getConnection(); diff --git a/core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php b/core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php index 47bfa18e9d0b..82ce2db7e701 100644 --- a/core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php +++ b/core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php @@ -84,7 +84,7 @@ protected function setUp(): void { // Run cron to ensure the content is indexed. $this->cronRun(); $this->drupalGet('admin/reports/dblog'); - $this->assertText('Cron run completed'); + $this->assertSession()->pageTextContains('Cron run completed'); } /** @@ -108,7 +108,7 @@ public function testNumberSearching() { $number = ltrim($number, '-'); $this->drupalPostForm('search/node', ['keys' => $number], 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } } diff --git a/core/modules/search/tests/src/Functional/SearchNumbersTest.php b/core/modules/search/tests/src/Functional/SearchNumbersTest.php index 1dbb4c13f175..1af4c350a68e 100644 --- a/core/modules/search/tests/src/Functional/SearchNumbersTest.php +++ b/core/modules/search/tests/src/Functional/SearchNumbersTest.php @@ -91,7 +91,7 @@ protected function setUp(): void { // Run cron to ensure the content is indexed. $this->cronRun(); $this->drupalGet('admin/reports/dblog'); - $this->assertText('Cron run completed'); + $this->assertSession()->pageTextContains('Cron run completed'); } /** @@ -115,7 +115,7 @@ public function testNumberSearching() { // Verify that the node title does appear as a link on the search page // when searching for the number. $this->drupalPostForm('search/node', ['keys' => $number], 'Search'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } } diff --git a/core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php b/core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php index fd45196cc2a2..f2710bf0e796 100644 --- a/core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php +++ b/core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php @@ -81,7 +81,7 @@ public function testSearchText() { $edit = []; $edit['keys'] = 'bike shed'; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('bike shed shop'); + $this->assertSession()->pageTextContains('bike shed shop'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:search.page.node_search'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'search_index'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'search_index:node_search'); @@ -95,7 +95,7 @@ public function testSearchText() { $this->node->title = 'bike shop'; $this->node->save(); $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('bike shop'); + $this->assertSession()->pageTextContains('bike shop'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:search.page.node_search'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'search_index'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'search_index:node_search'); @@ -108,7 +108,7 @@ public function testSearchText() { // Deleting a node should invalidate the search plugin's index cache tag. $this->node->delete(); $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('Your search yielded no results.'); + $this->assertSession()->pageTextContains('Your search yielded no results.'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:search.page.node_search'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'search_index'); $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'search_index:node_search'); @@ -177,7 +177,7 @@ public function testSearchTagsBubbling() { // Test that the value of the entity reference field is shown. $this->drupalGet('node/2'); - $this->assertText('bike shed shop'); + $this->assertSession()->pageTextContains('bike shed shop'); // Refresh the search index. $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); @@ -201,8 +201,8 @@ public function testSearchTagsBubbling() { $edit = []; $edit['keys'] = 'shop'; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('bike shed shop'); - $this->assertText('Llama shop'); + $this->assertSession()->pageTextContains('bike shed shop'); + $this->assertSession()->pageTextContains('Llama shop'); $expected_cache_tags = Cache::mergeTags($default_search_tags, [ 'node:1', 'user:2', @@ -219,7 +219,7 @@ public function testSearchTagsBubbling() { $edit = []; $edit['keys'] = 'Llama'; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('Llama shop'); + $this->assertSession()->pageTextContains('Llama shop'); $expected_cache_tags = Cache::mergeTags($default_search_tags, [ 'node:1', 'node:2', diff --git a/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php b/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php index 4d9346ee607b..60699409aa98 100644 --- a/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php +++ b/core/modules/search/tests/src/Functional/SearchPageOverrideTest.php @@ -45,8 +45,8 @@ protected function setUp(): void { public function testSearchPageHook() { $keys = 'bike shed ' . $this->randomMachineName(); $this->drupalGet("search/dummy_path", ['query' => ['keys' => $keys]]); - $this->assertText('Dummy search snippet'); - $this->assertText('Test page text is here'); + $this->assertSession()->pageTextContains('Dummy search snippet'); + $this->assertSession()->pageTextContains('Test page text is here'); } } diff --git a/core/modules/search/tests/src/Functional/SearchPageTextTest.php b/core/modules/search/tests/src/Functional/SearchPageTextTest.php index 1d9cb180a9f2..501cd5fb5552 100644 --- a/core/modules/search/tests/src/Functional/SearchPageTextTest.php +++ b/core/modules/search/tests/src/Functional/SearchPageTextTest.php @@ -70,25 +70,25 @@ public function testSearchLabelXSS() { public function testSearchText() { $this->drupalLogin($this->searchingUser); $this->drupalGet('search/node'); - $this->assertText('Enter your keywords'); - $this->assertText('Search'); + $this->assertSession()->pageTextContains('Enter your keywords'); + $this->assertSession()->pageTextContains('Search'); $this->assertSession()->titleEquals('Search | Drupal'); $edit = []; $search_terms = 'bike shed ' . $this->randomMachineName(); $edit['keys'] = $search_terms; $this->drupalPostForm('search/node', $edit, 'Search'); - $this->assertText('search yielded no results'); - $this->assertText('Search'); + $this->assertSession()->pageTextContains('search yielded no results'); + $this->assertSession()->pageTextContains('Search'); $title_source = 'Search for @keywords | Drupal'; $this->assertSession()->titleEquals('Search for ' . Unicode::truncate($search_terms, 60, TRUE, TRUE) . ' | Drupal'); $this->assertNoText('Node'); $this->assertNoText('Node'); - $this->assertText('Content'); + $this->assertSession()->pageTextContains('Content'); $this->clickLink('About searching'); - $this->assertText('About searching'); - $this->assertText('Use upper-case OR to get more results'); + $this->assertSession()->pageTextContains('About searching'); + $this->assertSession()->pageTextContains('Use upper-case OR to get more results'); // Search for a longer text, and see that it is in the title, truncated. $edit = []; @@ -106,12 +106,12 @@ public function testSearchText() { $edit['keys'] = $this->searchingUser->getAccountName(); $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText('Search'); + $this->assertSession()->pageTextContains('Search'); $this->assertSession()->titleEquals('Search for ' . Unicode::truncate($this->searchingUser->getAccountName(), 60, TRUE, TRUE) . ' | Drupal'); $this->clickLink('About searching'); - $this->assertText('About searching'); - $this->assertText('user names and partial user names'); + $this->assertSession()->pageTextContains('About searching'); + $this->assertSession()->pageTextContains('user names and partial user names'); // Test that search keywords containing slashes are correctly loaded // from the GET params and displayed in the search form. @@ -137,9 +137,9 @@ public function testSearchText() { // Test that a search on Node or User with no keywords entered generates // the "Please enter some keywords" message. $this->drupalPostForm('search/node', [], 'Search'); - $this->assertText('Please enter some keywords'); + $this->assertSession()->pageTextContains('Please enter some keywords'); $this->drupalPostForm('search/user', [], 'Search'); - $this->assertText('Please enter some keywords'); + $this->assertSession()->pageTextContains('Please enter some keywords'); // Make sure the "Please enter some keywords" message is NOT displayed if // you use "or" words or phrases in Advanced Search. @@ -152,7 +152,7 @@ public function testSearchText() { // message, and that if after that you search for a longer keyword, you // do not still see the message. $this->drupalPostForm('search/node', ['keys' => $this->randomMachineName(1)], 'Search'); - $this->assertText('You must include at least one keyword'); + $this->assertSession()->pageTextContains('You must include at least one keyword'); $this->assertNoText('Please enter some keywords'); $this->submitForm(['keys' => $this->randomMachineName()], 'Search'); $this->assertNoText('You must include at least one keyword'); @@ -161,13 +161,13 @@ public function testSearchText() { // the search page. See issue https://www.drupal.org/node/890058. $this->drupalPostForm('search/node', ['keys' => '../../admin'], 'Search'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('no results'); + $this->assertSession()->pageTextContains('no results'); // Test that if you search for a URL starting with "./", you still end up // at the search page. See issue https://www.drupal.org/node/1421560. $this->drupalPostForm('search/node', ['keys' => '.something'], 'Search'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('no results'); + $this->assertSession()->pageTextContains('no results'); } } diff --git a/core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php b/core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php index cebfc2a2ad3b..45cdd6dac3fb 100644 --- a/core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php +++ b/core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php @@ -59,7 +59,7 @@ public function testPreprocessLangcode() { $this->drupalPostForm('search/node', $edit, 'edit-submit--2'); // Checks if the langcode message has been set by hook_search_preprocess(). - $this->assertText('Langcode Preprocess Test: en'); + $this->assertSession()->pageTextContains('Langcode Preprocess Test: en'); } /** @@ -81,16 +81,16 @@ public function testPreprocessStemming() { $this->drupalPostForm('search/node', $edit, 'edit-submit--2'); // Check if the node has been found. - $this->assertText('Search results'); - $this->assertText('we are testing'); + $this->assertSession()->pageTextContains('Search results'); + $this->assertSession()->pageTextContains('we are testing'); // Search for the same node using a different query. $edit = ['or' => 'test']; $this->drupalPostForm('search/node', $edit, 'edit-submit--2'); // Check if the node has been found. - $this->assertText('Search results'); - $this->assertText('we are testing'); + $this->assertSession()->pageTextContains('Search results'); + $this->assertSession()->pageTextContains('we are testing'); } } diff --git a/core/modules/search/tests/src/Functional/SearchQueryAlterTest.php b/core/modules/search/tests/src/Functional/SearchQueryAlterTest.php index c81e6cd98bec..6587cc3d11ec 100644 --- a/core/modules/search/tests/src/Functional/SearchQueryAlterTest.php +++ b/core/modules/search/tests/src/Functional/SearchQueryAlterTest.php @@ -53,7 +53,7 @@ public function testQueryAlter() { // Search for the body keyword 'pizza'. $this->drupalPostForm('search/node', ['keys' => 'pizza'], 'Search'); // The article should be there but not the page. - $this->assertText('article'); + $this->assertSession()->pageTextContains('article'); $this->assertNoText('page'); } diff --git a/core/modules/search/tests/src/Functional/SearchRankingTest.php b/core/modules/search/tests/src/Functional/SearchRankingTest.php index 89e8ed37fe4a..e3b7edce83e3 100644 --- a/core/modules/search/tests/src/Functional/SearchRankingTest.php +++ b/core/modules/search/tests/src/Functional/SearchRankingTest.php @@ -129,7 +129,7 @@ public function testRankings() { // Test that the settings form displays the content ranking section. $this->drupalGet('admin/config/search/pages/manage/node_search'); - $this->assertText('Content ranking'); + $this->assertSession()->pageTextContains('Content ranking'); // Check that all rankings are visible and set to 0. foreach ($node_ranks as $node_rank) { diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php index 1c979828dfcd..227c98992477 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -81,7 +81,7 @@ public function testShortcutLinkAdd() { ]; $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, 'Save'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Added a shortcut for ' . $title . '.'); + $this->assertSession()->pageTextContains('Added a shortcut for ' . $title . '.'); $saved_set = ShortcutSet::load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'link'); $this->assertContains('internal:' . $test_path, $paths, 'Shortcut created: ' . $test_path); @@ -153,7 +153,7 @@ public function testShortcutQuickLink() { // Test the "Add to shortcuts" link. $this->clickLink('Add to Default shortcuts'); - $this->assertText('Added a shortcut for Cron.'); + $this->assertSession()->pageTextContains('Added a shortcut for Cron.'); $this->assertSession()->linkExists('Cron', 0, 'Shortcut link found on page'); $this->drupalGet('admin/structure'); @@ -162,7 +162,7 @@ public function testShortcutQuickLink() { // Test the "Remove from shortcuts" link. $this->clickLink('Cron'); $this->clickLink('Remove from Default shortcuts'); - $this->assertText('The shortcut Cron has been deleted.'); + $this->assertSession()->pageTextContains('The shortcut Cron has been deleted.'); $this->assertSession()->linkNotExists('Cron', 'Shortcut link removed from page'); $this->drupalGet('admin/structure'); @@ -172,26 +172,26 @@ public function testShortcutQuickLink() { // Test the "Add to shortcuts" link for a page generated by views. $this->clickLink('Add to Default shortcuts'); - $this->assertText('Added a shortcut for People.'); + $this->assertSession()->pageTextContains('Added a shortcut for People.'); $this->assertShortcutQuickLink('Remove from Default shortcuts'); // Test the "Remove from shortcuts" link for a page generated by views. $this->clickLink('Remove from Default shortcuts'); - $this->assertText('The shortcut People has been deleted.'); + $this->assertSession()->pageTextContains('The shortcut People has been deleted.'); $this->assertShortcutQuickLink('Add to Default shortcuts'); // Test two pages which use same route name but different route parameters. $this->drupalGet('node/add/page'); // Add Shortcut for Basic Page. $this->clickLink('Add to Default shortcuts'); - $this->assertText('Added a shortcut for Create Basic page.'); + $this->assertSession()->pageTextContains('Added a shortcut for Create Basic page.'); // Assure that Article does not have its shortcut indicated as set. $this->drupalGet('node/add/article'); $link = $this->xpath('//a[normalize-space()=:label]', [':label' => 'Remove from Default shortcuts']); $this->assertTrue(empty($link), 'Link Remove to Default shortcuts not found for Create Article page.'); // Add Shortcut for Article. $this->clickLink('Add to Default shortcuts'); - $this->assertText('Added a shortcut for Create Article.'); + $this->assertSession()->pageTextContains('Added a shortcut for Create Article.'); $this->config('system.theme')->set('default', 'seven')->save(); $this->drupalGet('node/' . $this->node->id()); @@ -199,12 +199,12 @@ public function testShortcutQuickLink() { // Test the "Add to shortcuts" link for node view route. $this->clickLink('Add to Default shortcuts'); - $this->assertText("Added a shortcut for $title."); + $this->assertSession()->pageTextContains("Added a shortcut for $title."); $this->assertShortcutQuickLink('Remove from Default shortcuts'); // Test the "Remove from shortcuts" link for node view route. $this->clickLink('Remove from Default shortcuts'); - $this->assertText("The shortcut $title has been deleted."); + $this->assertSession()->pageTextContains("The shortcut $title has been deleted."); $this->assertShortcutQuickLink('Add to Default shortcuts'); \Drupal::service('module_installer')->install(['block_content']); @@ -241,7 +241,7 @@ public function testShortcutLinkRename() { $titles = $this->getShortcutInformation($saved_set, 'title'); $this->assertContains($new_link_name, $titles, 'Shortcut renamed: ' . $new_link_name); $this->assertSession()->linkExists($new_link_name, 0, 'Renamed shortcut link appears on the page.'); - $this->assertText('The shortcut ' . $new_link_name . ' has been updated.'); + $this->assertSession()->pageTextContains('The shortcut ' . $new_link_name . ' has been updated.'); } /** @@ -260,7 +260,7 @@ public function testShortcutLinkChangePath() { $paths = $this->getShortcutInformation($saved_set, 'link'); $this->assertContains('internal:' . $new_link_path, $paths, 'Shortcut path changed: ' . $new_link_path); $this->assertSession()->linkByHrefExists($new_link_path, 0, 'Shortcut with new path appears on the page.'); - $this->assertText('The shortcut ' . $shortcut->getTitle() . ' has been updated.'); + $this->assertSession()->pageTextContains('The shortcut ' . $shortcut->getTitle() . ' has been updated.'); } /** diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php index 160c375f5e1d..6468521d37bf 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php @@ -48,7 +48,7 @@ public function testShortcutSetAdd() { $this->drupalGet('user/' . $this->adminUser->id() . '/shortcuts'); // Verify that generated shortcut set was listed as a choice on the user // account page. - $this->assertText($new_set->label()); + $this->assertSession()->pageTextContains($new_set->label()); } /** @@ -147,7 +147,7 @@ public function testShortcutSetSwitchCreate() { public function testShortcutSetSwitchNoSetName() { $edit = ['set' => 'new']; $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', $edit, 'Change set'); - $this->assertText('The new set label is required.'); + $this->assertSession()->pageTextContains('The new set label is required.'); $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertEquals($this->set->id(), $current_set->id(), 'Attempting to switch to a new shortcut set without providing a set name does not succeed.'); $field = $this->assertSession()->fieldExists('label'); @@ -212,7 +212,7 @@ public function testShortcutSetCreateWithSetName() { $this->drupalGet('user/' . $this->adminUser->id() . '/shortcuts'); // Verify that generated shortcut set was listed as a choice on the user // account page. - $this->assertText($new_set->label()); + $this->assertSession()->pageTextContains($new_set->label()); } } diff --git a/core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php b/core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php index 1bcf94c822ab..0bbbda823017 100644 --- a/core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php +++ b/core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php @@ -94,22 +94,22 @@ public function testStatisticsSettings() { // "1 view" will actually be shown when the node is hit the second time). $this->drupalGet('node/' . $this->testNode->id()); $this->client->post($stats_path, ['form_params' => $post]); - $this->assertText('1 view'); + $this->assertSession()->pageTextContains('1 view'); $this->drupalGet('node/' . $this->testNode->id()); $this->client->post($stats_path, ['form_params' => $post]); - $this->assertText('2 views'); + $this->assertSession()->pageTextContains('2 views'); // Increase the max age to test that nodes are no longer immediately // updated, visit the node once more to populate the cache. $this->config('statistics.settings')->set('display_max_age', 3600)->save(); $this->drupalGet('node/' . $this->testNode->id()); - $this->assertText('3 views'); + $this->assertSession()->pageTextContains('3 views'); $this->client->post($stats_path, ['form_params' => $post]); $this->drupalGet('node/' . $this->testNode->id()); // Verify that views counter was not updated. - $this->assertText('3 views'); + $this->assertSession()->pageTextContains('3 views'); } /** @@ -162,7 +162,7 @@ public function testExpiredLogs() { $this->client->post($stats_path, ['form_params' => $post]); $this->drupalGet('node/' . $this->testNode->id()); $this->client->post($stats_path, ['form_params' => $post]); - $this->assertText('1 view'); + $this->assertSession()->pageTextContains('1 view'); // statistics_cron() will subtract // statistics.settings:accesslog.max_lifetime config from REQUEST_TIME in diff --git a/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php b/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php index 1d017cae7e9e..53402fa890ec 100644 --- a/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php +++ b/core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php @@ -49,10 +49,10 @@ public function testPopularContentBlock() { // Get some page and check if the block is displayed. $this->drupalGet('user'); - $this->assertText('Popular content'); - $this->assertText("Today's"); - $this->assertText('All time'); - $this->assertText('Last viewed'); + $this->assertSession()->pageTextContains('Popular content'); + $this->assertSession()->pageTextContains("Today's"); + $this->assertSession()->pageTextContains('All time'); + $this->assertSession()->pageTextContains('Last viewed'); $tags = Cache::mergeTags($node->getCacheTags(), $block->getCacheTags()); $tags = Cache::mergeTags($tags, $this->blockingUser->getCacheTags()); diff --git a/core/modules/syslog/tests/src/Functional/SyslogTest.php b/core/modules/syslog/tests/src/Functional/SyslogTest.php index bce03f48a227..d8bf575bcfb8 100644 --- a/core/modules/syslog/tests/src/Functional/SyslogTest.php +++ b/core/modules/syslog/tests/src/Functional/SyslogTest.php @@ -33,7 +33,7 @@ public function testSettings() { // If we're on Windows, there is no configuration form. if (defined('LOG_LOCAL6')) { $this->drupalPostForm('admin/config/development/logging', ['syslog_facility' => LOG_LOCAL6], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $this->drupalGet('admin/config/development/logging'); // Should be one field. diff --git a/core/modules/system/tests/src/Functional/Batch/PageTest.php b/core/modules/system/tests/src/Functional/Batch/PageTest.php index 528304f51306..f6abdc1f2a47 100644 --- a/core/modules/system/tests/src/Functional/Batch/PageTest.php +++ b/core/modules/system/tests/src/Functional/Batch/PageTest.php @@ -58,7 +58,7 @@ public function testBatchProgressPageTitle() { // Run initial step only first. $this->maximumMetaRefreshCount = 0; $this->drupalGet('batch-test/test-title'); - $this->assertText('Batch Test'); + $this->assertSession()->pageTextContains('Batch Test'); // Leave the batch process running. $this->maximumMetaRefreshCount = NULL; @@ -66,7 +66,7 @@ public function testBatchProgressPageTitle() { // The stack should contain the title shown on the progress page. $this->assertEquals(['Batch Test'], batch_test_stack(), 'The batch title is shown on the batch page.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); } /** diff --git a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php index 9e3045b6783a..fb83d42822b4 100644 --- a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php +++ b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php @@ -32,7 +32,7 @@ public function testBatchNoForm() { $this->drupalGet('batch-test/no-form'); $this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch for step 2 performed successfully.'); $this->assertEquals($this->_resultStack('batch_1'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); } /** @@ -45,7 +45,7 @@ public function testBatchRedirectFinishedCallback() { $this->assertEquals($this->_resultStack('batch_1'), batch_test_stack(), 'Execution order was correct.'); // Verify that the custom redirection after batch execution displays the // correct page. - $this->assertText('Test page text.'); + $this->assertSession()->pageTextContains('Test page text.'); $this->assertSession()->addressEquals(Url::fromRoute('test_page_test.test_page')); } @@ -61,7 +61,7 @@ public function testBatchForm() { // of verifying that no markup is incorrectly escaped. $this->assertSession()->assertNoEscaped('<'); $this->assertBatchMessages($this->_resultMessages('batch_0'), 'Batch with no operation performed successfully.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); // Batch 1: several simple operations. $edit = ['batch' => 'batch_1']; @@ -69,7 +69,7 @@ public function testBatchForm() { $this->assertSession()->assertNoEscaped('<'); $this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch with simple operations performed successfully.'); $this->assertEquals($this->_resultStack('batch_1'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); // Batch 2: one multistep operation. $edit = ['batch' => 'batch_2']; @@ -77,7 +77,7 @@ public function testBatchForm() { $this->assertSession()->assertNoEscaped('<'); $this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch with multistep operation performed successfully.'); $this->assertEquals($this->_resultStack('batch_2'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); // Batch 3: simple + multistep combined. $edit = ['batch' => 'batch_3']; @@ -85,7 +85,7 @@ public function testBatchForm() { $this->assertSession()->assertNoEscaped('<'); $this->assertBatchMessages($this->_resultMessages('batch_3'), 'Batch with simple and multistep operations performed successfully.'); $this->assertEquals($this->_resultStack('batch_3'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); // Batch 4: nested batch. $edit = ['batch' => 'batch_4']; @@ -93,7 +93,7 @@ public function testBatchForm() { $this->assertSession()->assertNoEscaped('<'); $this->assertBatchMessages($this->_resultMessages('batch_4'), 'Nested batch performed successfully.'); $this->assertEquals($this->_resultStack('batch_4'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); // Submit batches 4 and 7. Batch 4 will trigger batch 2. Batch 7 will // trigger batches 6 and 5. @@ -127,27 +127,27 @@ public function testBatchForm() { public function testBatchFormMultistep() { $this->drupalGet('batch-test/multistep'); $this->assertSession()->assertNoEscaped('<'); - $this->assertText('step 1'); + $this->assertSession()->pageTextContains('step 1'); // First step triggers batch 1. $this->submitForm([], 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch for step 1 performed successfully.'); $this->assertEquals($this->_resultStack('batch_1'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('step 2'); + $this->assertSession()->pageTextContains('step 2'); $this->assertSession()->assertNoEscaped('<'); // Second step triggers batch 2. $this->submitForm([], 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch for step 2 performed successfully.'); $this->assertEquals($this->_resultStack('batch_2'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); $this->assertSession()->assertNoEscaped('<'); // Extra query arguments will trigger logic that will add them to the // redirect URL. Make sure they are persisted. $this->drupalGet('batch-test/multistep', ['query' => ['big_tree' => 'small_axe']]); $this->submitForm([], 'Submit'); - $this->assertText('step 2'); + $this->assertSession()->pageTextContains('step 2'); $this->assertStringContainsString('batch-test/multistep?big_tree=small_axe', $this->getUrl(), 'Query argument was persisted and another extra argument was added.'); } @@ -165,7 +165,7 @@ public function testBatchFormMultipleBatches() { // The stack contains execution order of batch callbacks and submit // handlers and logging of corresponding $form_state->getValues(). $this->assertEquals($this->_resultStack('chained', $value), batch_test_stack(), 'Execution order was correct, and $form_state is correctly persisted.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); } /** @@ -183,7 +183,7 @@ public function testBatchFormProgrammatic() { // The stack contains execution order of batch callbacks and submit // handlers and logging of corresponding $form_state->getValues(). $this->assertEquals($this->_resultStack('chained', $value), batch_test_stack(), 'Execution order was correct, and $form_state is correctly persisted.'); - $this->assertText('Got out of a programmatic batched form.'); + $this->assertSession()->pageTextContains('Got out of a programmatic batched form.'); } /** @@ -207,7 +207,7 @@ public function testBatchLargePercentage() { $this->drupalGet('batch-test/large-percentage'); $this->assertBatchMessages($this->_resultMessages('batch_5'), 'Batch for step 2 performed successfully.'); $this->assertEquals($this->_resultStack('batch_5'), batch_test_stack(), 'Execution order was correct.'); - $this->assertText('Redirection successful.'); + $this->assertSession()->pageTextContains('Redirection successful.'); } /** diff --git a/core/modules/system/tests/src/Functional/Common/FormatDateTest.php b/core/modules/system/tests/src/Functional/Common/FormatDateTest.php index ca71b9c21755..98638ab75aa3 100644 --- a/core/modules/system/tests/src/Functional/Common/FormatDateTest.php +++ b/core/modules/system/tests/src/Functional/Common/FormatDateTest.php @@ -40,7 +40,7 @@ public function testAdminDefinedFormatDate() { 'date_format_pattern' => 'j M Y', ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); - $this->assertText('Custom date format added.'); + $this->assertSession()->pageTextContains('Custom date format added.'); /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */ $date_formatter = $this->container->get('date.formatter'); diff --git a/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php b/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php index 4ec716f0b903..2d07e9990fe9 100644 --- a/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php +++ b/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php @@ -41,9 +41,9 @@ public function testConfigForm() { $this->assertSession()->fieldExists('bundles[page]'); $this->submitForm(['bundles[page]' => 'page', 'bundles[article]' => 'article'], 'Submit'); // @see \Drupal\condition_test\FormController::submitForm() - $this->assertText('Bundle: page'); - $this->assertText('Bundle: article'); - $this->assertText('Executed successfully.'); + $this->assertSession()->pageTextContains('Bundle: page'); + $this->assertSession()->pageTextContains('Bundle: article'); + $this->assertSession()->pageTextContains('Executed successfully.'); } } diff --git a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php index fcf2870bf4f6..acea9d9bac4c 100644 --- a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php +++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php @@ -43,7 +43,7 @@ public function testBogusAcceptHeader() { foreach ($tests as $case => $header) { $this->drupalGet('', [], ['Accept: ' . $header]); $this->assertNoText('Unsupported Media Type'); - $this->assertText('Log in'); + $this->assertSession()->pageTextContains('Log in'); } } diff --git a/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php b/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php index b6dc49d4b6a7..03aad8f7063f 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php @@ -47,7 +47,7 @@ public function testAddPageWithBundleEntities() { // No bundles exist, the add bundle message should be present as the user // has the necessary permissions. $this->drupalGet('/entity_test_with_bundle/add'); - $this->assertText('There is no test entity bundle yet.'); + $this->assertSession()->pageTextContains('There is no test entity bundle yet.'); $this->assertSession()->linkExists('Add a new test entity bundle.'); // One bundle exists, confirm redirection to the add-form. @@ -69,8 +69,8 @@ public function testAddPageWithBundleEntities() { $this->assertSession()->linkExists('Test label'); $this->assertSession()->linkExists('Test2 label'); - $this->assertText('My test description'); - $this->assertText('My test2 description'); + $this->assertSession()->pageTextContains('My test description'); + $this->assertSession()->pageTextContains('My test2 description'); $this->clickLink('Test2 label'); $this->drupalGet('/entity_test_with_bundle/add/test2'); diff --git a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php index aa974e521332..9e0d26f57a18 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php @@ -211,11 +211,11 @@ public function testEntityRevisionParamConverter() { $revision_url = 'entity_test_mulrev/' . $entity->id() . '/revision/' . $pending_revision->getRevisionId() . '/view'; $this->drupalGet($revision_url); - $this->assertText('pending revision - en'); + $this->assertSession()->pageTextContains('pending revision - en'); $this->assertNoText('pending revision - de'); $this->drupalGet('de/' . $revision_url); - $this->assertText('pending revision - de'); + $this->assertSession()->pageTextContains('pending revision - de'); $this->assertNoText('pending revision - en'); } diff --git a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php index 9ce084b59c6b..89b2d9f14985 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php @@ -96,7 +96,7 @@ public function testEntityFormLanguage() { $edit['body[0][value]'] = $this->randomMachineName(16); $edit['langcode[0][value]'] = $langcode; $this->drupalPostForm('node/add/page', $edit, 'Save'); - $this->assertText('Basic page ' . $edit['title[0][value]'] . ' has been created.'); + $this->assertSession()->pageTextContains('Basic page ' . $edit['title[0][value]'] . ' has been created.'); // Verify that the creation message contains a link to a node. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]'); diff --git a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php index fd02092fc74e..ee865b06a016 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php @@ -130,7 +130,7 @@ public function testEntityViewControllerViewBuilder() { $entity_test = $this->createTestEntity('entity_test_view_builder'); $entity_test->save(); $this->drupalGet('entity_test_view_builder/' . $entity_test->id()); - $this->assertText($entity_test->label()); + $this->assertSession()->pageTextContains($entity_test->label()); } /** diff --git a/core/modules/system/tests/src/Functional/File/ConfigTest.php b/core/modules/system/tests/src/Functional/File/ConfigTest.php index 3fecc29e06c5..313a118d7012 100644 --- a/core/modules/system/tests/src/Functional/File/ConfigTest.php +++ b/core/modules/system/tests/src/Functional/File/ConfigTest.php @@ -37,11 +37,11 @@ public function testFileConfigurationPage() { ]; // Check that public and private can be selected as default scheme. - $this->assertText('Public local files served by the webserver.'); - $this->assertText('Private local files served by Drupal.'); + $this->assertSession()->pageTextContains('Public local files served by the webserver.'); + $this->assertSession()->pageTextContains('Private local files served by Drupal.'); $this->submitForm($fields, 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); foreach ($fields as $field => $value) { $this->assertSession()->fieldValueEquals($field, $value); } @@ -56,7 +56,7 @@ public function testFileConfigurationPage() { $this->rebuildContainer(); $this->drupalGet('admin/config/media/file-system'); - $this->assertText('Public local files served by the webserver.'); + $this->assertSession()->pageTextContains('Public local files served by the webserver.'); $this->assertNoText('Private local files served by Drupal.'); } diff --git a/core/modules/system/tests/src/Functional/Form/ArbitraryRebuildTest.php b/core/modules/system/tests/src/Functional/Form/ArbitraryRebuildTest.php index 616f43b2229d..e9df00699a4f 100644 --- a/core/modules/system/tests/src/Functional/Form/ArbitraryRebuildTest.php +++ b/core/modules/system/tests/src/Functional/Form/ArbitraryRebuildTest.php @@ -60,7 +60,7 @@ public function testUserRegistrationRebuild() { 'mail' => 'bar@example.com', ]; $this->drupalPostForm('user/register', $edit, 'Rebuild'); - $this->assertText('Form rebuilt.'); + $this->assertSession()->pageTextContains('Form rebuilt.'); $this->assertSession()->fieldValueEquals('name', 'foo'); $this->assertSession()->fieldValueEquals('mail', 'bar@example.com'); } @@ -74,7 +74,7 @@ public function testUserRegistrationMultipleField() { 'mail' => 'bar@example.com', ]; $this->drupalPostForm('user/register', $edit, 'Add another item'); - $this->assertText('Test a multiple valued field'); + $this->assertSession()->pageTextContains('Test a multiple valued field'); $this->assertSession()->fieldValueEquals('name', 'foo'); $this->assertSession()->fieldValueEquals('mail', 'bar@example.com'); } diff --git a/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php b/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php index 617d681fbef6..4fa301e36d82 100644 --- a/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php +++ b/core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php @@ -30,7 +30,7 @@ public function testConfirmForm() { $this->drupalGet('form-test/confirm-form'); $site_name = $this->config('system.site')->get('name'); $this->assertSession()->titleEquals("ConfirmFormTestForm::getQuestion(). | $site_name"); - $this->assertText('ConfirmFormTestForm::getDescription().'); + $this->assertSession()->pageTextContains('ConfirmFormTestForm::getDescription().'); $this->assertSession()->buttonExists('ConfirmFormTestForm::getConfirmText().'); // Test cancelling the form. @@ -39,7 +39,7 @@ public function testConfirmForm() { // Test submitting the form. $this->drupalPostForm('form-test/confirm-form', [], 'ConfirmFormTestForm::getConfirmText().'); - $this->assertText('The ConfirmFormTestForm::submitForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The ConfirmFormTestForm::submitForm() method was used for this form.'); $this->assertSession()->addressEquals(''); // Test submitting the form with a destination. diff --git a/core/modules/system/tests/src/Functional/Form/ElementTest.php b/core/modules/system/tests/src/Functional/Form/ElementTest.php index 62bbe95080d8..39815c648fe8 100644 --- a/core/modules/system/tests/src/Functional/Form/ElementTest.php +++ b/core/modules/system/tests/src/Functional/Form/ElementTest.php @@ -190,7 +190,7 @@ public function testFormAutocomplete() { */ public function testFormElementErrors() { $this->drupalPostForm('form_test/details-form', [], 'Submit'); - $this->assertText('I am an error on the details element.'); + $this->assertSession()->pageTextContains('I am an error on the details element.'); } /** diff --git a/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php b/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php index f0b7a9ff22c2..6bb0d2ca4036 100644 --- a/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php +++ b/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php @@ -34,7 +34,7 @@ public function testAccessFalse() { $this->assertNoText('This checkbox inside a container does not have its default value.'); $this->assertNoText('This checkbox inside a nested container does not have its default value.'); $this->assertNoText('This checkbox inside a vertical tab whose fieldset access is allowed does not have its default value.'); - $this->assertText('The form submitted correctly.'); + $this->assertSession()->pageTextContains('The form submitted correctly.'); } } diff --git a/core/modules/system/tests/src/Functional/Form/FormObjectTest.php b/core/modules/system/tests/src/Functional/Form/FormObjectTest.php index 9453ff82d340..174cdf39ac86 100644 --- a/core/modules/system/tests/src/Functional/Form/FormObjectTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormObjectTest.php @@ -32,47 +32,47 @@ public function testObjectFormCallback() { $config_factory = $this->container->get('config.factory'); $this->drupalGet('form-test/object-builder'); - $this->assertText('The FormTestObject::buildForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestObject::buildForm() method was used for this form.'); $elements = $this->xpath('//form[@id="form-test-form-test-object"]'); $this->assertTrue(!empty($elements), 'The correct form ID was used.'); $this->submitForm(['bananas' => 'green'], 'Save'); - $this->assertText('The FormTestObject::validateForm() method was used for this form.'); - $this->assertText('The FormTestObject::submitForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestObject::validateForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestObject::submitForm() method was used for this form.'); $value = $config_factory->get('form_test.object')->get('bananas'); $this->assertSame('green', $value); $this->drupalGet('form-test/object-arguments-builder/yellow'); - $this->assertText('The FormTestArgumentsObject::buildForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestArgumentsObject::buildForm() method was used for this form.'); $elements = $this->xpath('//form[@id="form-test-form-test-arguments-object"]'); $this->assertTrue(!empty($elements), 'The correct form ID was used.'); $this->submitForm([], 'Save'); - $this->assertText('The FormTestArgumentsObject::validateForm() method was used for this form.'); - $this->assertText('The FormTestArgumentsObject::submitForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestArgumentsObject::validateForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestArgumentsObject::submitForm() method was used for this form.'); $value = $config_factory->get('form_test.object')->get('bananas'); $this->assertSame('yellow', $value); $this->drupalGet('form-test/object-service-builder'); - $this->assertText('The FormTestServiceObject::buildForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestServiceObject::buildForm() method was used for this form.'); $elements = $this->xpath('//form[@id="form-test-form-test-service-object"]'); $this->assertTrue(!empty($elements), 'The correct form ID was used.'); $this->submitForm(['bananas' => 'brown'], 'Save'); - $this->assertText('The FormTestServiceObject::validateForm() method was used for this form.'); - $this->assertText('The FormTestServiceObject::submitForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestServiceObject::validateForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestServiceObject::submitForm() method was used for this form.'); $value = $config_factory->get('form_test.object')->get('bananas'); $this->assertSame('brown', $value); $this->drupalGet('form-test/object-controller-builder'); - $this->assertText('The FormTestControllerObject::create() method was used for this form.'); - $this->assertText('The FormTestControllerObject::buildForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestControllerObject::create() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestControllerObject::buildForm() method was used for this form.'); $elements = $this->xpath('//form[@id="form-test-form-test-controller-object"]'); $this->assertTrue(!empty($elements), 'The correct form ID was used.'); // Ensure parameters are injected from request attributes. - $this->assertText('custom_value'); + $this->assertSession()->pageTextContains('custom_value'); // Ensure the request object is injected. - $this->assertText('request_value'); + $this->assertSession()->pageTextContains('request_value'); $this->submitForm(['bananas' => 'black'], 'Save'); - $this->assertText('The FormTestControllerObject::validateForm() method was used for this form.'); - $this->assertText('The FormTestControllerObject::submitForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestControllerObject::validateForm() method was used for this form.'); + $this->assertSession()->pageTextContains('The FormTestControllerObject::submitForm() method was used for this form.'); $value = $config_factory->get('form_test.object')->get('bananas'); $this->assertSame('black', $value); } diff --git a/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php b/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php index 60546cab37d9..6bdefd2682c7 100644 --- a/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormStoragePageCacheTest.php @@ -47,34 +47,34 @@ protected function getFormBuildId() { public function testValidateFormStorageOnCachedPage() { $this->drupalGet('form-test/form-storage-page-cache'); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_initial = $this->getFormBuildId(); // Trigger validation error by submitting an empty title. $edit = ['title' => '']; $this->submitForm($edit, 'Save'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_first_validation = $this->getFormBuildId(); $this->assertNotEquals($build_id_initial, $build_id_first_validation, 'Build id changes when form validation fails'); // Trigger validation error by again submitting an empty title. $edit = ['title' => '']; $this->submitForm($edit, 'Save'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_second_validation = $this->getFormBuildId(); $this->assertEquals($build_id_first_validation, $build_id_second_validation, 'Build id remains the same when form validation fails subsequently'); // Repeat the test sequence but this time with a page loaded from the cache. $this->drupalGet('form-test/form-storage-page-cache'); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_from_cache_initial = $this->getFormBuildId(); $this->assertEquals($build_id_initial, $build_id_from_cache_initial, 'Build id is the same as on the first request'); // Trigger validation error by submitting an empty title. $edit = ['title' => '']; $this->submitForm($edit, 'Save'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_from_cache_first_validation = $this->getFormBuildId(); $this->assertNotEquals($build_id_initial, $build_id_from_cache_first_validation, 'Build id changes when form validation fails'); $this->assertNotEquals($build_id_first_validation, $build_id_from_cache_first_validation, 'Build id from first user is not reused'); @@ -82,7 +82,7 @@ public function testValidateFormStorageOnCachedPage() { // Trigger validation error by again submitting an empty title. $edit = ['title' => '']; $this->submitForm($edit, 'Save'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_from_cache_second_validation = $this->getFormBuildId(); $this->assertEquals($build_id_from_cache_first_validation, $build_id_from_cache_second_validation, 'Build id remains the same when form validation fails subsequently'); } @@ -93,7 +93,7 @@ public function testValidateFormStorageOnCachedPage() { public function testRebuildFormStorageOnCachedPage() { $this->drupalGet('form-test/form-storage-page-cache'); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); - $this->assertText('No old build id'); + $this->assertSession()->pageTextContains('No old build id'); $build_id_initial = $this->getFormBuildId(); // Trigger rebuild, should regenerate build id. When a submit handler @@ -111,7 +111,7 @@ public function testRebuildFormStorageOnCachedPage() { // Trigger subsequent rebuild, should regenerate the build id again. $edit = ['title' => 'something']; $this->submitForm($edit, 'Rebuild'); - $this->assertText($build_id_first_rebuild); + $this->assertSession()->pageTextContains($build_id_first_rebuild); $build_id_second_rebuild = $this->getFormBuildId(); $this->assertNotEquals($build_id_first_rebuild, $build_id_second_rebuild, 'Build id changes on second rebuild.'); } diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php index 4361a78a3eb9..450aed38859e 100644 --- a/core/modules/system/tests/src/Functional/Form/FormTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormTest.php @@ -265,7 +265,7 @@ public function testInputWithInvalidToken() { $element = $assert->fieldExists('textfield'); $this->assertEmpty($element->getValue()); $assert->responseNotContains($random_string); - $this->assertText('The form has become outdated.'); + $this->assertSession()->pageTextContains('The form has become outdated.'); // Ensure that we don't use the posted values. $this->assertSession()->fieldValueEquals('textfield', ''); $this->assertSession()->checkboxNotChecked('edit-checkboxes-foo'); @@ -286,7 +286,7 @@ public function testInputWithInvalidToken() { // Verify that the error message is displayed with invalid token even when // required fields are filled. $this->assertSession()->elementExists('xpath', '//div[contains(@class, "error")]'); - $this->assertText('The form has become outdated.'); + $this->assertSession()->pageTextContains('The form has become outdated.'); $this->assertSession()->fieldValueEquals('textfield', ''); $this->assertSession()->fieldValueEquals('textarea', ''); @@ -304,7 +304,7 @@ public function testInputWithInvalidToken() { // Verify that the error message is displayed with invalid token even when // required fields are filled.' $this->assertSession()->elementExists('xpath', '//div[contains(@class, "error")]'); - $this->assertText('The form has become outdated.'); + $this->assertSession()->pageTextContains('The form has become outdated.'); $this->assertSession()->fieldValueEquals('integer_step', 5); // Check a form with a Url field @@ -319,7 +319,7 @@ public function testInputWithInvalidToken() { // Verify that the error message is displayed with invalid token even when // required fields are filled. $this->assertSession()->elementExists('xpath', '//div[contains(@class, "error")]'); - $this->assertText('The form has become outdated.'); + $this->assertSession()->pageTextContains('The form has become outdated.'); $this->assertSession()->fieldValueEquals('url', ''); } @@ -436,7 +436,7 @@ public function testSelect() { 'multiple_no_default_required', ]; foreach ($expected_errors as $key) { - $this->assertText($form[$key]['#title'] . ' field is required.'); + $this->assertSession()->pageTextContains($form[$key]['#title'] . ' field is required.'); } // Post values for required fields. @@ -872,7 +872,7 @@ public function testInputForgery() { // an input forgery. // @see \Drupal\form_test\Form\FormTestInputForgeryForm::postRender $this->submitForm(['checkboxes[one]' => TRUE, 'checkboxes[two]' => TRUE], 'Submit'); - $this->assertText('An illegal choice has been detected.'); + $this->assertSession()->pageTextContains('An illegal choice has been detected.'); } /** diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php index 4cedf3b4a99b..f9e83820378f 100644 --- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php @@ -52,7 +52,7 @@ public function testModuleListForm() { // Ensure that the Database Logging module's machine name is printed. This // module is used because its machine name is different than its human // readable name. - $this->assertText('dblog'); + $this->assertSession()->pageTextContains('dblog'); } /** @@ -143,7 +143,7 @@ public function testInstalledIncompatibleModule() { $edit = ['modules[changing_module][enable]' => 'changing_module']; $this->drupalGet('admin/modules'); $this->drupalPostForm('admin/modules', $edit, 'Install'); - $this->assertText('Module Module that changes has been enabled.'); + $this->assertSession()->pageTextContains('Module Module that changes has been enabled.'); $incompatible_updates = [ [ @@ -157,7 +157,7 @@ public function testInstalledIncompatibleModule() { $incompatible_info = $info + $incompatible_update; file_put_contents($file_path, Yaml::encode($incompatible_info)); $this->drupalGet('admin/modules'); - $this->assertText($incompatible_modules_message); + $this->assertSession()->pageTextContains($incompatible_modules_message); file_put_contents($file_path, Yaml::encode($compatible_info)); $this->drupalGet('admin/modules'); @@ -168,7 +168,7 @@ public function testInstalledIncompatibleModule() { $edit = ['uninstall[changing_module]' => 'changing_module']; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); foreach ($incompatible_updates as $incompatible_update) { $incompatible_info = $info + $incompatible_update; file_put_contents($file_path, Yaml::encode($incompatible_info)); diff --git a/core/modules/system/tests/src/Functional/Form/SystemConfigFormTest.php b/core/modules/system/tests/src/Functional/Form/SystemConfigFormTest.php index 7811f695d683..90ab6c7148ef 100644 --- a/core/modules/system/tests/src/Functional/Form/SystemConfigFormTest.php +++ b/core/modules/system/tests/src/Functional/Form/SystemConfigFormTest.php @@ -31,7 +31,7 @@ public function testSystemConfigForm() { // Verify the primary action submit button is found. $this->assertSession()->elementExists('xpath', "//div[@id = 'edit-actions']/input[contains(@class, 'button--primary')]"); $this->submitForm([], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); } } diff --git a/core/modules/system/tests/src/Functional/Form/ValidationTest.php b/core/modules/system/tests/src/Functional/Form/ValidationTest.php index 807b1b9109d4..0ab5d7c2ee97 100644 --- a/core/modules/system/tests/src/Functional/Form/ValidationTest.php +++ b/core/modules/system/tests/src/Functional/Form/ValidationTest.php @@ -36,7 +36,7 @@ public function testValidate() { ]; $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('name', '#value changed by #element_validate'); - $this->assertText('Name value: value changed by setValueForElement() in #element_validate'); + $this->assertSession()->pageTextContains('Name value: value changed by setValueForElement() in #element_validate'); // Verify that #validate handlers can alter the form and submitted // form values. @@ -45,7 +45,7 @@ public function testValidate() { ]; $this->submitForm($edit, 'Save'); $this->assertSession()->fieldValueEquals('name', '#value changed by #validate'); - $this->assertText('Name value: value changed by setValueForElement() in #validate'); + $this->assertSession()->pageTextContains('Name value: value changed by setValueForElement() in #validate'); // Verify that #element_validate handlers can make form elements // inaccessible, but values persist. @@ -54,12 +54,12 @@ public function testValidate() { ]; $this->submitForm($edit, 'Save'); $this->assertSession()->fieldNotExists('name'); - $this->assertText('Name value: element_validate_access'); + $this->assertSession()->pageTextContains('Name value: element_validate_access'); // Verify that value for inaccessible form element persists. $this->submitForm([], 'Save'); $this->assertSession()->fieldValueNotEquals('name', 'Form element was hidden.'); - $this->assertText('Name value: element_validate_access'); + $this->assertSession()->pageTextContains('Name value: element_validate_access'); // Verify that #validate handlers don't run if the CSRF token is invalid. $this->drupalLogin($this->drupalCreateUser()); @@ -73,7 +73,7 @@ public function testValidate() { $this->submitForm(['name' => 'validate'], 'Save'); $this->assertSession()->fieldValueNotEquals('name', '#value changed by #validate'); $this->assertNoText('Name value: value changed by setValueForElement() in #validate'); - $this->assertText('The form has become outdated.'); + $this->assertSession()->pageTextContains('The form has become outdated.'); } /** @@ -81,7 +81,7 @@ public function testValidate() { */ public function testDisabledToken() { $this->drupalPostForm('form-test/validate-no-token', [], 'Save'); - $this->assertText('The form_test_validate_no_token form has been submitted successfully.'); + $this->assertSession()->pageTextContains('The form_test_validate_no_token form has been submitted successfully.'); } /** @@ -114,29 +114,29 @@ public function testValidateLimitErrors() { // is triggered. $this->drupalPostForm($path, $edit, 'Partial validate'); $this->assertNoText('Title field is required.'); - $this->assertText('Test element is invalid'); + $this->assertSession()->pageTextContains('Test element is invalid'); // Edge case of #limit_validation_errors containing numeric indexes: same // thing with the 'Partial validate (numeric index)' button and the // 'test_numeric_index' field. $this->drupalPostForm($path, $edit, 'Partial validate (numeric index)'); $this->assertNoText('Title field is required.'); - $this->assertText('Test (numeric index) element is invalid'); + $this->assertSession()->pageTextContains('Test (numeric index) element is invalid'); // Ensure something like 'foobar' isn't considered "inside" 'foo'. $this->drupalPostForm($path, $edit, 'Partial validate (substring)'); $this->assertNoText('Title field is required.'); - $this->assertText('Test (substring) foo element is invalid'); + $this->assertSession()->pageTextContains('Test (substring) foo element is invalid'); // Ensure not validated values are not available to submit handlers. $this->drupalPostForm($path, ['title' => '', 'test' => 'valid'], 'Partial validate'); - $this->assertText('Only validated values appear in the form values.'); + $this->assertSession()->pageTextContains('Only validated values appear in the form values.'); // Now test full form validation and ensure that the #element_validate // handler is still triggered. $this->drupalPostForm($path, $edit, 'Full validate'); - $this->assertText('Title field is required.'); - $this->assertText('Test element is invalid'); + $this->assertSession()->pageTextContains('Title field is required.'); + $this->assertSession()->pageTextContains('Test element is invalid'); } /** @@ -213,11 +213,11 @@ public function testCustomRequiredError() { foreach (Element::children($form) as $key) { if (isset($form[$key]['#required_error'])) { $this->assertNoText($form[$key]['#title'] . ' field is required.'); - $this->assertText((string) $form[$key]['#required_error']); + $this->assertSession()->pageTextContains((string) $form[$key]['#required_error']); } elseif (isset($form[$key]['#form_test_required_error'])) { $this->assertNoText($form[$key]['#title'] . ' field is required.'); - $this->assertText((string) $form[$key]['#form_test_required_error']); + $this->assertSession()->pageTextContains((string) $form[$key]['#form_test_required_error']); } } $this->assertNoText('An illegal choice has been detected. Please contact the site administrator.'); diff --git a/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php b/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php index a62fed5e0c86..4d89c41b003c 100644 --- a/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php +++ b/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php @@ -36,12 +36,12 @@ public function testLockAcquire() { // Cause another request to acquire the lock. $this->drupalGet('system-test/lock-acquire'); - $this->assertText($lock_acquired); + $this->assertSession()->pageTextContains($lock_acquired); // The other request has finished, thus it should have released its lock. $this->assertTrue($lock->acquire('system_test_lock_acquire'), 'Lock acquired by this request.', 'Lock'); // This request holds the lock, so the other request cannot acquire it. $this->drupalGet('system-test/lock-acquire'); - $this->assertText($lock_not_acquired); + $this->assertSession()->pageTextContains($lock_not_acquired); $lock->release('system_test_lock_acquire'); // Try a very short timeout and lock breaking. @@ -49,14 +49,14 @@ public function testLockAcquire() { sleep(1); // The other request should break our lock. $this->drupalGet('system-test/lock-acquire'); - $this->assertText($lock_acquired); + $this->assertSession()->pageTextContains($lock_acquired); // We cannot renew it, since the other thread took it. $this->assertFalse($lock->acquire('system_test_lock_acquire'), 'Lock cannot be extended by this request.', 'Lock'); // Check the shut-down function. $lock_acquired_exit = 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()'; $this->drupalGet('system-test/lock-exit'); - $this->assertText($lock_acquired_exit); + $this->assertSession()->pageTextContains($lock_acquired_exit); $this->assertTrue($lock->acquire('system_test_lock_exit'), 'Lock acquired by this request after the other request exits.', 'Lock'); } @@ -67,21 +67,21 @@ public function testPersistentLock() { $persistent_lock = $this->container->get('lock.persistent'); // Get a persistent lock. $this->drupalGet('system-test/lock-persist/lock1'); - $this->assertText('TRUE: Lock successfully acquired in SystemTestController::lockPersist()'); + $this->assertSession()->pageTextContains('TRUE: Lock successfully acquired in SystemTestController::lockPersist()'); // Ensure that a shutdown function has not released the lock. $this->assertFalse($persistent_lock->lockMayBeAvailable('lock1')); $this->drupalGet('system-test/lock-persist/lock1'); - $this->assertText('FALSE: Lock not acquired in SystemTestController::lockPersist()'); + $this->assertSession()->pageTextContains('FALSE: Lock not acquired in SystemTestController::lockPersist()'); // Get another persistent lock. $this->drupalGet('system-test/lock-persist/lock2'); - $this->assertText('TRUE: Lock successfully acquired in SystemTestController::lockPersist()'); + $this->assertSession()->pageTextContains('TRUE: Lock successfully acquired in SystemTestController::lockPersist()'); $this->assertFalse($persistent_lock->lockMayBeAvailable('lock2')); // Release the first lock and try getting it again. $persistent_lock->release('lock1'); $this->drupalGet('system-test/lock-persist/lock1'); - $this->assertText('TRUE: Lock successfully acquired in SystemTestController::lockPersist()'); + $this->assertSession()->pageTextContains('TRUE: Lock successfully acquired in SystemTestController::lockPersist()'); } } diff --git a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php index 5d1dae9cdb82..c5eb2b53b7f9 100644 --- a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php +++ b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php @@ -63,7 +63,7 @@ protected function doTestHookMenuIntegration() { $base_path = 'foo/' . $machine_name; $this->drupalGet($base_path); // Confirm correct controller activated. - $this->assertText('test1'); + $this->assertSession()->pageTextContains('test1'); // Confirm local task links are displayed. $this->assertSession()->linkExists('Local task A'); $this->assertSession()->linkExists('Local task B'); @@ -79,7 +79,7 @@ protected function doTestHookMenuIntegration() { */ protected function doTestTitleCallbackFalse() { $this->drupalGet('test-page'); - $this->assertText('A title with @placeholder', 'Raw text found on the page'); + $this->assertSession()->pageTextContains('A title with @placeholder', 'Raw text found on the page'); $this->assertNoText('A title with some other text', 'Text with placeholder substitutions not found.'); } @@ -92,7 +92,7 @@ protected function doTestTitleMenuCallback() { $this->assertNoText('Menu Callback Title'); // Verify that the menu router item title is output as page title. $this->drupalGet('menu_callback_title'); - $this->assertText('Menu Callback Title'); + $this->assertSession()->pageTextContains('Menu Callback Title'); } /** @@ -101,7 +101,7 @@ protected function doTestTitleMenuCallback() { protected function doTestDescriptionMenuItems() { // Verify that the menu router item title is output as page title. $this->drupalGet('menu_callback_description'); - $this->assertText('Menu item description text'); + $this->assertSession()->pageTextContains('Menu item description text'); } /** @@ -165,11 +165,11 @@ protected function doTestMenuHierarchy() { protected function doTestMenuOptionalPlaceholders() { $this->drupalGet('menu-test/optional'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Sometimes there is no placeholder.'); + $this->assertSession()->pageTextContains('Sometimes there is no placeholder.'); $this->drupalGet('menu-test/optional/foobar'); $this->assertSession()->statusCodeEquals(200); - $this->assertText("Sometimes there is a placeholder: 'foobar'."); + $this->assertSession()->pageTextContains("Sometimes there is a placeholder: 'foobar'."); } /** @@ -213,9 +213,9 @@ public function testMaintenanceModeLoginPaths() { $offline_message = $this->config('system.site')->get('name') . ' is currently under maintenance. We should be back shortly. Thank you for your patience.'; $this->drupalGet('test-page'); - $this->assertText($offline_message); + $this->assertSession()->pageTextContains($offline_message); $this->drupalGet('menu_login_callback'); - $this->assertText('This is TestControllers::testLogin.'); + $this->assertSession()->pageTextContains('This is TestControllers::testLogin.'); $this->container->get('state')->set('system.maintenance_mode', FALSE); } @@ -268,7 +268,7 @@ public function testThemeIntegration() { */ protected function doTestThemeCallbackAdministrative() { $this->drupalGet('menu-test/theme-callback/use-admin-theme'); - $this->assertText('Active theme: seven. Actual theme: seven.'); + $this->assertSession()->pageTextContains('Active theme: seven. Actual theme: seven.'); $this->assertRaw('seven/css/base/elements.css'); } @@ -288,7 +288,7 @@ protected function doTestThemeCallbackMaintenanceMode() { $admin_user = $this->drupalCreateUser(['access site in maintenance mode']); $this->drupalLogin($admin_user); $this->drupalGet('menu-test/theme-callback/use-admin-theme'); - $this->assertText('Active theme: seven. Actual theme: seven.'); + $this->assertSession()->pageTextContains('Active theme: seven. Actual theme: seven.'); // Check that the administrative theme's CSS appears on the page. $this->assertRaw('seven/css/base/elements.css'); @@ -301,7 +301,7 @@ protected function doTestThemeCallbackMaintenanceMode() { protected function doTestThemeCallbackOptionalTheme() { // Request a theme that is not installed. $this->drupalGet('menu-test/theme-callback/use-test-theme'); - $this->assertText('Active theme: bartik. Actual theme: bartik.'); + $this->assertSession()->pageTextContains('Active theme: bartik. Actual theme: bartik.'); // Check that the default theme's CSS appears on the page. $this->assertRaw('bartik/css/base/elements.css'); @@ -311,7 +311,7 @@ protected function doTestThemeCallbackOptionalTheme() { $theme_installer->install(['test_theme']); $this->drupalGet('menu-test/theme-callback/use-test-theme'); - $this->assertText('Active theme: test_theme. Actual theme: test_theme.'); + $this->assertSession()->pageTextContains('Active theme: test_theme. Actual theme: test_theme.'); // Check that the optional theme's CSS appears on the page. $this->assertRaw('test_theme/kitten.css'); @@ -323,7 +323,7 @@ protected function doTestThemeCallbackOptionalTheme() { */ protected function doTestThemeCallbackFakeTheme() { $this->drupalGet('menu-test/theme-callback/use-fake-theme'); - $this->assertText('Active theme: bartik. Actual theme: bartik.'); + $this->assertSession()->pageTextContains('Active theme: bartik. Actual theme: bartik.'); // Check that the default theme's CSS appears on the page. $this->assertRaw('bartik/css/base/elements.css'); } @@ -333,7 +333,7 @@ protected function doTestThemeCallbackFakeTheme() { */ protected function doTestThemeCallbackNoThemeRequested() { $this->drupalGet('menu-test/theme-callback/no-theme-requested'); - $this->assertText('Active theme: bartik. Actual theme: bartik.'); + $this->assertSession()->pageTextContains('Active theme: bartik. Actual theme: bartik.'); // Check that the default theme's CSS appears on the page. $this->assertRaw('bartik/css/base/elements.css'); } diff --git a/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php b/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php index 4f1a4b834627..c4baf155b1a6 100644 --- a/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php +++ b/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php @@ -42,7 +42,7 @@ public function testClassLoading() { for ($i = 0; $i < 2; $i++) { $this->drupalGet('module-test/class-loading'); $this->assertSession()->statusCodeEquals(200); - $this->assertText($this->expected); + $this->assertSession()->pageTextContains($this->expected); } } diff --git a/core/modules/system/tests/src/Functional/Module/DependencyTest.php b/core/modules/system/tests/src/Functional/Module/DependencyTest.php index 0f7705eb57b8..5ae54121fbdf 100644 --- a/core/modules/system/tests/src/Functional/Module/DependencyTest.php +++ b/core/modules/system/tests/src/Functional/Module/DependencyTest.php @@ -40,7 +40,7 @@ public function testEnableWithoutDependency() { $edit = []; $edit['modules[content_translation][enable]'] = 'content_translation'; $this->drupalPostForm('admin/modules', $edit, 'Install'); - $this->assertText('Some required modules must be enabled'); + $this->assertSession()->pageTextContains('Some required modules must be enabled'); $this->assertModules(['content_translation', 'language'], FALSE); @@ -48,7 +48,7 @@ public function testEnableWithoutDependency() { $this->assertNoModuleConfig('language'); $this->submitForm([], 'Continue'); - $this->assertText('2 modules have been enabled: Content Translation, Language.'); + $this->assertSession()->pageTextContains('2 modules have been enabled: Content Translation, Language.'); $this->assertModules(['content_translation', 'language'], TRUE); // Assert that the language YAML files were created. @@ -141,7 +141,7 @@ public function testEnableRequirementsFailureDependency() { $this->drupalPostForm('admin/modules', $edit, 'Install'); // Makes sure the modules were NOT installed. - $this->assertText('Requirements 1 Test failed requirements'); + $this->assertSession()->pageTextContains('Requirements 1 Test failed requirements'); $this->assertModules(['requirements1_test'], FALSE); $this->assertModules(['requirements2_test'], FALSE); @@ -173,7 +173,7 @@ public function testModuleEnableOrder() { $this->assertModules(['color'], FALSE); // Note that dependencies are sorted alphabetically in the confirmation // message. - $this->assertText('You must enable the Configuration Manager, Help modules to install Color.'); + $this->assertSession()->pageTextContains('You must enable the Configuration Manager, Help modules to install Color.'); $edit['modules[config][enable]'] = 'config'; $edit['modules[help][enable]'] = 'help'; @@ -213,13 +213,13 @@ public function testUninstallDependents() { $edit = ['uninstall[forum]' => 'forum']; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); // Uninstall comment module. $edit = ['uninstall[comment]' => 'comment']; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); } } diff --git a/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php b/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php index 721d34eeb52c..59f017aa61a8 100644 --- a/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php +++ b/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php @@ -46,7 +46,7 @@ public function testExperimentalConfirmForm() { $edit = []; $edit["modules[test_page_test][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, 'Install'); - $this->assertText('Module Test page has been enabled.'); + $this->assertSession()->pageTextContains('Module Test page has been enabled.'); $this->assertNoText('Experimental modules are provided for testing purposes only.'); // Uninstall the module. @@ -62,15 +62,15 @@ public function testExperimentalConfirmForm() { // The module should not be enabled and there should be a warning and a // list of the experimental modules with only this one. $this->assertNoText('Experimental Test has been enabled.'); - $this->assertText('Experimental modules are provided for testing purposes only.'); - $this->assertText('The following modules are experimental: Experimental Test'); + $this->assertSession()->pageTextContains('Experimental modules are provided for testing purposes only.'); + $this->assertSession()->pageTextContains('The following modules are experimental: Experimental Test'); // There should be no message about enabling dependencies. $this->assertNoText('You must enable'); // Enable the module and confirm that it worked. $this->submitForm([], 'Continue'); - $this->assertText('Experimental Test has been enabled.'); + $this->assertSession()->pageTextContains('Experimental Test has been enabled.'); // Uninstall the module. \Drupal::service('module_installer')->uninstall(['experimental_module_test']); @@ -84,20 +84,20 @@ public function testExperimentalConfirmForm() { // The module should not be enabled and there should be a warning and a // list of the experimental modules with only this one. $this->assertNoText('2 modules have been enabled: Experimental Dependency Test, Experimental Test'); - $this->assertText('Experimental modules are provided for testing purposes only.'); + $this->assertSession()->pageTextContains('Experimental modules are provided for testing purposes only.'); - $this->assertText('The following modules are experimental: Experimental Test'); + $this->assertSession()->pageTextContains('The following modules are experimental: Experimental Test'); // Ensure the non-experimental module is not listed as experimental. $this->assertNoText('The following modules are experimental: Experimental Test, Experimental Dependency Test'); $this->assertNoText('The following modules are experimental: Experimental Dependency Test'); // There should be a message about enabling dependencies. - $this->assertText('You must enable the Experimental Test module to install Experimental Dependency Test'); + $this->assertSession()->pageTextContains('You must enable the Experimental Test module to install Experimental Dependency Test'); // Enable the module and confirm that it worked. $this->submitForm([], 'Continue'); - $this->assertText('2 modules have been enabled: Experimental Dependency Test, Experimental Test'); + $this->assertSession()->pageTextContains('2 modules have been enabled: Experimental Dependency Test, Experimental Test'); // Uninstall the modules. \Drupal::service('module_installer')->uninstall(['experimental_module_test', 'experimental_module_dependency_test']); @@ -113,9 +113,9 @@ public function testExperimentalConfirmForm() { // The module should not be enabled and there should be a warning and a // list of the experimental modules with only this one. $this->assertNoText('2 modules have been enabled: Experimental Dependency Test, Experimental Test'); - $this->assertText('Experimental modules are provided for testing purposes only.'); + $this->assertSession()->pageTextContains('Experimental modules are provided for testing purposes only.'); - $this->assertText('The following modules are experimental: Experimental Test'); + $this->assertSession()->pageTextContains('The following modules are experimental: Experimental Test'); // Ensure the non-experimental module is not listed as experimental. $this->assertNoText('The following modules are experimental: Experimental Dependency Test, Experimental Test'); @@ -126,7 +126,7 @@ public function testExperimentalConfirmForm() { // Enable the module and confirm that it worked. $this->submitForm([], 'Continue'); - $this->assertText('2 modules have been enabled: Experimental Dependency Test, Experimental Test'); + $this->assertSession()->pageTextContains('2 modules have been enabled: Experimental Dependency Test, Experimental Test'); // Try to enable an experimental module that can not be due to // hook_requirements(). @@ -137,7 +137,7 @@ public function testExperimentalConfirmForm() { // Verify that if the module can not be installed, we are not taken to the // confirm form. $this->assertSession()->addressEquals('admin/modules'); - $this->assertText('The Experimental Test Requirements module can not be installed.'); + $this->assertSession()->pageTextContains('The Experimental Test Requirements module can not be installed.'); } } diff --git a/core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php b/core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php index c3df85aa6e72..ed458242e9f9 100644 --- a/core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php +++ b/core/modules/system/tests/src/Functional/Module/HookRequirementsTest.php @@ -26,7 +26,7 @@ public function testHookRequirementsFailure() { $this->drupalPostForm('admin/modules', $edit, 'Install'); // Makes sure the module was NOT installed. - $this->assertText('Requirements 1 Test failed requirements'); + $this->assertSession()->pageTextContains('Requirements 1 Test failed requirements'); $this->assertModules(['requirements1_test'], FALSE); } diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index 29756768b816..b7da5bea519e 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -73,8 +73,8 @@ public function testInstallUninstall() { $edit = []; $edit["modules[help][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, 'Install'); - $this->assertText('has been enabled'); - $this->assertText('hook_modules_installed fired for help'); + $this->assertSession()->pageTextContains('has been enabled'); + $this->assertSession()->pageTextContains('hook_modules_installed fired for help'); $this->assertModuleSuccessfullyInstalled('help'); // Test help for the required modules. @@ -109,12 +109,12 @@ public function testInstallUninstall() { // Handle experimental modules, which require a confirmation screen. if ($package == 'Core (Experimental)') { - $this->assertText('Are you sure you wish to enable experimental modules?'); + $this->assertSession()->pageTextContains('Are you sure you wish to enable experimental modules?'); if (count($modules_to_install) > 1) { // When there are experimental modules, needed dependencies do not // result in the same page title, but there will be expected text // indicating they need to be enabled. - $this->assertText('You must enable'); + $this->assertSession()->pageTextContains('You must enable'); } $this->submitForm([], 'Continue'); } @@ -123,8 +123,8 @@ public function testInstallUninstall() { elseif (count($modules_to_install) > 1) { // Verify that we are on the correct form and that the expected text // about enabling dependencies appears. - $this->assertText('Some required modules must be enabled'); - $this->assertText('You must enable'); + $this->assertSession()->pageTextContains('Some required modules must be enabled'); + $this->assertSession()->pageTextContains('You must enable'); $this->submitForm([], 'Continue'); } @@ -134,17 +134,17 @@ public function testInstallUninstall() { $module_names[] = $all_modules[$module_to_install]->info['name']; } if (count($modules_to_install) > 1) { - $this->assertText(count($module_names) . ' modules have been enabled: ' . implode(', ', $module_names)); + $this->assertSession()->pageTextContains(count($module_names) . ' modules have been enabled: ' . implode(', ', $module_names)); } else { - $this->assertText('Module ' . $module_names[0] . ' has been enabled.'); + $this->assertSession()->pageTextContains('Module ' . $module_names[0] . ' has been enabled.'); } // Check that hook_modules_installed() was invoked with the expected list // of modules, that each module's database tables now exist, and that // appropriate messages appear in the logs. foreach ($modules_to_install as $module_to_install) { - $this->assertText('hook_modules_installed fired for ' . $module_to_install); + $this->assertSession()->pageTextContains('hook_modules_installed fired for ' . $module_to_install); $this->assertLogMessage('system', "%module module installed.", ['%module' => $module_to_install], RfcLogLevel::INFO); $this->assertInstallModuleUpdates($module_to_install); $this->assertModuleSuccessfullyInstalled($module_to_install); @@ -216,10 +216,10 @@ public function testInstallUninstall() { // If there are experimental modules, click the confirm form. if ($experimental) { - $this->assertText('Are you sure you wish to enable experimental modules?'); + $this->assertSession()->pageTextContains('Are you sure you wish to enable experimental modules?'); $this->submitForm([], 'Continue'); } - $this->assertText(count($all_modules) . ' modules have been enabled: '); + $this->assertSession()->pageTextContains(count($all_modules) . ' modules have been enabled: '); } /** @@ -259,14 +259,14 @@ protected function assertSuccessfulUninstall($module, $package = 'Core') { $edit['uninstall[' . $module . ']'] = TRUE; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->assertModules([$module], FALSE); // Check that the appropriate hook was fired and the appropriate log // message appears. (But don't check for the log message if the dblog // module was just uninstalled, since the {watchdog} table won't be there // anymore.) - $this->assertText('hook_modules_uninstalled fired for ' . $module); + $this->assertSession()->pageTextContains('hook_modules_uninstalled fired for ' . $module); $this->assertLogMessage('system', "%module module uninstalled.", ['%module' => $module], RfcLogLevel::INFO); // Check that the module's database tables no longer exist. @@ -349,7 +349,7 @@ protected function assertUninstallModuleUpdates($module) { protected function assertHelp($module, $name) { $this->drupalGet('admin/help/' . $module); $this->assertSession()->statusCodeEquals(200); - $this->assertText($name . ' module'); + $this->assertSession()->pageTextContains($name . ' module'); $this->assertSession()->linkExists('online documentation for the ' . $name . ' module', 0, "Correct online documentation link is in the help page for $module"); } diff --git a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php index 564d97f41d6b..28f1155954f1 100644 --- a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php @@ -79,40 +79,40 @@ public function setUp(): void { public function testUninstall() { // Check that Taxonomy cannot be uninstalled yet. $this->drupalGet('admin/modules/uninstall'); - $this->assertText('Remove content items'); + $this->assertSession()->pageTextContains('Remove content items'); $this->assertSession()->linkByHrefExists('admin/modules/uninstall/entity/taxonomy_term'); // Delete Taxonomy term data. $this->drupalGet('admin/modules/uninstall/entity/taxonomy_term'); $term_count = count($this->terms); for ($i = 1; $i < 11; $i++) { - $this->assertText($this->terms[$term_count - $i]->label()); + $this->assertSession()->pageTextContains($this->terms[$term_count - $i]->label()); } $term_count = $term_count - 10; - $this->assertText("And $term_count more taxonomy terms."); - $this->assertText('This action cannot be undone.'); - $this->assertText('Make a backup of your database if you want to be able to restore these items.'); + $this->assertSession()->pageTextContains("And $term_count more taxonomy terms."); + $this->assertSession()->pageTextContains('This action cannot be undone.'); + $this->assertSession()->pageTextContains('Make a backup of your database if you want to be able to restore these items.'); $this->submitForm([], 'Delete all taxonomy terms'); // Check that we are redirected to the uninstall page and data has been // removed. $this->assertSession()->addressEquals('admin/modules/uninstall'); - $this->assertText('All taxonomy terms have been deleted.'); + $this->assertSession()->pageTextContains('All taxonomy terms have been deleted.'); // Check that there is no more data to be deleted, Taxonomy is ready to be // uninstalled. - $this->assertText('Enables the categorization of content.'); + $this->assertSession()->pageTextContains('Enables the categorization of content.'); $this->assertSession()->linkByHrefNotExists('admin/modules/uninstall/entity/taxonomy_term'); // Uninstall the Taxonomy module. $this->drupalPostForm('admin/modules/uninstall', ['uninstall[taxonomy]' => TRUE], 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->assertNoText('Enables the categorization of content.'); // Check Node cannot be uninstalled yet, there is content to be removed. $this->drupalGet('admin/modules/uninstall'); - $this->assertText('Remove content items'); + $this->assertSession()->pageTextContains('Remove content items'); $this->assertSession()->linkByHrefExists('admin/modules/uninstall/entity/node'); // Delete Node data. @@ -120,52 +120,54 @@ public function testUninstall() { // Only the 5 pages should be listed as the 5 articles are initially inaccessible. foreach ($this->nodes as $node) { if ($node->bundle() === 'page') { - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } else { $node->set('private', FALSE)->save(); } } - $this->assertText('And 5 more content items.'); + $this->assertSession()->pageTextContains('And 5 more content items.'); // All 10 nodes should now be listed as none are still inaccessible. $this->drupalGet('admin/modules/uninstall/entity/node'); foreach ($this->nodes as $node) { - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } // Ensures there is no more count when not necessary. $this->assertNoText('And 0 more content'); - $this->assertText('This action cannot be undone.'); - $this->assertText('Make a backup of your database if you want to be able to restore these items.'); + $this->assertSession()->pageTextContains('This action cannot be undone.'); + $this->assertSession()->pageTextContains('Make a backup of your database if you want to be able to restore these items.'); // Create another node so we have 11. $this->nodes[] = $this->drupalCreateNode(['type' => 'page']); $this->drupalGet('admin/modules/uninstall/entity/node'); // Ensures singular case is used when a single entity is left after listing // the first 10's labels. - $this->assertText('And 1 more content item.'); + $this->assertSession()->pageTextContains('And 1 more content item.'); // Create another node so we have 12, with one private. $this->nodes[] = $this->drupalCreateNode(['type' => 'article', 'private' => TRUE]); $this->drupalGet('admin/modules/uninstall/entity/node'); - $this->assertText('And 2 more content items.'); + // Ensures singular case is used when a single entity is left after listing + // the first 10's labels. + $this->assertSession()->pageTextContains('And 2 more content items.'); $this->submitForm([], 'Delete all content items'); // Check we are redirected to the uninstall page and data has been removed. $this->assertSession()->addressEquals('admin/modules/uninstall'); - $this->assertText('All content items have been deleted.'); + $this->assertSession()->pageTextContains('All content items have been deleted.'); // Check there is no more data to be deleted, Node is ready to be // uninstalled. - $this->assertText('Allows content to be submitted to the site and displayed on pages.'); + $this->assertSession()->pageTextContains('Allows content to be submitted to the site and displayed on pages.'); $this->assertSession()->linkByHrefNotExists('admin/modules/uninstall/entity/node'); // Uninstall Node module. $this->drupalPostForm('admin/modules/uninstall', ['uninstall[node]' => TRUE], 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->assertNoText('Allows content to be submitted to the site and displayed on pages.'); // Ensure a 404 is returned when accessing a non-existent entity type. @@ -174,7 +176,7 @@ public function testUninstall() { // Test an entity type which does not have any existing entities. $this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label'); - $this->assertText('There are 0 entity test without label entities to delete.'); + $this->assertSession()->pageTextContains('There are 0 entity test without label entities to delete.'); $this->assertSession()->buttonNotExists("Delete all entity test without label entities"); // Test an entity type without a label. @@ -186,14 +188,14 @@ public function testUninstall() { 'name' => $this->randomMachineName(), ])->save(); $this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label'); - $this->assertText('This will delete 1 entity test without label.'); + $this->assertSession()->pageTextContains('This will delete 1 entity test without label.'); $this->assertSession()->buttonExists("Delete all entity test without label entities"); $storage->create([ 'id' => mb_strtolower($this->randomMachineName()), 'name' => $this->randomMachineName(), ])->save(); $this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label'); - $this->assertText('This will delete 2 entity test without label entities.'); + $this->assertSession()->pageTextContains('This will delete 2 entity test without label entities.'); } } diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php index e360bacd8013..7b245cf81e1c 100644 --- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php @@ -77,8 +77,8 @@ public function testUninstallPage() { // @see regression https://www.drupal.org/node/2512106 $this->assertRaw('<label for="edit-uninstall-node" class="module-name table-filter-text-source">Node</label>'); - $this->assertText('The following reason prevents Node from being uninstalled:'); - $this->assertText('There is content for the entity type: Content'); + $this->assertSession()->pageTextContains('The following reason prevents Node from being uninstalled:'); + $this->assertSession()->pageTextContains('There is content for the entity type: Content'); // Delete the node to allow node to be uninstalled. $node->delete(); @@ -87,10 +87,10 @@ public function testUninstallPage() { $edit['uninstall[module_test]'] = TRUE; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->assertNoText('Configuration deletions'); - $this->assertText('Configuration updates'); - $this->assertText($node_type->label()); + $this->assertSession()->pageTextContains('Configuration updates'); + $this->assertSession()->pageTextContains($node_type->label()); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); // Uninstall node testing that the configuration that will be deleted is // listed. @@ -98,13 +98,13 @@ public function testUninstallPage() { $edit = []; $edit['uninstall[node]'] = TRUE; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); - $this->assertText('Configuration deletions'); + $this->assertSession()->pageTextContains('Configuration deletions'); $this->assertNoText('Configuration updates'); $entity_types = []; foreach ($node_dependencies as $entity) { $label = $entity->label() ?: $entity->id(); - $this->assertText($label); + $this->assertSession()->pageTextContains($label); $entity_types[] = $entity->getEntityTypeId(); } $entity_types = array_unique($entity_types); @@ -122,7 +122,7 @@ public function testUninstallPage() { $this->assertEquals('test_uninstall_page', $cached->data, new FormattableMarkup('Cache entry found: @bin', ['@bin' => $cached->data])); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); // Check that the page does not have double escaped HTML tags. $this->assertNoRaw('<label'); @@ -132,7 +132,7 @@ public function testUninstallPage() { // Make sure we get an error message when we try to confirm uninstallation // of an empty list of modules. $this->drupalGet('admin/modules/uninstall/confirm'); - $this->assertText('The selected modules could not be uninstalled, either due to a website problem or due to the uninstall confirmation form timing out. Please try again.'); + $this->assertSession()->pageTextContains('The selected modules could not be uninstalled, either due to a website problem or due to the uninstall confirmation form timing out. Please try again.'); // Make sure confirmation page is accessible only during uninstall process. $this->drupalGet('admin/modules/uninstall/confirm'); @@ -142,7 +142,7 @@ public function testUninstallPage() { // Make sure the correct error is shown when no modules are selected. $edit = []; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); - $this->assertText('No modules selected.'); + $this->assertSession()->pageTextContains('No modules selected.'); } /** @@ -164,11 +164,11 @@ public function testFailedInstallStatus() { // Even though the module failed to install properly, its configuration // status is "enabled" and should still be available to uninstall. $this->drupalGet('admin/modules/uninstall'); - $this->assertText('Module installer config test'); + $this->assertSession()->pageTextContains('Module installer config test'); $edit['uninstall[module_installer_config_test]'] = TRUE; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->assertNoText('Module installer config test'); } diff --git a/core/modules/system/tests/src/Functional/Pager/PagerTest.php b/core/modules/system/tests/src/Functional/Pager/PagerTest.php index ea54545b05d9..4d7c43d8da4d 100644 --- a/core/modules/system/tests/src/Functional/Pager/PagerTest.php +++ b/core/modules/system/tests/src/Functional/Pager/PagerTest.php @@ -84,15 +84,15 @@ public function testActiveClass() { public function testPagerQueryParametersAndCacheContext() { // First page. $this->drupalGet('pager-test/query-parameters'); - $this->assertText('Pager calls: 0'); - $this->assertText('[url.query_args.pagers:0]=0.0'); + $this->assertSession()->pageTextContains('Pager calls: 0'); + $this->assertSession()->pageTextContains('[url.query_args.pagers:0]=0.0'); $this->assertCacheContext('url.query_args'); // Go to last page, the count of pager calls need to go to 1. $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--last']); $elements[0]->click(); - $this->assertText('Pager calls: 1'); - $this->assertText('[url.query_args.pagers:0]=0.60'); + $this->assertSession()->pageTextContains('Pager calls: 1'); + $this->assertSession()->pageTextContains('[url.query_args.pagers:0]=0.60'); $this->assertCacheContext('url.query_args'); // Reset counter to 0. @@ -102,8 +102,8 @@ public function testPagerQueryParametersAndCacheContext() { $elements[0]->click(); $elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--first']); $elements[0]->click(); - $this->assertText('Pager calls: 2'); - $this->assertText('[url.query_args.pagers:0]=0.0'); + $this->assertSession()->pageTextContains('Pager calls: 2'); + $this->assertSession()->pageTextContains('[url.query_args.pagers:0]=0.0'); $this->assertCacheContext('url.query_args'); } diff --git a/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php b/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php index 1c82cfe15591..69fb5c152beb 100644 --- a/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php +++ b/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php @@ -79,7 +79,7 @@ public function testRenderCachedBlock() { // Get the front page, which should now have our visible block. $this->drupalGet(''); // Make sure our block is visible. - $this->assertText('Markup from attached_rendering_block.'); + $this->assertSession()->pageTextContains('Markup from attached_rendering_block.'); // Test that all our attached items are present. $this->assertFeed(); $this->assertHead(); @@ -89,7 +89,7 @@ public function testRenderCachedBlock() { // Reload the page, to test caching. $this->drupalGet(''); // Make sure our block is visible. - $this->assertText('Markup from attached_rendering_block.'); + $this->assertSession()->pageTextContains('Markup from attached_rendering_block.'); // The header should be present again. $this->assertSession()->responseHeaderEquals('X-Test-Teapot', 'Teapot Mode Active'); } diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index 13194465fb60..d00a2f5bda63 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -238,12 +238,12 @@ public function testUrlGeneratorFront() { public function testRouterMatching() { $this->drupalGet('router_test/test14/1'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('User route "entity.user.canonical" was matched.'); + $this->assertSession()->pageTextContains('User route "entity.user.canonical" was matched.'); // Try to match a route for a non-existent user. $this->drupalGet('router_test/test14/2'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Route not matched.'); + $this->assertSession()->pageTextContains('Route not matched.'); // Check that very long paths don't cause an error. $path = 'router_test/test1'; @@ -261,7 +261,7 @@ public function testRouterMatching() { public function testRouterResponsePsr7() { $this->drupalGet('/router_test/test23'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('test23'); + $this->assertSession()->pageTextContains('test23'); } /** @@ -274,11 +274,11 @@ public function testUserAccount() { $second_account = $this->drupalCreateUser(); $this->drupalGet('router_test/test12/' . $second_account->id()); - $this->assertText($account->getAccountName() . ':' . $second_account->getAccountName()); + $this->assertSession()->pageTextContains($account->getAccountName() . ':' . $second_account->getAccountName()); $this->assertEquals($this->loggedInUser->id(), $account->id(), 'Ensure that the user was not changed.'); $this->drupalGet('router_test/test13/' . $second_account->id()); - $this->assertText($account->getAccountName() . ':' . $second_account->getAccountName()); + $this->assertSession()->pageTextContains($account->getAccountName() . ':' . $second_account->getAccountName()); $this->assertEquals($this->loggedInUser->id(), $account->id(), 'Ensure that the user was not changed.'); } diff --git a/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php b/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php index e55ff0c83d31..0b2c721a869d 100644 --- a/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php +++ b/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php @@ -36,7 +36,7 @@ public function testServiceProviderRegistrationIntegration() { // saying it has fired. This will fire on every page request so it should // show up on the front page. $this->drupalGet(''); - $this->assertText('The service_provider_test event subscriber fired!'); + $this->assertSession()->pageTextContains('The service_provider_test event subscriber fired!'); } } diff --git a/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php index 510864318d77..4657df6c3732 100644 --- a/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php +++ b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php @@ -87,7 +87,7 @@ public function testHttpsSession() { // Verify that user is logged in on secure URL. $this->drupalGet($this->httpsUrl('admin/config')); - $this->assertText('Configuration'); + $this->assertSession()->pageTextContains('Configuration'); $this->assertSession()->statusCodeEquals(200); // Verify that user is not logged in on non-secure URL. diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php index 7408f3f3f692..6bc87f73e263 100644 --- a/core/modules/system/tests/src/Functional/Session/SessionTest.php +++ b/core/modules/system/tests/src/Functional/Session/SessionTest.php @@ -71,7 +71,7 @@ public function testSessionSaveRegenerate() { ]; $this->drupalPostForm('user/login', $edit, 'Log in'); $this->drupalGet('user'); - $pass = $this->assertText($user->getAccountName()); + $pass = $this->assertSession()->pageTextContains($user->getAccountName()); $this->_logged_in = $pass; $this->drupalGet('session-test/id'); @@ -94,11 +94,11 @@ public function testDataPersistence() { $value_1 = $this->randomMachineName(); // Verify that the session value is stored. $this->drupalGet('session-test/set/' . $value_1); - $this->assertText($value_1); + $this->assertSession()->pageTextContains($value_1); // Verify that the session correctly returned the stored data for an // authenticated user. $this->drupalGet('session-test/get'); - $this->assertText($value_1); + $this->assertSession()->pageTextContains($value_1); // Attempt to write over val_1. If drupal_save_session(FALSE) is working. // properly, val_1 will still be set. @@ -107,10 +107,10 @@ public function testDataPersistence() { // session-test/no-set. $this->drupalGet('session-test/no-set/' . $value_2); $session = $this->getSession(); - $this->assertText($value_2); + $this->assertSession()->pageTextContains($value_2); // Verify that the session data is not saved for drupal_save_session(FALSE). $this->drupalGet('session-test/get'); - $this->assertText($value_1); + $this->assertSession()->pageTextContains($value_1); // Switch browser cookie to anonymous user, then back to user 1. $session_cookie_name = $this->getSessionName(); @@ -122,7 +122,7 @@ public function testDataPersistence() { $session->setCookie($session_cookie_name, $session_cookie_value); // Verify that the session data persists through browser close. $this->drupalGet('session-test/get'); - $this->assertText($value_1); + $this->assertSession()->pageTextContains($value_1); $this->mink->setDefaultSessionName('default'); // Logout the user and make sure the stored value no longer persists. @@ -136,20 +136,20 @@ public function testDataPersistence() { $value_3 = $this->randomMachineName(); // Verify that session data is stored for anonymous user. $this->drupalGet('session-test/set/' . $value_3); - $this->assertText($value_3); + $this->assertSession()->pageTextContains($value_3); // Verify that session correctly returns the stored data for an anonymous // user. $this->drupalGet('session-test/get'); - $this->assertText($value_3); + $this->assertSession()->pageTextContains($value_3); // Try to store data when drupal_save_session(FALSE). $value_4 = $this->randomMachineName(); // Verify that the session value is correctly passed to session-test/no-set. $this->drupalGet('session-test/no-set/' . $value_4); - $this->assertText($value_4); + $this->assertSession()->pageTextContains($value_4); // Verify that the session data is not saved for drupal_save_session(FALSE). $this->drupalGet('session-test/get'); - $this->assertText($value_3); + $this->assertSession()->pageTextContains($value_3); // Login, the data should persist. $this->drupalLogin($user); @@ -174,7 +174,7 @@ public function testSessionPersistenceOnLogin() { $this->drupalLogin($user); // Test property added to session object form hook_user_login(). $this->drupalGet('session-test/get-from-session-object'); - $this->assertText('foobar'); + $this->assertSession()->pageTextContains('foobar'); } /** @@ -216,7 +216,7 @@ public function testEmptyAnonymousSession() { $this->assertSessionEmpty(FALSE); // Verify that caching was bypassed. $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); - $this->assertText('This is a dummy message.'); + $this->assertSession()->pageTextContains('This is a dummy message.'); // Verify that session cookie was deleted. $this->assertSession()->responseHeaderMatches('Set-Cookie', '/SESS\w+=deleted/'); diff --git a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php index 2574c71a38ae..098207f1aa75 100644 --- a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php +++ b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php @@ -51,7 +51,7 @@ protected function setUp(): void { public function testAccessDenied() { $this->drupalGet('admin'); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); $this->assertSession()->statusCodeEquals(403); // Ensure that users without permission are denied access and have the @@ -85,8 +85,8 @@ public function testAccessDenied() { // Log out and check that the user login block is shown on custom 403 pages. $this->drupalLogout(); $this->drupalGet('admin'); - $this->assertText($this->adminUser->getAccountName()); - $this->assertText('Username'); + $this->assertSession()->pageTextContains($this->adminUser->getAccountName()); + $this->assertSession()->pageTextContains('Username'); // Log back in and remove the custom 403 page. $this->drupalLogin($this->adminUser); @@ -98,9 +98,9 @@ public function testAccessDenied() { // Logout and check that the user login block is shown on default 403 pages. $this->drupalLogout(); $this->drupalGet('admin'); - $this->assertText('Access denied'); + $this->assertSession()->pageTextContains('Access denied'); $this->assertSession()->statusCodeEquals(403); - $this->assertText('Username'); + $this->assertSession()->pageTextContains('Username'); // Log back in, set the custom 403 page to /user/login and remove the block $this->drupalLogin($this->adminUser); @@ -116,7 +116,7 @@ public function testAccessDenied() { $this->drupalPostForm('admin/config/system/site-information', $edit, 'Log in'); // Check that we're still on the same page. - $this->assertText('Basic site settings'); + $this->assertSession()->pageTextContains('Basic site settings'); } /** @@ -128,14 +128,14 @@ public function testAccessDeniedCustomPageWithAccessDenied() { $this->drupalGet('/system-test/always-denied'); $this->assertNoText('Admin-only 4xx response'); - $this->assertText('You are not authorized to access this page.'); + $this->assertSession()->pageTextContains('You are not authorized to access this page.'); $this->assertSession()->statusCodeEquals(403); // Verify the access cacheability metadata for custom 403 is bubbled. $this->assertCacheContext('user.roles'); $this->drupalLogin($this->adminUser); $this->drupalGet('/system-test/always-denied'); - $this->assertText('Admin-only 4xx response'); + $this->assertSession()->pageTextContains('Admin-only 4xx response'); $this->assertSession()->statusCodeEquals(403); // Verify the access cacheability metadata for custom 403 is bubbled. $this->assertCacheContext('user.roles'); diff --git a/core/modules/system/tests/src/Functional/System/AdminTest.php b/core/modules/system/tests/src/Functional/System/AdminTest.php index 072c3b44e790..d97f8ce6c2dc 100644 --- a/core/modules/system/tests/src/Functional/System/AdminTest.php +++ b/core/modules/system/tests/src/Functional/System/AdminTest.php @@ -66,7 +66,7 @@ public function testAdminPages() { $this->assertSession()->linkExists($item->getTitle()); $this->assertSession()->linkByHrefExists($item->getUrlObject()->toString()); // The description should appear below the link. - $this->assertText($item->getDescription()); + $this->assertSession()->pageTextContains($item->getDescription()); } // For each administrative listing page on which the Locale module appears, diff --git a/core/modules/system/tests/src/Functional/System/CronRunTest.php b/core/modules/system/tests/src/Functional/System/CronRunTest.php index 0d5d0c015af6..cd9e98252ca4 100644 --- a/core/modules/system/tests/src/Functional/System/CronRunTest.php +++ b/core/modules/system/tests/src/Functional/System/CronRunTest.php @@ -83,7 +83,7 @@ public function testAutomatedCron() { // Disable cron through the interface by setting the interval to zero. $this->drupalPostForm('admin/config/system/cron', ['interval' => 0], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $this->drupalLogout(); // Test if cron does not run when the cron interval is set to zero. @@ -122,7 +122,7 @@ public function testCronUI() { \Drupal::state()->set('system.cron_last', $cron_last); $this->submitForm([], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $this->assertSession()->addressEquals('admin/config/system/cron'); // Check that cron does not run when saving the configuration form. @@ -147,7 +147,7 @@ public function testManualCron() { $this->drupalGet('admin/reports/status'); $this->clickLink(t('Run cron')); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Cron ran successfully.'); + $this->assertSession()->pageTextContains('Cron ran successfully.'); } } diff --git a/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php b/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php index ed2b467f2671..1ee4c6fcb705 100644 --- a/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php +++ b/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php @@ -28,7 +28,7 @@ public function testDateLocking() { $this->drupalGet('admin/config/regional/date-time'); $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/short'); $this->assertSession()->linkByHrefNotExists('admin/config/regional/date-time/formats/manage/html_date'); - $this->assertText('Fallback date format'); + $this->assertSession()->pageTextContains('Fallback date format'); $this->assertNoText('short (locked)'); // Locked date formats are not editable. diff --git a/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php b/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php index c8c074e5508d..7803be472242 100644 --- a/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php +++ b/core/modules/system/tests/src/Functional/System/DateFormatsMachineNameTest.php @@ -38,7 +38,7 @@ public function testDateFormatsMachineNameAllowedValues() { 'date_format_pattern' => 'Y-m-d', ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); - $this->assertText('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'); + $this->assertSession()->pageTextContains('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'); // Try to create a date format with the reserved machine name "custom". $edit = [ @@ -47,7 +47,7 @@ public function testDateFormatsMachineNameAllowedValues() { 'date_format_pattern' => 'Y-m-d', ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); - $this->assertText('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'); + $this->assertSession()->pageTextContains('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'); // Try to create a date format with a machine name, "fallback", that // already exists. @@ -57,7 +57,7 @@ public function testDateFormatsMachineNameAllowedValues() { 'date_format_pattern' => 'j/m/Y', ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); // Create a date format with a machine name distinct from the previous two. $id = mb_strtolower($this->randomMachineName(16)); @@ -67,7 +67,7 @@ public function testDateFormatsMachineNameAllowedValues() { 'date_format_pattern' => 'd/m/Y', ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); - $this->assertText('Custom date format added.'); + $this->assertSession()->pageTextContains('Custom date format added.'); // Try to create a date format with same machine name as the previous one. $edit = [ @@ -76,7 +76,7 @@ public function testDateFormatsMachineNameAllowedValues() { 'date_format_pattern' => 'd-m-Y', ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); } } diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php index 6c365e6e2cef..fb65b916963b 100644 --- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php +++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php @@ -72,10 +72,10 @@ public function testTimeZoneHandling() { // Confirm date format and time zone. $this->drupalGet('node/' . $node1->id()); // Date should be identical, with GMT offset of -10 hours. - $this->assertText('2007-01-31 21:00:00 -1000'); + $this->assertSession()->pageTextContains('2007-01-31 21:00:00 -1000'); $this->drupalGet('node/' . $node2->id()); // Date should be identical, with GMT offset of -10 hours. - $this->assertText('2007-07-31 21:00:00 -1000'); + $this->assertSession()->pageTextContains('2007-07-31 21:00:00 -1000'); // Set time zone to Los Angeles time. $config->set('timezone.default', 'America/Los_Angeles')->save(); @@ -84,10 +84,10 @@ public function testTimeZoneHandling() { // Confirm date format and time zone. $this->drupalGet('node/' . $node1->id()); // Date should be two hours ahead, with GMT offset of -8 hours. - $this->assertText('2007-01-31 23:00:00 -0800'); + $this->assertSession()->pageTextContains('2007-01-31 23:00:00 -0800'); $this->drupalGet('node/' . $node2->id()); // Date should be three hours ahead, with GMT offset of -7 hours. - $this->assertText('2007-08-01 00:00:00 -0700'); + $this->assertSession()->pageTextContains('2007-08-01 00:00:00 -0700'); } /** @@ -111,11 +111,11 @@ public function testDateFormatConfiguration() { // Verify that the user is redirected to the correct page. $this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection')); // Check that date format added confirmation message appears. - $this->assertText('Custom date format added.'); + $this->assertSession()->pageTextContains('Custom date format added.'); // Check that custom date format appears in the date format list. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Check that the delete link for custom date format appears. - $this->assertText('Delete'); + $this->assertSession()->pageTextContains('Delete'); // Edit the custom date format and re-save without editing the format. $this->drupalGet('admin/config/regional/date-time'); @@ -123,7 +123,7 @@ public function testDateFormatConfiguration() { $this->submitForm([], 'Save format'); // Verify that the user is redirected to the correct page. $this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection')); - $this->assertText('Custom date format updated.'); + $this->assertSession()->pageTextContains('Custom date format updated.'); // Edit custom date format. $this->drupalGet('admin/config/regional/date-time'); @@ -134,7 +134,7 @@ public function testDateFormatConfiguration() { $this->drupalPostForm($this->getUrl(), $edit, 'Save format'); // Verify that the user is redirected to the correct page. $this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection')); - $this->assertText('Custom date format updated.'); + $this->assertSession()->pageTextContains('Custom date format updated.'); // Delete custom date format. $this->clickLink(t('Delete')); @@ -159,11 +159,11 @@ public function testDateFormatConfiguration() { $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); // Verify that the user is redirected to the correct page. $this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection')); - $this->assertText('Custom date format added.'); + $this->assertSession()->pageTextContains('Custom date format added.'); // Check that the custom date format appears in the date format list. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Check that the delete link for custom date format appears. - $this->assertText('Delete'); + $this->assertSession()->pageTextContains('Delete'); $date_format = DateFormat::create([ 'id' => 'xss_short', @@ -188,9 +188,9 @@ public function testDateFormatConfiguration() { $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, 'Add format'); // Verify that the user is redirected to the correct page. $this->assertSession()->addressEquals(Url::fromRoute('entity.date_format.collection')); - $this->assertText('Custom date format added.'); + $this->assertSession()->pageTextContains('Custom date format added.'); // Check that the custom date format appears in the date format list. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); $this->assertSession()->assertEscaped('<em>' . date("Y") . '</em>'); } @@ -213,7 +213,7 @@ public function testEnteringDateTimeViaSelectors() { $this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/add-field', $edit, 'Save and continue'); // Check that the new datetime field was created, and process is now set // to continue for configuration. - $this->assertText('These settings apply to the'); + $this->assertSession()->pageTextContains('These settings apply to the'); $this->drupalGet('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage'); $edit = [ @@ -224,7 +224,7 @@ public function testEnteringDateTimeViaSelectors() { $this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage', $edit, 'Save field settings'); $this->drupalGet('admin/structure/types/manage/page_with_date/fields'); - $this->assertText('field_dt'); + $this->assertSession()->pageTextContains('field_dt'); $this->drupalGet('admin/structure/types/manage/page_with_date/form-display'); $edit = [ @@ -249,14 +249,14 @@ public function testEnteringDateTimeViaSelectors() { 'field_dt[0][value][minute]' => '30', ]; $this->drupalPostForm('node/add/page_with_date', $edit, 'Save'); - $this->assertText('Selected combination of day and month is not valid.'); + $this->assertSession()->pageTextContains('Selected combination of day and month is not valid.'); $edit['field_dt[0][value][day]'] = '29'; $this->drupalPostForm('node/add/page_with_date', $edit, 'Save'); $this->assertNoText('Selected combination of day and month is not valid.'); $this->drupalGet('node/1'); - $this->assertText('Mon, 02/29/2016 - 01:30'); + $this->assertSession()->pageTextContains('Mon, 02/29/2016 - 01:30'); } } diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php index d840311db170..cfbe1f7861f1 100644 --- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php +++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php @@ -126,7 +126,7 @@ public function testExceptionHandler() { $this->assertSession()->statusCodeEquals(500); // We cannot use assertErrorMessage() since the exact error reported // varies from database to database. Check that the SQL string is displayed. - $this->assertText($error_pdo_exception['%type']); + $this->assertSession()->pageTextContains($error_pdo_exception['%type']); // Assert statement improved since static queries adds table alias in the // error message. $this->assertSession()->pageTextContains($error_pdo_exception['@message']); diff --git a/core/modules/system/tests/src/Functional/System/FrontPageTest.php b/core/modules/system/tests/src/Functional/System/FrontPageTest.php index 9204e046a51c..a42f27b3ac3b 100644 --- a/core/modules/system/tests/src/Functional/System/FrontPageTest.php +++ b/core/modules/system/tests/src/Functional/System/FrontPageTest.php @@ -62,16 +62,16 @@ public function testDrupalFrontPage() { $this->assertSession()->titleEquals('Home | Drupal'); // Check that path is the front page. - $this->assertText('On front page.'); + $this->assertSession()->pageTextContains('On front page.'); $this->drupalGet('node'); - $this->assertText('On front page.'); + $this->assertSession()->pageTextContains('On front page.'); $this->drupalGet($this->nodePath); $this->assertNoText('On front page.'); // Change the front page to an invalid path. $edit = ['site_frontpage' => '/kittens']; $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration'); - $this->assertText("Either the path '" . $edit['site_frontpage'] . "' is invalid or you do not have access to it."); + $this->assertSession()->pageTextContains("Either the path '" . $edit['site_frontpage'] . "' is invalid or you do not have access to it."); // Change the front page to a path without a starting slash. $edit = ['site_frontpage' => $this->nodePath]; @@ -82,14 +82,14 @@ public function testDrupalFrontPage() { $edit['site_frontpage'] = '/' . $this->nodePath; $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration'); // Check that the front page path has been saved. - $this->assertText(t('The configuration options have been saved.')); + $this->assertSession()->pageTextContains(t('The configuration options have been saved.')); // Check that path is the front page. $this->drupalGet(''); - $this->assertText('On front page.'); + $this->assertSession()->pageTextContains('On front page.'); $this->drupalGet('node'); $this->assertNoText('On front page.'); $this->drupalGet($this->nodePath); - $this->assertText('On front page.'); + $this->assertSession()->pageTextContains('On front page.'); } } diff --git a/core/modules/system/tests/src/Functional/System/HtaccessTest.php b/core/modules/system/tests/src/Functional/System/HtaccessTest.php index 0652713039d8..c2b7f051cb3a 100644 --- a/core/modules/system/tests/src/Functional/System/HtaccessTest.php +++ b/core/modules/system/tests/src/Functional/System/HtaccessTest.php @@ -122,14 +122,14 @@ public function testFileAccess() { $node->save(); $this->drupalGet('test.php'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('This is a node'); + $this->assertSession()->pageTextContains('This is a node'); // Update node's alias to test.php/test. $node->path = '/test.php/test'; $node->save(); $this->drupalGet('test.php/test'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('This is a node'); + $this->assertSession()->pageTextContains('This is a node'); } /** diff --git a/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php b/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php index 00bdc50b2d6c..f71082b03974 100644 --- a/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php +++ b/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php @@ -50,7 +50,7 @@ public function testMainContentFallback() { $edit['uninstall[block]'] = 'block'; $this->drupalPostForm('admin/modules/uninstall', $edit, 'Uninstall'); $this->submitForm([], 'Uninstall'); - $this->assertText('The selected modules have been uninstalled.'); + $this->assertSession()->pageTextContains('The selected modules have been uninstalled.'); $this->rebuildContainer(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('block'), 'Block module uninstall.'); @@ -60,7 +60,7 @@ public function testMainContentFallback() { $this->drupalGet('admin/config/system/site-information'); $this->assertSession()->fieldExists('site_name'); $this->drupalGet('system-test/main-content-fallback'); - $this->assertText('Content to test main content fallback'); + $this->assertSession()->pageTextContains('Content to test main content fallback'); // Request a user* page and see if it is displayed. $this->drupalLogin($this->webUser); $this->drupalGet('user/' . $this->webUser->id() . '/edit'); @@ -71,7 +71,7 @@ public function testMainContentFallback() { $edit = []; $edit['modules[block][enable]'] = 'block'; $this->drupalPostForm('admin/modules', $edit, 'Install'); - $this->assertText('Module Block has been enabled.'); + $this->assertSession()->pageTextContains('Module Block has been enabled.'); $this->rebuildContainer(); $this->assertTrue(\Drupal::moduleHandler()->moduleExists('block'), 'Block module re-enabled.'); } diff --git a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php index abfe17b0f125..ef99dbdeb15a 100644 --- a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php +++ b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php @@ -48,7 +48,7 @@ protected function setUp(): void { public function testPageNotFound() { $this->drupalLogin($this->adminUser); $this->drupalGet($this->randomMachineName(10)); - $this->assertText('Page not found'); + $this->assertSession()->pageTextContains('Page not found'); // Set a custom 404 page without a starting slash. $edit = [ @@ -64,7 +64,7 @@ public function testPageNotFound() { $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration'); $this->drupalGet($this->randomMachineName(10)); - $this->assertText($this->adminUser->getAccountName()); + $this->assertSession()->pageTextContains($this->adminUser->getAccountName()); } /** @@ -76,14 +76,14 @@ public function testPageNotFoundCustomPageWithAccessDenied() { $this->drupalGet('/this-path-does-not-exist'); $this->assertNoText('Admin-only 4xx response'); - $this->assertText('The requested page could not be found.'); + $this->assertSession()->pageTextContains('The requested page could not be found.'); $this->assertSession()->statusCodeEquals(404); // Verify the access cacheability metadata for custom 404 is bubbled. $this->assertCacheContext('user.roles'); $this->drupalLogin($this->adminUser); $this->drupalGet('/this-path-does-not-exist'); - $this->assertText('Admin-only 4xx response'); + $this->assertSession()->pageTextContains('Admin-only 4xx response'); $this->assertNoText('The requested page could not be found.'); $this->assertSession()->statusCodeEquals(404); // Verify the access cacheability metadata for custom 404 is bubbled. diff --git a/core/modules/system/tests/src/Functional/System/PageTitleTest.php b/core/modules/system/tests/src/Functional/System/PageTitleTest.php index 354aadedd070..84f81fb0ca43 100644 --- a/core/modules/system/tests/src/Functional/System/PageTitleTest.php +++ b/core/modules/system/tests/src/Functional/System/PageTitleTest.php @@ -65,9 +65,9 @@ public function testTitleTags() { // Make sure tags in the node title are converted. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertNotNull($node, 'Node created and found in database'); - $this->assertText(Html::escape($edit['title[0][value]'])); + $this->assertSession()->responseContains(Html::escape($edit['title[0][value]'])); $this->drupalGet("node/" . $node->id()); - $this->assertText(Html::escape($edit['title[0][value]'])); + $this->assertSession()->responseContains(Html::escape($edit['title[0][value]'])); } /** diff --git a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php index 51f1349fe3c7..d463396670b8 100644 --- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php +++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php @@ -85,13 +85,13 @@ public function testSiteMaintenance() { $this->drupalLogout(); $this->drupalGet(''); $this->assertEquals('Site under maintenance', $this->cssSelect('main h1')[0]->getText()); - $this->assertText($offline_message); + $this->assertSession()->pageTextContains($offline_message); $this->drupalGet('node'); $this->assertEquals('Site under maintenance', $this->cssSelect('main h1')[0]->getText()); - $this->assertText($offline_message); + $this->assertSession()->pageTextContains($offline_message); $this->drupalGet('user/register'); $this->assertEquals('Site under maintenance', $this->cssSelect('main h1')[0]->getText()); - $this->assertText($offline_message); + $this->assertSession()->pageTextContains($offline_message); // Verify that user is able to log in. $this->drupalGet('user'); @@ -106,7 +106,7 @@ public function testSiteMaintenance() { 'pass' => $this->user->pass_raw, ]; $this->submitForm($edit, 'Log in'); - $this->assertText($user_message); + $this->assertSession()->pageTextContains($user_message); // Log in administrative user and configure a custom site offline message. $this->drupalLogout(); @@ -128,7 +128,7 @@ public function testSiteMaintenance() { // Verify that custom site offline message is not displayed on user/password. $this->drupalGet('user/password'); - $this->assertText('Username or email address'); + $this->assertSession()->pageTextContains('Username or email address'); // Submit password reset form. $edit = [ @@ -141,7 +141,7 @@ public function testSiteMaintenance() { // Log in with temporary login link. $this->drupalPostForm($path, [], 'Log in'); - $this->assertText($user_message); + $this->assertSession()->pageTextContains($user_message); // Regression test to check if title displays in Bartik on maintenance page. \Drupal::service('theme_installer')->install(['bartik']); diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php index 365267fad3af..cab94ed7ccd4 100644 --- a/core/modules/system/tests/src/Functional/System/StatusTest.php +++ b/core/modules/system/tests/src/Functional/System/StatusTest.php @@ -50,7 +50,7 @@ public function testStatusPage() { $this->assertSession()->statusCodeEquals(200); // Verify that the PHP version is shown on the page. - $this->assertText(phpversion()); + $this->assertSession()->pageTextContains(phpversion()); if (function_exists('phpinfo')) { $this->assertSession()->linkByHrefExists(Url::fromRoute('system.php')->toString()); @@ -69,7 +69,7 @@ public function testStatusPage() { // update_test_postupdate_update_8001() needs to be executed. drupal_set_installed_schema_version('update_test_postupdate', 8000); $this->drupalGet('admin/reports/status'); - $this->assertText('Out of date'); + $this->assertSession()->pageTextContains('Out of date'); // Now cleanup the executed post update functions. drupal_set_installed_schema_version('update_test_postupdate', 8001); @@ -77,7 +77,7 @@ public function testStatusPage() { $post_update_registry = \Drupal::service('update.post_update_registry'); $post_update_registry->filterOutInvokedUpdatesByModule('update_test_postupdate'); $this->drupalGet('admin/reports/status'); - $this->assertText('Out of date'); + $this->assertSession()->pageTextContains('Out of date'); $this->drupalGet('admin/reports/status/php'); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php index 686e263bc708..2dec1ab4a4c3 100644 --- a/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php +++ b/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php @@ -55,11 +55,11 @@ public function testFileTransferHooks() { $this->drupalGetAuthorizePHP($page_title); $this->assertSession()->titleEquals("$page_title | Drupal"); $this->assertNoText('It appears you have reached this page in error.'); - $this->assertText('To continue, provide your server connection details'); + $this->assertSession()->pageTextContains('To continue, provide your server connection details'); // Make sure we see the new connection method added by system_test. $this->assertRaw('System Test FileTransfer'); // Make sure the settings form callback works. - $this->assertText('System Test Username'); + $this->assertSession()->pageTextContains('System Test Username'); // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets as // expected to the first page of the authorize.php script. $this->assertRaw('core/misc/states.js'); diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php index c679e54364c5..89012faf4592 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -177,7 +177,7 @@ public function testThemeSettings() { 'logo_path' => $path, ]; $this->submitForm($edit, 'Save configuration'); - $this->assertText('The custom logo path is invalid.'); + $this->assertSession()->pageTextContains('The custom logo path is invalid.'); } // Upload a file to use for the logo. @@ -383,15 +383,15 @@ public function testInvalidTheme() { // Clear the system_list() and theme listing cache to pick up the change. $this->container->get('theme_handler')->reset(); $this->drupalGet('admin/appearance'); - $this->assertText('This theme requires the base theme not_real_test_basetheme to operate correctly.'); - $this->assertText('This theme requires the base theme test_invalid_basetheme to operate correctly.'); - $this->assertText('This theme requires the theme engine not_real_engine to operate correctly.'); + $this->assertSession()->pageTextContains('This theme requires the base theme not_real_test_basetheme to operate correctly.'); + $this->assertSession()->pageTextContains('This theme requires the base theme test_invalid_basetheme to operate correctly.'); + $this->assertSession()->pageTextContains('This theme requires the theme engine not_real_engine to operate correctly.'); // Check for the error text of a theme with the wrong core version // using 7.x and ^7. $incompatible_core_message = 'This theme is not compatible with Drupal ' . \Drupal::VERSION . ". Check that the .info.yml file contains a compatible 'core' or 'core_version_requirement' value."; $this->assertThemeIncompatibleText('Theme test with invalid semver core version', $incompatible_core_message); // Check for the error text of a theme without a content region. - $this->assertText("This theme is missing a 'content' region."); + $this->assertSession()->pageTextContains("This theme is missing a 'content' region."); } /** @@ -466,7 +466,7 @@ public function testInstallAndSetAsDefault() { $this->drupalGet('admin/appearance'); $this->getSession()->getPage()->findLink("Install $theme_name as default theme")->click(); // Test the confirmation message. - $this->assertText("$theme_name is now the default theme."); + $this->assertSession()->pageTextContains("$theme_name is now the default theme."); // Make sure the theme is now set as the default theme in config. $this->assertEquals($theme_machine_name, $this->config('system.theme')->get('default')); @@ -493,7 +493,7 @@ public function testThemeSettingsNoLogoNoFavicon() { $this->drupalGet('admin/appearance/settings/test_theme_settings_features'); $edit = []; $this->drupalPostForm('admin/appearance/settings/test_theme_settings_features', $edit, 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); } /** diff --git a/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php b/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php index f1b814987e32..557556d90f82 100644 --- a/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php +++ b/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php @@ -34,12 +34,12 @@ public function testTokens() { $this->drupalLogin($account); $this->drupalGet('token-test/' . $node->id()); - $this->assertText("Tokens: {$node->id()} {$account->id()}"); + $this->assertSession()->pageTextContains("Tokens: {$node->id()} {$account->id()}"); $this->assertCacheTags(['node:1', 'rendered', 'user:2']); $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); $this->drupalGet('token-test-without-bubbleable-metadata/' . $node->id()); - $this->assertText("Tokens: {$node->id()} {$account->id()}"); + $this->assertSession()->pageTextContains("Tokens: {$node->id()} {$account->id()}"); $this->assertCacheTags(['node:1', 'rendered', 'user:2']); $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); } diff --git a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php index f96df6541342..db0cb122cf72 100644 --- a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php +++ b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php @@ -77,7 +77,7 @@ public function testFakeRequests() { $this->writeSettings($settings); $this->drupalGet('trusted-hosts-test/fake-request'); - $this->assertText('Host: ' . $host); + $this->assertSession()->pageTextContains('Host: ' . $host); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php index 719c09a8abf5..7a227da1ddb2 100644 --- a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php @@ -36,7 +36,7 @@ public function testTemplateOverride() { ->set('default', 'test_theme_nyan_cat_engine') ->save(); $this->drupalGet('theme-test/template-test'); - $this->assertText('Success: Template overridden with Nyan Cat theme. All of them'); + $this->assertSession()->pageTextContains('Success: Template overridden with Nyan Cat theme. All of them'); } } diff --git a/core/modules/system/tests/src/Functional/Theme/ExperimentalThemeTest.php b/core/modules/system/tests/src/Functional/Theme/ExperimentalThemeTest.php index 160c4a0925f3..7cd097684daf 100644 --- a/core/modules/system/tests/src/Functional/Theme/ExperimentalThemeTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ExperimentalThemeTest.php @@ -41,14 +41,14 @@ protected function setUp(): void { public function testExperimentalConfirmForm() { // Only experimental themes should be marked as such with a parenthetical. $this->drupalGet('admin/appearance'); - $this->assertText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); - $this->assertText(sprintf('Experimental dependency test %s', \Drupal::VERSION)); + $this->assertSession()->responseContains(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); + $this->assertSession()->responseContains(sprintf('Experimental dependency test %s', \Drupal::VERSION)); // First, test installing a non-experimental theme with no dependencies. // There should be no confirmation form and no experimental theme warning. $this->drupalGet('admin/appearance'); $this->cssSelect('a[title="Install <strong>Test theme</strong> theme"]')[0]->click(); - $this->assertText('The <strong>Test theme</strong> theme has been installed.'); + $this->assertSession()->pageTextContains('The <strong>Test theme</strong> theme has been installed.'); $this->assertNoText('Experimental modules are provided for testing purposes only.'); // Next, test installing an experimental theme with no dependencies. @@ -56,26 +56,26 @@ public function testExperimentalConfirmForm() { // list of dependencies. $this->drupalGet('admin/appearance'); $this->cssSelect('a[title="Install Experimental test theme"]')[0]->click(); - $this->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.'); + $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only. Use at your own risk.'); // The module should not be enabled and there should be a warning and a // list of the experimental modules with only this one. $this->assertNoText('The Experimental Test theme has been installed.'); - $this->assertText('Experimental themes are provided for testing purposes only.'); + $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only.'); // There should be no message about enabling dependencies. $this->assertNoText('You must enable'); // Enable the theme and confirm that it worked. $this->submitForm([], 'Continue'); - $this->assertText('The Experimental test theme has been installed.'); + $this->assertSession()->pageTextContains('The Experimental test theme has been installed.'); // Setting it as the default should not ask for another confirmation. $this->cssSelect('a[title="Set Experimental test as default theme"]')[0]->click(); $this->assertNoText('Experimental themes are provided for testing purposes only. Use at your own risk.'); - $this->assertText('Experimental test is now the default theme.'); + $this->assertSession()->pageTextContains('Experimental test is now the default theme.'); $this->assertNoText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); - $this->assertText(sprintf('Experimental test %s (default theme, administration theme, experimental theme)', \Drupal::VERSION)); + $this->assertSession()->responseContains(sprintf('Experimental test %s (default theme, administration theme, experimental theme)', \Drupal::VERSION)); // Uninstall the theme. $this->config('system.theme')->set('default', 'test_theme')->save(); @@ -87,7 +87,7 @@ public function testExperimentalConfirmForm() { // experimental warning. $this->drupalGet('admin/appearance'); $this->cssSelect('a[title="Install Experimental test as default theme"]')[0]->click(); - $this->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.'); + $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only. Use at your own risk.'); // Test enabling a theme that is not itself experimental, but that depends // on an experimental module. @@ -97,28 +97,28 @@ public function testExperimentalConfirmForm() { // The theme should not be enabled and there should be a warning and a // list of the experimental modules with only this one. $this->assertNoText('The Experimental dependency test theme has been installed.'); - $this->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.'); - $this->assertText('The following themes are experimental: Experimental test'); + $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only. Use at your own risk.'); + $this->assertSession()->pageTextContains('The following themes are experimental: Experimental test'); // Ensure the non-experimental theme is not listed as experimental. $this->assertNoText('The following themes are experimental: Experimental test, Experimental dependency test'); $this->assertNoText('The following themes are experimental: Experimental dependency test'); // There should be a message about enabling dependencies. - $this->assertText('You must enable the Experimental test theme to install Experimental dependency test'); + $this->assertSession()->pageTextContains('You must enable the Experimental test theme to install Experimental dependency test'); // Enable the theme and confirm that it worked. $this->submitForm([], 'Continue'); - $this->assertText('The Experimental dependency test theme has been installed.'); - $this->assertText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); - $this->assertText(sprintf('Experimental dependency test %s', \Drupal::VERSION)); + $this->assertSession()->pageTextContains('The Experimental dependency test theme has been installed.'); + $this->assertSession()->responseContains(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); + $this->assertSession()->responseContains(sprintf('Experimental dependency test %s', \Drupal::VERSION)); // Setting it as the default should not ask for another confirmation. $this->cssSelect('a[title="Set Experimental dependency test as default theme"]')[0]->click(); $this->assertNoText('Experimental themes are provided for testing purposes only. Use at your own risk.'); - $this->assertText('Experimental dependency test is now the default theme.'); - $this->assertText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); - $this->assertText(sprintf('Experimental dependency test %s (default theme, administration theme)', \Drupal::VERSION)); + $this->assertSession()->pageTextContains('Experimental dependency test is now the default theme.'); + $this->assertSession()->responseContains(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION)); + $this->assertSession()->responseContains(sprintf('Experimental dependency test %s (default theme, administration theme)', \Drupal::VERSION)); // Uninstall the theme. $this->config('system.theme')->set('default', 'test_theme')->save(); @@ -130,7 +130,7 @@ public function testExperimentalConfirmForm() { // experimental warning for its dependency. $this->drupalGet('admin/appearance'); $this->cssSelect('a[title="Install Experimental dependency test as default theme"]')[0]->click(); - $this->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.'); + $this->assertSession()->pageTextContains('Experimental themes are provided for testing purposes only. Use at your own risk.'); } } diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeLegacyTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeLegacyTest.php index 7de359c95b80..f7323059de16 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeLegacyTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeLegacyTest.php @@ -36,7 +36,7 @@ protected function setUp(): void { */ public function testFunctionOverride() { $this->drupalGet('theme-test/function-template-overridden'); - $this->assertText('Success: Template overrides theme function.', 'Theme function overridden by test_theme template.'); + $this->assertSession()->pageTextContains('Success: Template overrides theme function.', 'Theme function overridden by test_theme template.'); } /** @@ -44,21 +44,21 @@ public function testFunctionOverride() { */ public function testThemeFunctionSuggestionsAlter() { $this->drupalGet('theme-test/function-suggestion-alter'); - $this->assertText('Original theme function.'); + $this->assertSession()->pageTextContains('Original theme function.'); // Install test_theme and test that themes can alter theme suggestions. $this->config('system.theme') ->set('default', 'test_legacy_theme') ->save(); $this->drupalGet('theme-test/function-suggestion-alter'); - $this->assertText('Theme function overridden based on new theme suggestion provided by the test_legacy_theme theme.'); + $this->assertSession()->pageTextContains('Theme function overridden based on new theme suggestion provided by the test_legacy_theme theme.'); // Enable the theme_suggestions_test module to test modules implementing // suggestions alter hooks. \Drupal::service('module_installer')->install(['theme_legacy_suggestions_test']); $this->resetAll(); $this->drupalGet('theme-test/function-suggestion-alter'); - $this->assertText('Theme function overridden based on new theme suggestion provided by a module.'); + $this->assertSession()->pageTextContains('Theme function overridden based on new theme suggestion provided by a module.'); } /** @@ -67,7 +67,7 @@ public function testThemeFunctionSuggestionsAlter() { public function testSuggestionsAlterInclude() { // Check the original theme output. $this->drupalGet('theme-test/suggestion-alter-include'); - $this->assertText('Original function before altering theme suggestions.'); + $this->assertSession()->pageTextContains('Original function before altering theme suggestions.'); // Enable theme_suggestions_test module and make two requests to make sure // the include file is always loaded. The file will always be included for @@ -75,9 +75,9 @@ public function testSuggestionsAlterInclude() { \Drupal::service('module_installer')->install(['theme_legacy_suggestions_test']); $this->resetAll(); $this->drupalGet('theme-test/suggestion-alter-include'); - $this->assertText('Function suggested via suggestion alter hook found in include file.', 'Include file loaded for initial request.'); + $this->assertSession()->pageTextContains('Function suggested via suggestion alter hook found in include file.', 'Include file loaded for initial request.'); $this->drupalGet('theme-test/suggestion-alter-include'); - $this->assertText('Function suggested via suggestion alter hook found in include file.', 'Include file loaded for second request.'); + $this->assertSession()->pageTextContains('Function suggested via suggestion alter hook found in include file.', 'Include file loaded for second request.'); } } diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php index 7512d082a4ab..4188e29633d4 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php @@ -34,7 +34,7 @@ protected function setUp(): void { */ public function testTemplateSuggestions() { $this->drupalGet('theme-test/suggestion-provided'); - $this->assertText('Template for testing suggestions provided by the module declaring the theme hook.'); + $this->assertSession()->pageTextContains('Template for testing suggestions provided by the module declaring the theme hook.'); // Install test_theme, it contains a template suggested by theme_test.module // in theme_test_theme_suggestions_theme_test_suggestion_provided(). @@ -43,7 +43,7 @@ public function testTemplateSuggestions() { ->save(); $this->drupalGet('theme-test/suggestion-provided'); - $this->assertText('Template overridden based on suggestion provided by the module declaring the theme hook.'); + $this->assertSession()->pageTextContains('Template overridden based on suggestion provided by the module declaring the theme hook.'); } /** @@ -51,21 +51,21 @@ public function testTemplateSuggestions() { */ public function testGeneralSuggestionsAlter() { $this->drupalGet('theme-test/general-suggestion-alter'); - $this->assertText('Original template for testing hook_theme_suggestions_alter().'); + $this->assertSession()->pageTextContains('Original template for testing hook_theme_suggestions_alter().'); // Install test_theme and test that themes can alter template suggestions. $this->config('system.theme') ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/general-suggestion-alter'); - $this->assertText('Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_alter().'); + $this->assertSession()->pageTextContains('Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_alter().'); // Enable the theme_suggestions_test module to test modules implementing // suggestions alter hooks. \Drupal::service('module_installer')->install(['theme_suggestions_test']); $this->resetAll(); $this->drupalGet('theme-test/general-suggestion-alter'); - $this->assertText('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_alter().'); + $this->assertSession()->pageTextContains('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_alter().'); } /** @@ -73,21 +73,21 @@ public function testGeneralSuggestionsAlter() { */ public function testTemplateSuggestionsAlter() { $this->drupalGet('theme-test/suggestion-alter'); - $this->assertText('Original template for testing hook_theme_suggestions_HOOK_alter().'); + $this->assertSession()->pageTextContains('Original template for testing hook_theme_suggestions_HOOK_alter().'); // Install test_theme and test that themes can alter template suggestions. $this->config('system.theme') ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/suggestion-alter'); - $this->assertText('Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_HOOK_alter().'); + $this->assertSession()->pageTextContains('Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_HOOK_alter().'); // Enable the theme_suggestions_test module to test modules implementing // suggestions alter hooks. \Drupal::service('module_installer')->install(['theme_suggestions_test']); $this->resetAll(); $this->drupalGet('theme-test/suggestion-alter'); - $this->assertText('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_HOOK_alter().'); + $this->assertSession()->pageTextContains('Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_HOOK_alter().'); } /** @@ -96,7 +96,7 @@ public function testTemplateSuggestionsAlter() { public function testSpecificSuggestionsAlter() { // Test that the default template is rendered. $this->drupalGet('theme-test/specific-suggestion-alter'); - $this->assertText('Template for testing specific theme calls.'); + $this->assertSession()->pageTextContains('Template for testing specific theme calls.'); $this->config('system.theme') ->set('default', 'test_theme') @@ -104,14 +104,14 @@ public function testSpecificSuggestionsAlter() { // Test a specific theme call similar to '#theme' => 'node__article'. $this->drupalGet('theme-test/specific-suggestion-alter'); - $this->assertText('Template matching the specific theme call.'); - $this->assertText('theme_test_specific_suggestions__variant'); + $this->assertSession()->pageTextContains('Template matching the specific theme call.'); + $this->assertSession()->pageTextContains('theme_test_specific_suggestions__variant'); // Ensure that the base hook is used to determine the suggestion alter hook. \Drupal::service('module_installer')->install(['theme_suggestions_test']); $this->resetAll(); $this->drupalGet('theme-test/specific-suggestion-alter'); - $this->assertText('Template overridden based on suggestion alter hook determined by the base hook.'); + $this->assertSession()->pageTextContains('Template overridden based on suggestion alter hook determined by the base hook.'); $raw_content = $this->getSession()->getPage()->getContent(); // Verify that a specific theme call is added to the suggestions array // before the suggestions alter hook. diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeTest.php index 24fb10843593..66e07ef12e5a 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeTest.php @@ -45,7 +45,7 @@ public function testPreprocessForSuggestions() { drupal_theme_rebuild(); for ($i = 0; $i < 2; $i++) { $this->drupalGet('theme-test/suggestion'); - $this->assertText('Theme hook implementor=theme-test--suggestion.html.twig. Foo=template_preprocess_theme_test'); + $this->assertSession()->pageTextContains('Theme hook implementor=theme-test--suggestion.html.twig. Foo=template_preprocess_theme_test'); } } @@ -96,7 +96,7 @@ public function testClassLoading() { $this->resetAll(); // Visit page controller and confirm that the theme class is loaded. $this->drupalGet('/theme-test/test-theme-class'); - $this->assertText('Loading ThemeClass was successful.'); + $this->assertSession()->pageTextContains('Loading ThemeClass was successful.'); } /** @@ -138,7 +138,7 @@ public function testTemplateOverride() { ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/template-test'); - $this->assertText('Success: Template overridden.'); + $this->assertSession()->pageTextContains('Success: Template overridden.'); } /** @@ -151,7 +151,7 @@ public function testPreprocessHtml() { $this->drupalGet(''); $attributes = $this->xpath('/body[@theme_test_page_variable="Page variable is an array."]'); $this->assertCount(1, $attributes, 'In template_preprocess_html(), the page variable is still an array (not rendered yet).'); - $this->assertText('theme test page bottom markup'); + $this->assertSession()->pageTextContains('theme test page bottom markup'); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php index 3968f69c2fc2..346c61c5ff6f 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php @@ -357,7 +357,7 @@ public function testInstalledIncompatibleTheme() { $incompatible_info = $info + $incompatible_update; file_put_contents($file_path, Yaml::encode($incompatible_info)); $this->drupalGet('admin/appearance'); - $this->assertText($incompatible_themes_message); + $this->assertSession()->pageTextContains($incompatible_themes_message); file_put_contents($file_path, Yaml::encode($compatible_info)); $this->drupalGet('admin/appearance'); diff --git a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php index 94e7df388a63..f55db4c9c7e0 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php @@ -47,7 +47,7 @@ public function testTwigExtensionFilter() { ->save(); $this->drupalGet('twig-extension-test/filter'); - $this->assertText('Every plant is not a mineral.'); + $this->assertSession()->pageTextContains('Every plant is not a mineral.'); // Test safe_join filter. $this->assertRaw('<em>will be escaped</em><br/><em>will be markup</em><br/><strong>will be rendered</strong>'); } @@ -61,8 +61,8 @@ public function testTwigExtensionFunction() { ->save(); $this->drupalGet('twig-extension-test/function'); - $this->assertText('THE QUICK BROWN BOX JUMPS OVER THE LAZY DOG 123.'); - $this->assertText('the quick brown box jumps over the lazy dog 123.'); + $this->assertSession()->pageTextContains('THE QUICK BROWN BOX JUMPS OVER THE LAZY DOG 123.'); + $this->assertSession()->pageTextContains('the quick brown box jumps over the lazy dog 123.'); $this->assertNoText('The Quick Brown Fox Jumps Over The Lazy Dog 123.'); } diff --git a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php index 1ce4160073d2..e123f7e05153 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php @@ -55,8 +55,8 @@ public function testTemplateDiscovery() { public function testTwigNamespaces() { // Test the module-provided extend and insert templates. $this->drupalGet('twig-theme-test/registry-loader'); - $this->assertText('This line is from twig_theme_test/templates/twig-registry-loader-test-extend.html.twig'); - $this->assertText('This line is from twig_theme_test/templates/twig-registry-loader-test-include.html.twig'); + $this->assertSession()->pageTextContains('This line is from twig_theme_test/templates/twig-registry-loader-test-extend.html.twig'); + $this->assertSession()->pageTextContains('This line is from twig_theme_test/templates/twig-registry-loader-test-include.html.twig'); // Enable a theme that overrides the extend and insert templates to ensure // they are picked up by the registry loader. @@ -64,8 +64,8 @@ public function testTwigNamespaces() { ->set('default', 'test_theme_twig_registry_loader') ->save(); $this->drupalGet('twig-theme-test/registry-loader'); - $this->assertText('This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-extend.html.twig'); - $this->assertText('This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-include.html.twig'); + $this->assertSession()->pageTextContains('This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-extend.html.twig'); + $this->assertSession()->pageTextContains('This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-include.html.twig'); // Enable overriding theme that overrides the extend and insert templates // from the base theme. @@ -73,8 +73,8 @@ public function testTwigNamespaces() { ->set('default', 'test_theme_twig_registry_loader_theme') ->save(); $this->drupalGet('twig-theme-test/registry-loader'); - $this->assertText('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-extend.html.twig'); - $this->assertText('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-include.html.twig'); + $this->assertSession()->pageTextContains('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-extend.html.twig'); + $this->assertSession()->pageTextContains('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-include.html.twig'); // Enable a subtheme for the theme that doesn't have any overrides to make // sure that templates are being loaded from the first parent which has the @@ -83,8 +83,8 @@ public function testTwigNamespaces() { ->set('default', 'test_theme_twig_registry_loader_subtheme') ->save(); $this->drupalGet('twig-theme-test/registry-loader'); - $this->assertText('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-extend.html.twig'); - $this->assertText('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-include.html.twig'); + $this->assertSession()->pageTextContains('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-extend.html.twig'); + $this->assertSession()->pageTextContains('This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-include.html.twig'); } } diff --git a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php index 1efaf9405168..c24bc5703d8d 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php @@ -126,25 +126,25 @@ public function testEmptyTwigTransTags() { */ protected function assertTwigTransTags() { // Assert that {% trans "Hello sun." %} is translated correctly. - $this->assertText('OH HAI SUNZ'); + $this->assertSession()->pageTextContains('OH HAI SUNZ'); // Assert that {% trans "Hello sun." %} with {"context": "Lolspeak"} is // translated correctly. - $this->assertText('O HAI SUNZZZZZZZ'); + $this->assertSession()->pageTextContains('O HAI SUNZZZZZZZ'); // Assert that {{ "Hello Earth."|trans }} is translated correctly. - $this->assertText('O HERRO ERRRF.'); + $this->assertSession()->pageTextContains('O HERRO ERRRF.'); // Assert that {% trans %}Hello moon.{% endtrans %} is translated correctly. - $this->assertText('OH HAI TEH MUUN'); + $this->assertSession()->pageTextContains('OH HAI TEH MUUN'); // Assert that {% trans %} with {% plural count = 1 %} is translated // correctly. - $this->assertText('O HAI STARRRRR'); + $this->assertSession()->pageTextContains('O HAI STARRRRR'); // Assert that {% trans %} with {% plural count = 2 %} is translated // correctly. - $this->assertText('O HAI 2 STARZZZZ'); + $this->assertSession()->pageTextContains('O HAI 2 STARZZZZ'); // Assert that {{ token }} was successfully translated and prefixed // with "@". @@ -160,19 +160,19 @@ protected function assertTwigTransTags() { // Assert that {% trans %} with a context only msgid is excluded from // translation. - $this->assertText('I have context.'); + $this->assertSession()->pageTextContains('I have context.'); // Assert that {% trans with {"context": "Lolspeak"} %} was successfully // translated with context. - $this->assertText('I HAZ KONTEX.'); + $this->assertSession()->pageTextContains('I HAZ KONTEX.'); // Assert that {% trans with {"langcode": "zz"} %} is successfully // translated in specified language. - $this->assertText('O HAI NU TXT.'); + $this->assertSession()->pageTextContains('O HAI NU TXT.'); // Assert that {% trans with {"context": "Lolspeak", "langcode": "zz"} %} // is successfully translated with context in specified language. - $this->assertText('O HAI NU TXTZZZZ.'); + $this->assertSession()->pageTextContains('O HAI NU TXTZZZZ.'); // Makes sure https://www.drupal.org/node/2489024 doesn't happen without // twig debug. diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php index f3ac0ee5b06f..e9964b9397c9 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/InvalidUpdateHookTest.php @@ -61,7 +61,7 @@ public function testInvalidUpdateHook() { $this->drupalGet($this->updateUrl); $this->updateRequirementsProblem(); $this->clickLink(t('Continue')); - $this->assertText('Some of the pending updates cannot be applied because their dependencies were not met.'); + $this->assertSession()->pageTextContains('Some of the pending updates cannot be applied because their dependencies were not met.'); } } diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php index 9a52a8273c0a..0f87ff0cccb3 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php @@ -57,7 +57,7 @@ public function testUpdatedSite() { // Assert that nodes are all published. $this->assertTrue($node->isPublished()); $this->drupalGet('node/' . $id); - $this->assertText($title); + $this->assertSession()->pageTextContains($title); } // Make sure the translated node still exists. @@ -66,33 +66,33 @@ public function testUpdatedSite() { // Make sure our alias still works. $this->drupalGet('test-article'); - $this->assertText('Test Article - New title'); - $this->assertText('Body'); - $this->assertText('Tags'); + $this->assertSession()->pageTextContains('Test Article - New title'); + $this->assertSession()->pageTextContains('Body'); + $this->assertSession()->pageTextContains('Tags'); // Make sure a translated page exists. $this->drupalGet('node/8', ['language' => $spanish]); // Check for text of two comments. - $this->assertText('Hola'); - $this->assertText('Hello'); + $this->assertSession()->pageTextContains('Hola'); + $this->assertSession()->pageTextContains('Hello'); // The user entity reference field is access restricted. $this->assertNoText('Test 12'); // Make sure all other field labels are there. for ($i = 1; $i <= 23; $i++) { if ($i != 12) { - $this->assertText('Test ' . $i); + $this->assertSession()->pageTextContains('Test ' . $i); } } // Make sure the translated slogan appears. - $this->assertText('drupal Spanish'); + $this->assertSession()->pageTextContains('drupal Spanish'); // Make sure the custom block appears. $this->drupalGet('<front>'); // Block title. - $this->assertText('Another block'); + $this->assertSession()->pageTextContains('Another block'); // Block body. - $this->assertText('Hello'); + $this->assertSession()->pageTextContains('Hello'); // Log in as user 1. $account = User::load(1); @@ -102,39 +102,39 @@ public function testUpdatedSite() { // Make sure we can see the access-restricted entity reference field // now that we're logged in. $this->drupalGet('node/8', ['language' => $spanish]); - $this->assertText('Test 12'); + $this->assertSession()->pageTextContains('Test 12'); $this->assertSession()->linkExists('drupal'); // Make sure the content for node 8 is still in the edit form. $this->drupalGet('node/8/edit'); - $this->assertText('Test title'); - $this->assertText('Test body'); + $this->assertSession()->pageTextContains('Test title'); + $this->assertSession()->pageTextContains('Test body'); $this->assertSession()->checkboxChecked('edit-field-test-1-value'); $this->assertRaw('2015-08-16'); $this->assertRaw('test@example.com'); $this->assertRaw('drupal.org'); - $this->assertText('0.1'); - $this->assertText('0.2'); + $this->assertSession()->pageTextContains('0.1'); + $this->assertSession()->pageTextContains('0.2'); $this->assertRaw('+31612345678'); $this->assertRaw('+31612345679'); - $this->assertText('Test Article - New title'); - $this->assertText('test.txt'); - $this->assertText('druplicon.small'); + $this->assertSession()->pageTextContains('Test Article - New title'); + $this->assertSession()->pageTextContains('test.txt'); + $this->assertSession()->pageTextContains('druplicon.small'); $this->assertRaw('General discussion'); - $this->assertText('Test Article - New title'); - $this->assertText('Test 1'); + $this->assertSession()->pageTextContains('Test Article - New title'); + $this->assertSession()->pageTextContains('Test 1'); $this->assertRaw('0.01'); $this->drupalPostForm('node/8/edit', [], 'Save (this translation)'); $this->assertSession()->statusCodeEquals(200); $this->drupalGet('node/8/edit', ['language' => $spanish]); - $this->assertText('Test title Spanish'); - $this->assertText('Test body Spanish'); + $this->assertSession()->pageTextContains('Test title Spanish'); + $this->assertSession()->pageTextContains('Test body Spanish'); // Make sure the user page is correct. $this->drupalGet('user/3'); - $this->assertText('usuario_test'); + $this->assertSession()->pageTextContains('usuario_test'); $this->assertRaw('druplicon.small'); - $this->assertText('Test file field'); + $this->assertSession()->pageTextContains('Test file field'); $this->assertSession()->linkExists('test.txt'); // Make sure the user is translated. @@ -143,37 +143,37 @@ public function testUpdatedSite() { // Make sure the custom field on the user is still there. $this->drupalGet('admin/config/people/accounts/fields'); - $this->assertText('Test file field'); + $this->assertSession()->pageTextContains('Test file field'); // Make sure the test view still exists. $this->drupalGet('admin/structure/views/view/test_view'); - $this->assertText('Test view'); + $this->assertSession()->pageTextContains('Test view'); // Make sure the book node exists. $this->drupalGet('admin/structure/book'); $this->clickLink('Test Article - New title'); - $this->assertText('Body'); - $this->assertText('Tags'); + $this->assertSession()->pageTextContains('Body'); + $this->assertSession()->pageTextContains('Tags'); $this->assertRaw('Text format'); // Make sure that users still exist. $this->drupalGet('admin/people'); - $this->assertText('usuario_test'); - $this->assertText('drupal'); + $this->assertSession()->pageTextContains('usuario_test'); + $this->assertSession()->pageTextContains('drupal'); $this->drupalGet('user/1/edit'); $this->assertRaw('drupal@example.com'); // Make sure the content view works. $this->drupalGet('admin/content'); - $this->assertText('Test title'); + $this->assertSession()->pageTextContains('Test title'); // Make sure our custom blocks show up. $this->drupalGet('admin/structure/block'); - $this->assertText('Another block'); - $this->assertText('Test block'); + $this->assertSession()->pageTextContains('Another block'); + $this->assertSession()->pageTextContains('Test block'); $this->drupalGet('admin/structure/block/block-content'); - $this->assertText('Another block'); - $this->assertText('Test block'); + $this->assertSession()->pageTextContains('Another block'); + $this->assertSession()->pageTextContains('Test block'); // Make sure our custom visibility conditions are correct. $this->drupalGet('admin/structure/block/manage/testblock'); @@ -188,28 +188,28 @@ public function testUpdatedSite() { // Make sure our custom text format exists. $this->drupalGet('admin/config/content/formats'); - $this->assertText('Test text format'); + $this->assertSession()->pageTextContains('Test text format'); $this->drupalGet('admin/config/content/formats/manage/test_text_format'); $this->assertSession()->statusCodeEquals(200); // Make sure our feed still exists. $this->drupalGet('admin/config/services/aggregator'); - $this->assertText('Test feed'); + $this->assertSession()->pageTextContains('Test feed'); $this->drupalGet('admin/config/services/aggregator/fields'); - $this->assertText('field_test'); + $this->assertSession()->pageTextContains('field_test'); // Make sure our view appears in the overview. $this->drupalGet('admin/structure/views'); - $this->assertText('test_view'); - $this->assertText('Test view'); + $this->assertSession()->pageTextContains('test_view'); + $this->assertSession()->pageTextContains('Test view'); // Make sure our custom forum exists. $this->drupalGet('admin/structure/forum'); - $this->assertText('Test forum'); + $this->assertSession()->pageTextContains('Test forum'); // Make sure our custom menu exists. $this->drupalGet('admin/structure/menu'); - $this->assertText('Test menu'); + $this->assertSession()->pageTextContains('Test menu'); // Make sure our custom menu exists. $this->drupalGet('admin/structure/menu/manage/test-menu'); @@ -223,15 +223,15 @@ public function testUpdatedSite() { // Make sure our comment type exists. $this->drupalGet('admin/structure/comment'); - $this->assertText('Test comment type'); + $this->assertSession()->pageTextContains('Test comment type'); $this->drupalGet('admin/structure/comment/manage/test_comment_type/fields'); - $this->assertText('comment_body'); + $this->assertSession()->pageTextContains('comment_body'); // Make sure our contact form exists. $this->drupalGet('admin/structure/contact'); - $this->assertText('Test contact form'); + $this->assertSession()->pageTextContains('Test contact form'); $this->drupalGet('admin/structure/types'); - $this->assertText('Test content type description'); + $this->assertSession()->pageTextContains('Test content type description'); $this->drupalGet('admin/structure/types/manage/test_content_type/fields'); // Make sure fields are the right type. @@ -256,40 +256,40 @@ public function testUpdatedSite() { // Make sure our form mode exists. $this->drupalGet('admin/structure/display-modes/form'); - $this->assertText('New form mode'); + $this->assertSession()->pageTextContains('New form mode'); // Make sure our view mode exists. $this->drupalGet('admin/structure/display-modes/view'); - $this->assertText('New view mode'); + $this->assertSession()->pageTextContains('New view mode'); $this->drupalGet('admin/structure/display-modes/view/manage/node.new_view_mode'); $this->assertSession()->statusCodeEquals(200); // Make sure our other language is still there. $this->drupalGet('admin/config/regional/language'); - $this->assertText('Spanish'); + $this->assertSession()->pageTextContains('Spanish'); // Make sure our custom date format exists. $this->drupalGet('admin/config/regional/date-time'); - $this->assertText('Test date format'); + $this->assertSession()->pageTextContains('Test date format'); $this->drupalGet('admin/config/regional/date-time/formats/manage/test_date_format'); $this->assertTrue($this->assertSession()->optionExists('edit-langcode', 'es')->isSelected()); // Make sure our custom image style exists. $this->drupalGet('admin/config/media/image-styles/manage/test_image_style'); - $this->assertText('Test image style'); - $this->assertText('Desaturate'); - $this->assertText('Convert PNG'); + $this->assertSession()->pageTextContains('Test image style'); + $this->assertSession()->pageTextContains('Desaturate'); + $this->assertSession()->pageTextContains('Convert PNG'); // Make sure our custom responsive image style exists. $this->drupalGet('admin/config/media/responsive-image-style/test'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('Test'); + $this->assertSession()->pageTextContains('Test'); // Make sure our custom shortcut exists. $this->drupalGet('admin/config/user-interface/shortcut'); - $this->assertText('Test shortcut'); + $this->assertSession()->pageTextContains('Test shortcut'); $this->drupalGet('admin/config/user-interface/shortcut/manage/test/customize'); - $this->assertText('All content'); + $this->assertSession()->pageTextContains('All content'); // Make sure our language detection settings are still correct. $this->drupalGet('admin/config/regional/language/detection'); @@ -302,28 +302,28 @@ public function testUpdatedSite() { // Make sure strings are still translated. $this->drupalGet('admin/structure/views/view/content/translate/es/edit'); // cSpell:disable-next-line - $this->assertText('Contenido'); + $this->assertSession()->pageTextContains('Contenido'); $this->drupalPostForm('admin/config/regional/translate', ['string' => 'Full comment'], 'Filter'); // cSpell:disable-next-line - $this->assertText('Comentario completo'); + $this->assertSession()->pageTextContains('Comentario completo'); // Make sure our custom action is still there. $this->drupalGet('admin/config/system/actions'); - $this->assertText('Test action'); + $this->assertSession()->pageTextContains('Test action'); $this->drupalGet('admin/config/system/actions/configure/test_action'); - $this->assertText('test_action'); + $this->assertSession()->pageTextContains('test_action'); $this->assertRaw('drupal.org'); // Make sure our ban still exists. $this->drupalGet('admin/config/people/ban'); - $this->assertText('8.8.8.8'); + $this->assertSession()->pageTextContains('8.8.8.8'); // Make sure our vocabulary exists. $this->drupalGet('admin/structure/taxonomy/manage/test_vocabulary/overview'); // Make sure our terms exist. - $this->assertText('Test root term'); - $this->assertText('Test child term'); + $this->assertSession()->pageTextContains('Test root term'); + $this->assertSession()->pageTextContains('Test child term'); $this->drupalGet('taxonomy/term/3'); $this->assertSession()->statusCodeEquals(200); @@ -333,12 +333,12 @@ public function testUpdatedSite() { // Make sure our contact form exists. $this->drupalGet('admin/structure/contact'); - $this->assertText('Test contact form'); + $this->assertSession()->pageTextContains('Test contact form'); $this->drupalGet('admin/structure/contact/manage/test_contact_form'); - $this->assertText('test@example.com'); - $this->assertText('Hello'); + $this->assertSession()->pageTextContains('test@example.com'); + $this->assertSession()->pageTextContains('Hello'); $this->drupalGet('admin/structure/contact/manage/test_contact_form/translate/es/edit'); - $this->assertText('Hola'); + $this->assertSession()->pageTextContains('Hola'); $this->assertRaw('Test contact form Spanish'); // Make sure our modules are still enabled. diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php index 8c190d46a7e0..bebc7247a7a2 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePostUpdateTest.php @@ -124,7 +124,7 @@ public function testPostUpdate() { $this->drupalGet('update.php/selection'); $this->updateRequirementsProblem(); $this->drupalGet('update.php/selection'); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); } } diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php index f6076fc83e27..1e74055893cc 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -130,9 +130,9 @@ public function testRequirements() { $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->updateRequirementsProblem(); $this->clickLink(t('Continue')); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); // Confirm that all caches were cleared. - $this->assertText('hook_cache_flush() invoked for update_script_test.module.'); + $this->assertSession()->pageTextContains('hook_cache_flush() invoked for update_script_test.module.'); // If there is a requirements warning, we expect it to be initially // displayed, but clicking the link to proceed should allow us to go @@ -144,34 +144,34 @@ public function testRequirements() { $update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save(); drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertText('This is a requirements warning provided by the update_script_test module.'); + $this->assertSession()->pageTextContains('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertNoText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink(t('Continue')); $this->clickLink(t('Apply pending updates')); $this->checkForMetaRefresh(); - $this->assertText('The update_script_test_update_8001() update was executed successfully.'); + $this->assertSession()->pageTextContains('The update_script_test_update_8001() update was executed successfully.'); // Confirm that all caches were cleared. - $this->assertText('hook_cache_flush() invoked for update_script_test.module.'); + $this->assertSession()->pageTextContains('hook_cache_flush() invoked for update_script_test.module.'); // Now try again without pending updates to make sure that works too. $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertText('This is a requirements warning provided by the update_script_test module.'); + $this->assertSession()->pageTextContains('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertNoText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink(t('Continue')); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); // Confirm that all caches were cleared. - $this->assertText('hook_cache_flush() invoked for update_script_test.module.'); + $this->assertSession()->pageTextContains('hook_cache_flush() invoked for update_script_test.module.'); // If there is a requirements error, it should be displayed even after // clicking the link to proceed (since the problem that triggered the error // has not been fixed). $update_script_test_config->set('requirement_type', REQUIREMENT_ERROR)->save(); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertText('This is a requirements error provided by the update_script_test module.'); + $this->assertSession()->pageTextContains('This is a requirements error provided by the update_script_test module.'); $this->clickLink('try again'); - $this->assertText('This is a requirements error provided by the update_script_test module.'); + $this->assertSession()->pageTextContains('This is a requirements error provided by the update_script_test module.'); // Ensure that changes to a module's requirements that would cause errors // are displayed correctly. @@ -504,7 +504,7 @@ public function testNoUpdateFunctionality() { $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->updateRequirementsProblem(); $this->clickLink(t('Continue')); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); $this->assertSession()->linkNotExists('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); $this->clickLink('Front page'); @@ -519,7 +519,7 @@ public function testNoUpdateFunctionality() { $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->updateRequirementsProblem(); $this->clickLink(t('Continue')); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); $this->assertSession()->linkExists('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); $this->clickLink('Administration pages'); @@ -559,7 +559,7 @@ public function testSuccessfulUpdateFunctionality() { $this->clickLink(t('Continue')); $this->clickLink(t('Apply pending updates')); $this->checkForMetaRefresh(); - $this->assertText('Updates were attempted.'); + $this->assertSession()->pageTextContains('Updates were attempted.'); $this->assertSession()->linkExists('logged'); $this->assertSession()->linkExists('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); @@ -633,7 +633,7 @@ public function testSuccessfulMultilingualUpdateFunctionality() { $this->clickLink(t('Continue')); $this->clickLink(t('Apply pending updates')); $this->checkForMetaRefresh(); - $this->assertText('Updates were attempted.'); + $this->assertSession()->pageTextContains('Updates were attempted.'); $this->assertSession()->linkExists('logged'); $this->assertSession()->linkExists('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); @@ -682,7 +682,7 @@ protected function runUpdates($maintenance_mode) { // Click through update.php with 'administer software updates' permission. $this->drupalLogin($this->updateUser); if ($maintenance_mode) { - $this->assertText('Operating in maintenance mode.'); + $this->assertSession()->pageTextContains('Operating in maintenance mode.'); } else { $this->assertNoText('Operating in maintenance mode.'); @@ -694,9 +694,9 @@ protected function runUpdates($maintenance_mode) { $this->checkForMetaRefresh(); // Verify that updates were completed successfully. - $this->assertText('Updates were attempted.'); + $this->assertSession()->pageTextContains('Updates were attempted.'); $this->assertSession()->linkExists('site'); - $this->assertText('The update_script_test_update_8001() update was executed successfully.'); + $this->assertSession()->pageTextContains('The update_script_test_update_8001() update was executed successfully.'); // Verify that no 7.x updates were run. $this->assertNoText('The update_script_test_update_7200() update was executed successfully.'); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php index 77e323470dca..513bbfb7cbcb 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php @@ -62,7 +62,7 @@ public function testWith7x() { $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->updateRequirementsProblem(); $this->clickLink(t('Continue')); - $this->assertText('Some of the pending updates cannot be applied because their dependencies were not met.'); + $this->assertSession()->pageTextContains('Some of the pending updates cannot be applied because their dependencies were not met.'); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php index 3c88b5ef6100..68a2a14d6b28 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php @@ -96,7 +96,7 @@ public function testTaxonomyImageAccess() { $this->submitForm(['field_test[0][alt]' => $this->randomMachineName()], 'Save'); $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['name' => $edit['name[0][value]']]); $term = reset($terms); - $this->assertText('Created new term ' . $term->getName() . '.'); + $this->assertSession()->pageTextContains('Created new term ' . $term->getName() . '.'); // Create a user that should have access to the file and one that doesn't. $access_user = $this->drupalCreateUser(['access content']); diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/tests/src/Functional/TermTest.php index 2aeb016bd865..7bb083173ed3 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTest.php @@ -161,16 +161,16 @@ public function testTaxonomyTermChildTerms() { // Get Page 1. Parent term and terms 1-13 are displayed. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); - $this->assertText($term1->getName()); + $this->assertSession()->pageTextContains($term1->getName()); for ($x = 1; $x <= 13; $x++) { - $this->assertText($terms_array[$x]->getName()); + $this->assertSession()->pageTextContains($terms_array[$x]->getName()); } // Get Page 2. Parent term and terms 1-18 are displayed. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]); - $this->assertText($term1->getName()); + $this->assertSession()->pageTextContains($term1->getName()); for ($x = 1; $x <= 18; $x++) { - $this->assertText($terms_array[$x]->getName()); + $this->assertSession()->pageTextContains($terms_array[$x]->getName()); } // Get Page 3. No parent term and no terms <18 are displayed. Terms 18-25 @@ -181,7 +181,7 @@ public function testTaxonomyTermChildTerms() { $this->assertNoText($terms_array[$x]->getName()); } for ($x = 18; $x <= 25; $x++) { - $this->assertText($terms_array[$x]->getName()); + $this->assertSession()->pageTextContains($terms_array[$x]->getName()); } } @@ -205,19 +205,19 @@ public function testTaxonomyNode() { // Check that the term is displayed when the node is viewed. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->drupalGet('node/' . $node->id()); - $this->assertText($term1->getName()); + $this->assertSession()->pageTextContains($term1->getName()); $this->clickLink(t('Edit')); - $this->assertText($term1->getName()); + $this->assertSession()->pageTextContains($term1->getName()); $this->submitForm([], 'Save'); - $this->assertText($term1->getName()); + $this->assertSession()->pageTextContains($term1->getName()); // Edit the node with a different term. $edit[$this->field->getName() . '[]'] = $term2->id(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); $this->drupalGet('node/' . $node->id()); - $this->assertText($term2->getName()); + $this->assertSession()->pageTextContains($term2->getName()); // Preview the node. $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Preview'); @@ -267,7 +267,7 @@ public function testNodeTermCreationAndDeletion() { // Preview and verify the terms appear but are not created. $this->submitForm($edit, 'Preview'); foreach ($terms as $term) { - $this->assertText($term); + $this->assertSession()->pageTextContains($term); } $tree = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->loadTree($this->vocabulary->id()); $this->assertTrue(empty($tree), 'The terms are not created on preview.'); @@ -277,13 +277,13 @@ public function testNodeTermCreationAndDeletion() { // Save, creating the terms. $this->drupalPostForm('node/add/article', $edit, 'Save'); - $this->assertText('Article ' . $edit['title[0][value]'] . ' has been created.'); + $this->assertSession()->pageTextContains('Article ' . $edit['title[0][value]'] . ' has been created.'); // Verify that the creation message contains a link to a node. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "node/")]'); foreach ($terms as $term) { - $this->assertText($term); + $this->assertSession()->pageTextContains($term); } // Get the created terms. @@ -299,7 +299,7 @@ public function testNodeTermCreationAndDeletion() { // Test editing the node. $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); foreach ($terms as $term) { - $this->assertText($term); + $this->assertSession()->pageTextContains($term); } // Delete term 1 from the term edit page. @@ -316,7 +316,7 @@ public function testNodeTermCreationAndDeletion() { $term_names = [$term_objects['term3']->getName(), $term_objects['term4']->getName()]; $this->drupalGet('node/' . $node->id()); foreach ($term_names as $term_name) { - $this->assertText($term_name); + $this->assertSession()->pageTextContains($term_name); } $this->assertNoText($term_objects['term1']->getName()); $this->assertNoText($term_objects['term2']->getName()); @@ -349,7 +349,7 @@ public function testTermInterface() { // Verify that the randomly generated term is present. $this->assertRaw($edit['name[0][value]']); - $this->assertText($edit['description[0][value]']); + $this->assertSession()->pageTextContains($edit['description[0][value]']); $edit = [ 'name[0][value]' => $this->randomMachineName(14), @@ -361,7 +361,7 @@ public function testTermInterface() { // Check that the term is still present at admin UI after edit. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); - $this->assertText($edit['name[0][value]']); + $this->assertSession()->pageTextContains($edit['name[0][value]']); $this->assertSession()->linkExists('Edit'); // Check the term link can be clicked through to the term page. @@ -370,8 +370,8 @@ public function testTermInterface() { // View the term and check that it is correct. $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertText($edit['name[0][value]']); - $this->assertText($edit['description[0][value]']); + $this->assertSession()->pageTextContains($edit['name[0][value]']); + $this->assertSession()->pageTextContains($edit['description[0][value]']); // Did this page request display a 'term-listing-heading'? $this->assertSession()->elementExists('xpath', '//div[contains(@class, "field--name-description")]'); diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php index 78b3b25ead54..08bce7b6a268 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php @@ -65,9 +65,9 @@ public function testTranslatedTaxonomyTermReferenceDisplay() { $this->drupalGet($path); $this->assertNoText($this->translatedTagName); - $this->assertText($this->baseTagName); + $this->assertSession()->pageTextContains($this->baseTagName); $this->drupalGet($translation_path); - $this->assertText($this->translatedTagName); + $this->assertSession()->pageTextContains($this->translatedTagName); $this->assertNoText($this->baseTagName); } diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php index 5e0127248cdb..e755dabd0ec4 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationTest.php @@ -106,15 +106,15 @@ public function testTermsTranslation() { // Test terms are listed. $this->drupalget('node/add/article'); - $this->assertText('one'); - $this->assertText('two'); - $this->assertText('three'); + $this->assertSession()->pageTextContains('one'); + $this->assertSession()->pageTextContains('two'); + $this->assertSession()->pageTextContains('three'); // Test terms translated are listed. $this->drupalget('hu/node/add/article'); - $this->assertText('translatedOne'); - $this->assertText('translatedTwo'); - $this->assertText('translatedThree'); + $this->assertSession()->pageTextContains('translatedOne'); + $this->assertSession()->pageTextContains('translatedTwo'); + $this->assertSession()->pageTextContains('translatedThree'); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php index 5d420090b145..f4e55c645ae2 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldAllTermsTest.php @@ -53,20 +53,20 @@ public function testViewsHandlerAllTermsWithTokens() { $this->drupalGet('taxonomy_all_terms_token_test'); // Term itself: {{ term_node_tid }} - $this->assertText('Term: ' . $this->term1->getName()); + $this->assertSession()->pageTextContains('Term: ' . $this->term1->getName()); // The taxonomy term ID for the term: {{ term_node_tid__tid }} - $this->assertText('The taxonomy term ID for the term: ' . $this->term1->id()); + $this->assertSession()->pageTextContains('The taxonomy term ID for the term: ' . $this->term1->id()); // The taxonomy term name for the term: {{ term_node_tid__name }} - $this->assertText('The taxonomy term name for the term: ' . $this->term1->getName()); + $this->assertSession()->pageTextContains('The taxonomy term name for the term: ' . $this->term1->getName()); // The machine name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary_vid }} - $this->assertText('The machine name for the vocabulary the term belongs to: ' . $this->term1->bundle()); + $this->assertSession()->pageTextContains('The machine name for the vocabulary the term belongs to: ' . $this->term1->bundle()); // The name for the vocabulary the term belongs to: {{ term_node_tid__vocabulary }} $vocabulary = Vocabulary::load($this->term1->bundle()); - $this->assertText('The name for the vocabulary the term belongs to: ' . $vocabulary->label()); + $this->assertSession()->pageTextContains('The name for the vocabulary the term belongs to: ' . $vocabulary->label()); } } diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php index 47cd3ad798cf..4f67f321a9df 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php @@ -97,8 +97,8 @@ public function testTaxonomyTermView() { $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertText($term->label()); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($term->label()); + $this->assertSession()->pageTextContains($node->label()); \Drupal::service('module_installer')->install(['language', 'content_translation']); ConfigurableLanguage::createFromLangcode('ur')->save(); @@ -116,14 +116,14 @@ public function testTaxonomyTermView() { $this->drupalPostForm('node/' . $node->id() . '/translations/add/en/ur', $edit, 'Save (this translation)'); $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertText($term->label()); - $this->assertText($original_title); + $this->assertSession()->pageTextContains($term->label()); + $this->assertSession()->pageTextContains($original_title); $this->assertNoText($translated_title); $this->drupalGet('ur/taxonomy/term/' . $term->id()); - $this->assertText($term->label()); + $this->assertSession()->pageTextContains($term->label()); $this->assertNoText($original_title); - $this->assertText($translated_title); + $this->assertSession()->pageTextContains($translated_title); // Uninstall language module and ensure that the language is not part of the // query anymore. diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyVocabularyArgumentTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyVocabularyArgumentTest.php index e9cfe225bb84..841ab102fc59 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyVocabularyArgumentTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyVocabularyArgumentTest.php @@ -73,7 +73,7 @@ protected function setUp($import_test_views = TRUE): void { public function testTermWithVocabularyArgument() { $this->drupalGet('test_argument_taxonomy_vocabulary/' . $this->vocabularies[0]->id()); // First term should be present. - $this->assertText($this->terms[0]->label()); + $this->assertSession()->pageTextContains($this->terms[0]->label()); // Second term should not be present. $this->assertNoText($this->terms[1]->label()); } diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php index c0508779cc5b..c5b3aed5a51e 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php @@ -243,7 +243,7 @@ public function testVocabularyPermissionsTaxonomyTerm() { $edit['name[0][value]'] = $this->randomMachineName(); $this->submitForm($edit, 'Save'); - $this->assertText('Created new term ' . $edit['name[0][value]'] . '.'); + $this->assertSession()->pageTextContains('Created new term ' . $edit['name[0][value]'] . '.'); // Verify that the creation message contains a link to a term. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "term/")]'); @@ -256,11 +256,11 @@ public function testVocabularyPermissionsTaxonomyTerm() { // Edit the term. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); $this->assertSession()->statusCodeEquals(200); - $this->assertText($edit['name[0][value]']); + $this->assertSession()->pageTextContains($edit['name[0][value]']); $edit['name[0][value]'] = $this->randomMachineName(); $this->submitForm($edit, 'Save'); - $this->assertText('Updated term ' . $edit['name[0][value]'] . '.'); + $this->assertSession()->pageTextContains('Updated term ' . $edit['name[0][value]'] . '.'); // Delete the vocabulary. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); @@ -313,11 +313,11 @@ public function testVocabularyPermissionsTaxonomyTerm() { // Edit the term. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); $this->assertSession()->statusCodeEquals(200); - $this->assertText($term->getName()); + $this->assertSession()->pageTextContains($term->getName()); $edit['name[0][value]'] = $this->randomMachineName(); $this->submitForm($edit, 'Save'); - $this->assertText('Updated term ' . $edit['name[0][value]'] . '.'); + $this->assertSession()->pageTextContains('Updated term ' . $edit['name[0][value]'] . '.'); // Verify that the update message contains a link to a term. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "term/")]'); diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php index 62446c592a66..d7f3b8b029c3 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php @@ -51,8 +51,8 @@ public function testVocabularyInterface() { // Edit the vocabulary. $this->drupalGet('admin/structure/taxonomy'); - $this->assertText($edit['name']); - $this->assertText($edit['description']); + $this->assertSession()->pageTextContains($edit['name']); + $this->assertSession()->pageTextContains($edit['description']); $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $edit['vid']])->toString()); $this->clickLink(t('Edit vocabulary')); $edit = []; @@ -60,18 +60,18 @@ public function testVocabularyInterface() { $edit['description'] = $this->randomMachineName(); $this->submitForm($edit, 'Save'); $this->drupalGet('admin/structure/taxonomy'); - $this->assertText($edit['name']); - $this->assertText($edit['description']); + $this->assertSession()->pageTextContains($edit['name']); + $this->assertSession()->pageTextContains($edit['description']); // Try to submit a vocabulary with a duplicate machine name. $edit['vid'] = $vid; $this->drupalPostForm('admin/structure/taxonomy/add', $edit, 'Save'); - $this->assertText('The machine-readable name is already in use. It must be unique.'); + $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); // Try to submit an invalid machine name. $edit['vid'] = '!&^%'; $this->drupalPostForm('admin/structure/taxonomy/add', $edit, 'Save'); - $this->assertText('The machine-readable name must contain only lowercase letters, numbers, and underscores.'); + $this->assertSession()->pageTextContains('The machine-readable name must contain only lowercase letters, numbers, and underscores.'); // Ensure that vocabulary titles are escaped properly. $edit = []; @@ -126,7 +126,7 @@ public function testTaxonomyAdminNoVocabularies() { $this->assertEmpty(Vocabulary::loadMultiple(), 'No vocabularies found.'); $this->drupalGet('admin/structure/taxonomy'); // Check the default message for no vocabularies. - $this->assertText('No vocabularies available.'); + $this->assertSession()->pageTextContains('No vocabularies available.'); } /** @@ -140,7 +140,7 @@ public function testTaxonomyAdminDeletingVocabulary() { 'vid' => $vid, ]; $this->drupalPostForm('admin/structure/taxonomy/add', $edit, 'Save'); - $this->assertText('Created new vocabulary'); + $this->assertSession()->pageTextContains('Created new vocabulary'); // Check the created vocabulary. $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache(); @@ -151,7 +151,7 @@ public function testTaxonomyAdminDeletingVocabulary() { $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id()); $this->clickLink(t('Delete')); $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', ['%name' => $vocabulary->label()])); - $this->assertText('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'); + $this->assertSession()->pageTextContains('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'); // Confirm deletion. $this->submitForm([], 'Delete'); diff --git a/core/modules/text/tests/src/Functional/TextFieldTest.php b/core/modules/text/tests/src/Functional/TextFieldTest.php index 6cde608c164b..34c6a6bbc2b4 100644 --- a/core/modules/text/tests/src/Functional/TextFieldTest.php +++ b/core/modules/text/tests/src/Functional/TextFieldTest.php @@ -134,7 +134,7 @@ public function testRequiredLongTextWithFileUpload() { $this->submitForm($edit, 'Save'); $this->assertSession()->statusCodeEquals(200); $this->drupalGet('entity_test/1'); - $this->assertText('Long text'); + $this->assertSession()->pageTextContains('Long text'); } /** @@ -207,7 +207,7 @@ public function _testTextfieldWidgetsFormatted($field_type, $widget_type) { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; - $this->assertText('entity_test ' . $id . ' has been created.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Display the entity. $entity = EntityTest::load($id); @@ -245,7 +245,7 @@ public function _testTextfieldWidgetsFormatted($field_type, $widget_type) { "{$field_name}[0][format]" => $format_id, ]; $this->submitForm($edit, 'Save'); - $this->assertText('entity_test ' . $id . ' has been updated.'); + $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been updated.'); // Display the entity. $this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]); diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php index 1462030e39f6..15b6adb4a6e7 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php @@ -149,7 +149,7 @@ public function testMenuLinkUpdateSubtreesHashCacheClear() { $edit['enabled'] = FALSE; $this->drupalPostForm("admin/structure/menu/link/" . $admin_menu_link_id . "/edit", $edit, 'Save'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The menu link has been saved.'); + $this->assertSession()->pageTextContains('The menu link has been saved.'); // Assert that the subtrees hash has been altered because the subtrees // structure changed. @@ -199,7 +199,7 @@ public function testUserRoleUpdateSubtreesHashCacheClear() { // Assign the role to the user. $this->drupalPostForm('user/' . $this->adminUser->id() . '/edit', ["roles[$rid]" => $rid], 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Assert that the subtrees hash has been altered because the subtrees // structure changed. @@ -240,7 +240,7 @@ public function testNonCurrentUserAccountUpdates() { // Assign the role to the user. $this->drupalPostForm('user/' . $admin_user_id . '/edit', ["roles[$rid]" => $rid], 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Log in adminUser and assert that the subtrees hash has changed. $this->drupalLogin($this->adminUser); @@ -288,7 +288,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() { $this->container->get('string_translation')->reset(); $this->assertRaw('"edit-languages-' . $langcode . '-weight"'); // Verify that the test language was added. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Have the adminUser request a page in the new language. $this->drupalGet($langcode . '/test-page'); @@ -313,7 +313,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() { $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); $this->assertNoText('No strings available'); // Verify that search found the string as untranslated. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Assume this is the only result. // Translate the string to a random string. @@ -323,7 +323,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() { $lid => $translation, ]; $this->drupalPostForm('admin/config/regional/translate', $edit, 'Save translations'); - $this->assertText('The strings have been saved.'); + $this->assertSession()->pageTextContains('The strings have been saved.'); // Verify that the user is redirected to the correct page. $this->assertSession()->addressEquals(Url::fromRoute('locale.translate_page')); $this->drupalLogout(); @@ -406,11 +406,11 @@ public function testExternalLink() { // Assert that the new menu link is shown on the menu link listing. $this->drupalGet('admin/structure/menu/manage/admin'); - $this->assertText('External URL'); + $this->assertSession()->pageTextContains('External URL'); // Assert that the new menu link is shown in the toolbar on a regular page. $this->drupalGet(Url::fromRoute('<front>')); - $this->assertText('External URL'); + $this->assertSession()->pageTextContains('External URL'); // Ensure the description is escaped as expected. $this->assertRaw('title="External URL & escaped"'); } diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarMenuTranslationTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarMenuTranslationTest.php index bec09c20656c..35d36602f148 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarMenuTranslationTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarMenuTranslationTest.php @@ -95,12 +95,12 @@ public function testToolbarClasses() { ]; $this->drupalPostForm('admin/config/regional/translate', $search, 'Filter'); // Make sure the menu item string was translated. - $this->assertText($menu_item_translated); + $this->assertSession()->pageTextContains($menu_item_translated); // Go to another page in the custom language and make sure the menu item // was translated. $this->drupalGet($langcode . '/admin/structure'); - $this->assertText($menu_item_translated); + $this->assertSession()->pageTextContains($menu_item_translated); // Toolbar icons are included based on the presence of a specific class on // the menu item. Ensure that class also exists for a translated menu item. diff --git a/core/modules/tour/tests/src/Functional/TourHelpPageTest.php b/core/modules/tour/tests/src/Functional/TourHelpPageTest.php index 6cbe63a64d52..2a97a0f27128 100644 --- a/core/modules/tour/tests/src/Functional/TourHelpPageTest.php +++ b/core/modules/tour/tests/src/Functional/TourHelpPageTest.php @@ -77,14 +77,14 @@ protected function verifyHelp($tours_ok = TRUE) { $this->drupalGet('admin/help'); // All users should be able to see the module section. - $this->assertText('Module overviews are provided by modules'); + $this->assertSession()->pageTextContains('Module overviews are provided by modules'); foreach ($this->getModuleList() as $name) { $this->assertSession()->linkExists($name); } // Some users should be able to see the tour section. if ($tours_ok) { - $this->assertText('Tours guide you through workflows'); + $this->assertSession()->pageTextContains('Tours guide you through workflows'); } else { $this->assertNoText('Tours guide you through workflows'); @@ -111,7 +111,7 @@ protected function verifyHelp($tours_ok = TRUE) { // Test the titles that should not be links. foreach ($titles[1] as $title) { if ($tours_ok) { - $this->assertText($title); + $this->assertSession()->pageTextContains($title); $this->assertSession()->linkNotExistsExact($title); } else { diff --git a/core/modules/tour/tests/src/Functional/TourTest.php b/core/modules/tour/tests/src/Functional/TourTest.php index 98c7e2ffd34a..05ec3c5dcc78 100644 --- a/core/modules/tour/tests/src/Functional/TourTest.php +++ b/core/modules/tour/tests/src/Functional/TourTest.php @@ -207,7 +207,7 @@ public function testTourFunctionality() { $this->assertCount(1, $elements, 'Found code tip was weighted last and had "End tour".'); // Test hook_tour_alter(). - $this->assertText('Altered by hook_tour_tips_alter'); + $this->assertSession()->pageTextContains('Altered by hook_tour_tips_alter'); // Navigate to tour-test-3 and verify the tour_test_1 tip is found with // appropriate classes. diff --git a/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php b/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php index 3bfbae5ddb28..7e5da4f46e05 100644 --- a/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php +++ b/core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php @@ -65,7 +65,7 @@ public function testTrackerNodeAccessIndexing() { $user = $this->drupalCreateUser(['node test view']); $this->drupalLogin($user); $this->drupalGet('activity'); - $this->assertText($private_node->getTitle()); + $this->assertSession()->pageTextContains($private_node->getTitle()); } /** @@ -95,20 +95,20 @@ public function testTrackerNodeAccess() { // User with access should see both nodes created. $this->drupalGet('activity'); - $this->assertText($private_node->getTitle()); - $this->assertText($public_node->getTitle()); + $this->assertSession()->pageTextContains($private_node->getTitle()); + $this->assertSession()->pageTextContains($public_node->getTitle()); $this->drupalGet('user/' . $access_user->id() . '/activity'); - $this->assertText($private_node->getTitle()); - $this->assertText($public_node->getTitle()); + $this->assertSession()->pageTextContains($private_node->getTitle()); + $this->assertSession()->pageTextContains($public_node->getTitle()); // User without access should not see private node. $this->drupalLogin($no_access_user); $this->drupalGet('activity'); $this->assertNoText($private_node->getTitle()); - $this->assertText($public_node->getTitle()); + $this->assertSession()->pageTextContains($public_node->getTitle()); $this->drupalGet('user/' . $access_user->id() . '/activity'); $this->assertNoText($private_node->getTitle()); - $this->assertText($public_node->getTitle()); + $this->assertSession()->pageTextContains($public_node->getTitle()); } } diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php index f6b7429d3233..941ed589f794 100644 --- a/core/modules/tracker/tests/src/Functional/TrackerTest.php +++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php @@ -89,7 +89,7 @@ public function testTrackerAll() { $this->drupalGet('activity'); $this->assertNoText($unpublished->label()); - $this->assertText($published->label()); + $this->assertSession()->pageTextContains($published->label()); $this->assertSession()->linkExists('My recent content', 0, 'User tab shows up on the global tracker page.'); // Assert cache contexts, specifically the pager and node access contexts. @@ -135,8 +135,8 @@ public function testTrackerAll() { ]); $this->drupalGet('activity'); - $this->assertText($node->label()); - $this->assertText(\Drupal::service('date.formatter')->formatTimeDiffSince($node->getChangedTime())); + $this->assertSession()->pageTextContains($node->label()); + $this->assertSession()->pageTextContains(\Drupal::service('date.formatter')->formatTimeDiffSince($node->getChangedTime())); } /** @@ -173,9 +173,9 @@ public function testTrackerUser() { $this->drupalGet('user/' . $this->user->id() . '/activity'); $this->assertNoText($unpublished->label()); - $this->assertText($my_published->label()); + $this->assertSession()->pageTextContains($my_published->label()); $this->assertNoText($other_published_no_comment->label()); - $this->assertText($other_published_my_comment->label()); + $this->assertSession()->pageTextContains($other_published_my_comment->label()); // Assert cache contexts. $this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.query_args.pagers:0', 'user', 'user.node_grants:view']); @@ -210,7 +210,7 @@ public function testTrackerUser() { $this->assertSession()->linkExists($my_published->label()); $this->assertSession()->linkNotExists($unpublished->label()); // Verify that title and tab title have been set correctly. - $this->assertText('Activity'); + $this->assertSession()->pageTextContains('Activity'); $this->assertSession()->titleEquals($this->user->getAccountName() . ' | Drupal'); // Verify that unpublished comments are removed from the tracker. @@ -404,7 +404,7 @@ public function testTrackerCronIndexing() { // Assert that all node titles are displayed. foreach ($nodes as $i => $node) { - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } // Fetch the site-wide tracker. @@ -412,7 +412,7 @@ public function testTrackerCronIndexing() { // Assert that all node titles are displayed. foreach ($nodes as $i => $node) { - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); } } @@ -434,7 +434,7 @@ public function testTrackerAdminUnpublish() { // Assert that the node is displayed. $this->drupalGet('activity'); - $this->assertText($node->label()); + $this->assertSession()->pageTextContains($node->label()); // Unpublish the node and ensure that it's no longer displayed. $edit = [ @@ -444,7 +444,7 @@ public function testTrackerAdminUnpublish() { $this->drupalPostForm('admin/content', $edit, 'Apply to selected items'); $this->drupalGet('activity'); - $this->assertText('No content available.'); + $this->assertSession()->pageTextContains('No content available.'); } /** diff --git a/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php b/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php index 679bee1dc4e2..351967122632 100644 --- a/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php +++ b/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php @@ -63,11 +63,11 @@ public function testViaAuthorize($url) { 'connection_settings[system_test][update_test_username]' => $this->randomMachineName(), ]; $this->submitForm($edit, 'Continue'); - $this->assertText('Files were added successfully.'); + $this->assertSession()->pageTextContains('Files were added successfully.'); // Ensure the module is available to install. $this->drupalGet('admin/modules'); - $this->assertText('Update test new module'); + $this->assertSession()->pageTextContains('Update test new module'); } /** diff --git a/core/modules/update/tests/src/Functional/UpdateContribTest.php b/core/modules/update/tests/src/Functional/UpdateContribTest.php index a3541eefac48..0d24aa22a69f 100644 --- a/core/modules/update/tests/src/Functional/UpdateContribTest.php +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php @@ -70,10 +70,10 @@ public function testNoReleasesAvailable() { // 'No available releases found' string. $this->assertSession()->responseContains('<h3>Drupal core</h3>'); $this->assertRaw(Link::fromTextAndUrl(t('Drupal'), Url::fromUri('http://example.com/project/drupal'))->toString()); - $this->assertText('Up to date'); + $this->assertSession()->pageTextContains('Up to date'); $this->assertSession()->responseContains('<h3>Modules</h3>'); $this->assertNoText('Update available'); - $this->assertText('No available releases found'); + $this->assertSession()->pageTextContains('No available releases found'); $this->assertNoRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); $available = update_get_available(); @@ -103,7 +103,7 @@ public function testUpdateContribBasic() { ] ); $this->standardTests(); - $this->assertText('Up to date'); + $this->assertSession()->pageTextContains('Up to date'); $this->assertSession()->responseContains('<h3>Modules</h3>'); $this->assertNoText('Update available'); $this->assertRaw($project_link); @@ -181,13 +181,13 @@ public function testUpdateContribOrder() { $this->refreshUpdateStatus(['drupal' => '0.0', '#all' => '1_0']); $this->standardTests(); // We're expecting the report to say all projects are up to date. - $this->assertText('Up to date'); + $this->assertSession()->pageTextContains('Up to date'); $this->assertNoText('Update available'); // We want to see all 3 module names listed, since they'll show up either // as project names or as modules under the "Includes" listing. - $this->assertText('AAA Update test'); - $this->assertText('BBB Update test'); - $this->assertText('CCC Update test'); + $this->assertSession()->pageTextContains('AAA Update test'); + $this->assertSession()->pageTextContains('BBB Update test'); + $this->assertSession()->pageTextContains('CCC Update test'); // We want aaa_update_test included in the ccc_update_test project, not as // its own project on the report. $this->assertNoRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); @@ -241,7 +241,7 @@ public function testUpdateBaseThemeSecurityUpdate() { 'update_test_basetheme' => '1_1-sec', ]; $this->refreshUpdateStatus($xml_mapping); - $this->assertText('Security update required!'); + $this->assertSession()->pageTextContains('Security update required!'); $this->assertRaw(Link::fromTextAndUrl(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'))->toString()); } @@ -397,7 +397,7 @@ public function testUpdateShowDisabledThemes() { // themes. $this->assertNoText('Themes'); if ($check_disabled) { - $this->assertText('Uninstalled themes'); + $this->assertSession()->pageTextContains('Uninstalled themes'); $this->assertRaw($base_theme_project_link); $this->assertRaw($sub_theme_project_link); } @@ -477,7 +477,7 @@ public function testUpdateBrokenFetchURL() { ]; $this->refreshUpdateStatus($xml_mapping); - $this->assertText('Up to date'); + $this->assertSession()->pageTextContains('Up to date'); // We're expecting the report to say most projects are up to date, so we // hope that 'Up to date' is not unique. $this->assertSession()->pageTextMatchesCount(3, '/Up to date/'); @@ -540,7 +540,7 @@ public function testHookUpdateStatusAlter() { ); $this->drupalGet('admin/reports/updates'); $this->assertSession()->responseContains('<h3>Modules</h3>'); - $this->assertText('Security update required!'); + $this->assertSession()->pageTextContains('Security update required!'); $this->assertRaw(Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString()); // Visit the reports page again without the altering and make sure the @@ -554,7 +554,7 @@ public function testHookUpdateStatusAlter() { // Turn the altering back on and visit the Update manager UI. $update_test_config->set('update_status', $update_status)->save(); $this->drupalGet('admin/modules/update'); - $this->assertText('Security update'); + $this->assertSession()->pageTextContains('Security update'); // Turn the altering back off and visit the Update manager UI. $update_test_config->set('update_status', [])->save(); diff --git a/core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php b/core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php index 214faf9d9d97..19a2546dc0b7 100644 --- a/core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php +++ b/core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php @@ -279,7 +279,7 @@ public function testDatestampMismatch() { $this->config('update_test.settings')->set('system_info', $system_info)->save(); $this->refreshUpdateStatus(['drupal' => 'dev']); $this->assertNoText('2001-Sep-'); - $this->assertText('Up to date'); + $this->assertSession()->pageTextContains('Up to date'); $this->assertNoText('Update available'); $this->assertNoText('Security update required!'); } @@ -334,7 +334,7 @@ public function testModulePageUpToDate() { $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); $this->checkForMetaRefresh(); - $this->assertText('Checked available update data for one project.'); + $this->assertSession()->pageTextContains('Checked available update data for one project.'); $this->drupalGet('admin/modules'); $this->assertNoText('There are updates available for your version of Drupal.'); $this->assertNoText('There is a security update available for your version of Drupal.'); @@ -356,9 +356,9 @@ public function testModulePageRegularUpdate() { $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); $this->checkForMetaRefresh(); - $this->assertText('Checked available update data for one project.'); + $this->assertSession()->pageTextContains('Checked available update data for one project.'); $this->drupalGet('admin/modules'); - $this->assertText('There are updates available for your version of Drupal.'); + $this->assertSession()->pageTextContains('There are updates available for your version of Drupal.'); $this->assertNoText('There is a security update available for your version of Drupal.'); } @@ -378,15 +378,15 @@ public function testModulePageSecurityUpdate() { $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); $this->checkForMetaRefresh(); - $this->assertText('Checked available update data for one project.'); + $this->assertSession()->pageTextContains('Checked available update data for one project.'); $this->drupalGet('admin/modules'); $this->assertNoText('There are updates available for your version of Drupal.'); - $this->assertText('There is a security update available for your version of Drupal.'); + $this->assertSession()->pageTextContains('There is a security update available for your version of Drupal.'); // Make sure admin/appearance warns you you're missing a security update. $this->drupalGet('admin/appearance'); $this->assertNoText('There are updates available for your version of Drupal.'); - $this->assertText('There is a security update available for your version of Drupal.'); + $this->assertSession()->pageTextContains('There is a security update available for your version of Drupal.'); // Make sure duplicate messages don't appear on Update status pages. $this->drupalGet('admin/reports/status'); @@ -449,7 +449,7 @@ public function testLanguageModuleUpdate() { ->save(); $this->drupalGet('admin/reports/updates'); - $this->assertText('Language'); + $this->assertSession()->pageTextContains('Language'); } /** diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php index 32d8126cb074..086adb23dd03 100644 --- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -70,7 +70,7 @@ public function testUploadModule() { 'files[project_upload]' => $validArchiveFile, ]; $this->drupalPostForm('admin/modules/install', $edit, 'Continue'); - $this->assertText('AAA Update test is already present.'); + $this->assertSession()->pageTextContains('AAA Update test is already present.'); $this->assertSession()->addressEquals('admin/modules/install'); // Ensure that a new module can be extracted and installed. @@ -132,7 +132,7 @@ public function testUploadModule() { // Run the updates for the new module. $this->drupalPostForm('admin/reports/updates/update', ['projects[update_test_new_module]' => TRUE], 'Download these updates'); $this->submitForm(['maintenance_mode' => FALSE], 'Continue'); - $this->assertText('Update was completed successfully.'); + $this->assertSession()->pageTextContains('Update was completed successfully.'); $this->assertRaw(t('Added / updated %project_name successfully', ['%project_name' => 'update_test_new_module'])); // Parse the info file again to check that the module has been updated to diff --git a/core/modules/user/tests/src/Functional/UserAdminLanguageTest.php b/core/modules/user/tests/src/Functional/UserAdminLanguageTest.php index 1b13442d29d8..9cdb5c77fff1 100644 --- a/core/modules/user/tests/src/Functional/UserAdminLanguageTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminLanguageTest.php @@ -128,9 +128,9 @@ public function testActualNegotiation() { // no preference set, negotiation will fall back further. $path = 'user/' . $this->adminUser->id() . '/edit'; $this->drupalGet($path); - $this->assertText('Language negotiation method: language-default'); + $this->assertSession()->pageTextContains('Language negotiation method: language-default'); $this->drupalGet('xx/' . $path); - $this->assertText('Language negotiation method: language-url'); + $this->assertSession()->pageTextContains('Language negotiation method: language-url'); // Set a preferred language code for the user. $edit = []; @@ -140,26 +140,26 @@ public function testActualNegotiation() { // Test negotiation with the URL method first. The admin method will only // be used if the URL method did not match. $this->drupalGet($path); - $this->assertText('Language negotiation method: language-user-admin'); + $this->assertSession()->pageTextContains('Language negotiation method: language-user-admin'); $this->drupalGet('xx/' . $path); - $this->assertText('Language negotiation method: language-url'); + $this->assertSession()->pageTextContains('Language negotiation method: language-url'); // Test negotiation with the admin language method first. The admin method // will be used at all times. $this->setLanguageNegotiation(TRUE); $this->drupalGet($path); - $this->assertText('Language negotiation method: language-user-admin'); + $this->assertSession()->pageTextContains('Language negotiation method: language-user-admin'); $this->drupalGet('xx/' . $path); - $this->assertText('Language negotiation method: language-user-admin'); + $this->assertSession()->pageTextContains('Language negotiation method: language-user-admin'); // Unset the preferred language code for the user. $edit = []; $edit['preferred_admin_langcode'] = ''; $this->drupalPostForm($path, $edit, 'Save'); $this->drupalGet($path); - $this->assertText('Language negotiation method: language-default'); + $this->assertSession()->pageTextContains('Language negotiation method: language-default'); $this->drupalGet('xx/' . $path); - $this->assertText('Language negotiation method: language-url'); + $this->assertSession()->pageTextContains('Language negotiation method: language-url'); } /** diff --git a/core/modules/user/tests/src/Functional/UserAdminTest.php b/core/modules/user/tests/src/Functional/UserAdminTest.php index fba8235e3fbe..b4ac139281c1 100644 --- a/core/modules/user/tests/src/Functional/UserAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminTest.php @@ -56,10 +56,10 @@ public function testUserAdmin() { $admin_user->save(); $this->drupalLogin($admin_user); $this->drupalGet('admin/people'); - $this->assertText($user_a->getAccountName()); - $this->assertText($user_b->getAccountName()); - $this->assertText($user_c->getAccountName()); - $this->assertText($admin_user->getAccountName()); + $this->assertSession()->pageTextContains($user_a->getAccountName()); + $this->assertSession()->pageTextContains($user_b->getAccountName()); + $this->assertSession()->pageTextContains($user_c->getAccountName()); + $this->assertSession()->pageTextContains($admin_user->getAccountName()); // Test for existence of edit link in table. $link = $user_a->toLink(t('Edit'), 'edit-form', ['query' => ['destination' => $user_a->toUrl('collection')->toString()]])->toString(); @@ -89,8 +89,8 @@ public function testUserAdmin() { // Check if the correct users show up. $this->assertNoText($user_a->getAccountName()); - $this->assertText($user_b->getAccountName()); - $this->assertText($user_c->getAccountName()); + $this->assertSession()->pageTextContains($user_b->getAccountName()); + $this->assertSession()->pageTextContains($user_c->getAccountName()); // Filter the users by role. Grab the system-generated role name for User C. $roles = $user_c->getRoles(); @@ -100,7 +100,7 @@ public function testUserAdmin() { // Check if the correct users show up when filtered by role. $this->assertNoText($user_a->getAccountName()); $this->assertNoText($user_b->getAccountName()); - $this->assertText($user_c->getAccountName()); + $this->assertSession()->pageTextContains($user_c->getAccountName()); // Test blocking of a user. $account = $user_storage->load($user_c->id()); @@ -126,7 +126,7 @@ public function testUserAdmin() { $this->drupalGet('admin/people', ['query' => ['status' => 2]]); $this->assertNoText($user_a->getAccountName()); $this->assertNoText($user_b->getAccountName()); - $this->assertText($user_c->getAccountName()); + $this->assertSession()->pageTextContains($user_c->getAccountName()); // Test unblocking of a user from /admin/people page and sending of activation mail $editunblock = []; diff --git a/core/modules/user/tests/src/Functional/UserBlocksTest.php b/core/modules/user/tests/src/Functional/UserBlocksTest.php index 70cdd05b6bd6..fa5589be7f61 100644 --- a/core/modules/user/tests/src/Functional/UserBlocksTest.php +++ b/core/modules/user/tests/src/Functional/UserBlocksTest.php @@ -124,7 +124,7 @@ public function testUserLoginBlock() { $edit['name'] = 'foo'; $edit['pass'] = 'invalid password'; $this->drupalPostForm('filter/tips', $edit, 'Log in'); - $this->assertText('Unrecognized username or password. Forgot your password?'); + $this->assertSession()->pageTextContains('Unrecognized username or password. Forgot your password?'); $this->drupalGet('filter/tips'); $this->assertNoText('Unrecognized username or password. Forgot your password?'); } diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php index 8c9f55aee554..43ef05e99d29 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -145,12 +145,12 @@ public function testUserCancelInvalid() { // Confirm account cancellation. $timestamp = time(); $this->submitForm([], 'Cancel account'); - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); // Attempt bogus account cancellation request confirmation. $bogus_timestamp = $timestamp + 60; $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account, $bogus_timestamp)); - $this->assertText('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'); + $this->assertSession()->pageTextContains('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'); $user_storage->resetCache([$account->id()]); $account = $user_storage->load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); @@ -158,7 +158,7 @@ public function testUserCancelInvalid() { // Attempt expired account cancellation request confirmation. $bogus_timestamp = $timestamp - 86400 - 60; $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account, $bogus_timestamp)); - $this->assertText('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'); + $this->assertSession()->pageTextContains('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'); $user_storage->resetCache([$account->id()]); $account = $user_storage->load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); @@ -188,15 +188,15 @@ public function testUserBlock() { // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); - $this->assertText('Are you sure you want to cancel your account?'); - $this->assertText('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your username.'); + $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?'); + $this->assertSession()->pageTextContains('Your account will be blocked and you will no longer be able to log in. All of your content will remain attributed to your username.'); $this->assertNoText('Select the method to cancel the account above.'); // Confirm account cancellation. $timestamp = time(); $this->submitForm([], 'Cancel account'); - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); @@ -248,13 +248,13 @@ public function testUserBlockUnpublish() { // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); - $this->assertText('Are you sure you want to cancel your account?'); - $this->assertText('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'); + $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?'); + $this->assertSession()->pageTextContains('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'); // Confirm account cancellation. $timestamp = time(); $this->submitForm([], 'Cancel account'); - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); @@ -369,13 +369,13 @@ public function testUserAnonymize() { // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); - $this->assertText('Are you sure you want to cancel your account?'); + $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?'); $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')])); // Confirm account cancellation. $timestamp = time(); $this->submitForm([], 'Cancel account'); - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); @@ -433,13 +433,13 @@ public function testUserAnonymizeBatch() { // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); - $this->assertText('Are you sure you want to cancel your account?'); + $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?'); $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', ['%anonymous-name' => $this->config('user.settings')->get('anonymous')])); // Confirm account cancellation. $timestamp = time(); $this->submitForm([], 'Cancel account'); - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); @@ -487,7 +487,7 @@ public function testUserDelete() { $this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $edit, 'Preview'); $this->submitForm([], 'Save'); - $this->assertText('Your comment has been posted.'); + $this->assertSession()->pageTextContains('Your comment has been posted.'); $comments = \Drupal::entityTypeManager()->getStorage('comment')->loadByProperties(['subject' => $edit['subject[0][value]']]); $comment = reset($comments); $this->assertNotEmpty($comment->id(), 'Comment found.'); @@ -505,13 +505,13 @@ public function testUserDelete() { // Attempt to cancel account. $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); - $this->assertText('Are you sure you want to cancel your account?'); - $this->assertText('Your account will be removed and all account information deleted. All of your content will also be deleted.'); + $this->assertSession()->pageTextContains('Are you sure you want to cancel your account?'); + $this->assertSession()->pageTextContains('Your account will be removed and all account information deleted. All of your content will also be deleted.'); // Confirm account cancellation. $timestamp = time(); $this->submitForm([], 'Cancel account'); - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); // Confirm account cancellation request. $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); @@ -553,7 +553,7 @@ public function testUserCancelByAdmin() { $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()])); - $this->assertText('Select the method to cancel the account above.'); + $this->assertSession()->pageTextContains('Select the method to cancel the account above.'); // Confirm deletion. $this->submitForm([], 'Cancel account'); @@ -581,7 +581,7 @@ public function testUserWithoutEmailCancelByAdmin() { $this->drupalGet('user/' . $account->id() . '/edit'); $this->submitForm([], 'Cancel account'); $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $account->getAccountName()])); - $this->assertText('Select the method to cancel the account above.'); + $this->assertSession()->pageTextContains('Select the method to cancel the account above.'); // Confirm deletion. $this->submitForm([], 'Cancel account'); @@ -617,10 +617,10 @@ public function testMassUserCancelByAdmin() { $edit['user_bulk_form[' . $i . ']'] = TRUE; } $this->drupalPostForm('admin/people', $edit, 'Apply to selected items'); - $this->assertText('Are you sure you want to cancel these user accounts?'); - $this->assertText('When cancelling these accounts'); - $this->assertText('Require email confirmation to cancel account'); - $this->assertText('Notify user when account is canceled'); + $this->assertSession()->pageTextContains('Are you sure you want to cancel these user accounts?'); + $this->assertSession()->pageTextContains('When cancelling these accounts'); + $this->assertSession()->pageTextContains('Require email confirmation to cancel account'); + $this->assertSession()->pageTextContains('Notify user when account is canceled'); // Confirm deletion. $this->submitForm([], 'Cancel accounts'); @@ -633,7 +633,7 @@ public function testMassUserCancelByAdmin() { $this->assertTrue($status, 'Users deleted and not found in the database.'); // Ensure that admin account was not cancelled. - $this->assertText('A confirmation request to cancel your account has been sent to your email address.'); + $this->assertSession()->pageTextContains('A confirmation request to cancel your account has been sent to your email address.'); $admin_user = $user_storage->load($admin_user->id()); $this->assertTrue($admin_user->isActive(), 'Administrative user is found in the database and enabled.'); diff --git a/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php b/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php index 106356c6cef1..c2d633acbc84 100644 --- a/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php +++ b/core/modules/user/tests/src/Functional/UserCreateFailMailTest.php @@ -43,7 +43,7 @@ public function testUserAdd() { ]; $this->drupalPostForm('admin/people/create', $edit, 'Create new account'); - $this->assertText('Unable to send email. Contact the site administrator if the problem persists.'); + $this->assertSession()->pageTextContains('Unable to send email. Contact the site administrator if the problem persists.'); $this->assertNoText('A welcome message with further instructions has been emailed to the new user ' . $edit['name'] . '.'); } diff --git a/core/modules/user/tests/src/Functional/UserCreateTest.php b/core/modules/user/tests/src/Functional/UserCreateTest.php index 31981e8a19c3..de8958bb6cbd 100644 --- a/core/modules/user/tests/src/Functional/UserCreateTest.php +++ b/core/modules/user/tests/src/Functional/UserCreateTest.php @@ -108,16 +108,16 @@ public function testUserAdd() { $this->drupalPostForm('admin/people/create', $edit, 'Create new account'); if ($notify) { - $this->assertText('A welcome message with further instructions has been emailed to the new user ' . $edit['name'] . '.'); + $this->assertSession()->pageTextContains('A welcome message with further instructions has been emailed to the new user ' . $edit['name'] . '.'); $this->assertCount(1, $this->drupalGetMails(), 'Notification email sent'); } else { - $this->assertText('Created a new user account for ' . $edit['name'] . '. No email has been sent.'); + $this->assertSession()->pageTextContains('Created a new user account for ' . $edit['name'] . '. No email has been sent.'); $this->assertCount(0, $this->drupalGetMails(), 'Notification email not sent'); } $this->drupalGet('admin/people'); - $this->assertText($edit['name']); + $this->assertSession()->pageTextContains($edit['name']); $user = user_load_by_name($name); $this->assertTrue($user->isActive(), 'User is not blocked'); } @@ -133,7 +133,7 @@ public function testUserAdd() { 'notify' => FALSE, ]; $this->drupalPostForm('admin/people/create', $edit, 'Create new account'); - $this->assertText("Created a new user account for $name. No email has been sent"); + $this->assertSession()->pageTextContains("Created a new user account for $name. No email has been sent"); $this->assertNoText('Password field is required'); } diff --git a/core/modules/user/tests/src/Functional/UserEditTest.php b/core/modules/user/tests/src/Functional/UserEditTest.php index ca3347afdac8..4bbf1e1d6ea0 100644 --- a/core/modules/user/tests/src/Functional/UserEditTest.php +++ b/core/modules/user/tests/src/Functional/UserEditTest.php @@ -49,12 +49,12 @@ public function testUserEdit() { $edit['pass[pass1]'] = ''; $edit['pass[pass2]'] = $this->randomMachineName(); $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, 'Save'); - $this->assertText("The specified passwords do not match."); + $this->assertSession()->pageTextContains("The specified passwords do not match."); $edit['pass[pass1]'] = $this->randomMachineName(); $edit['pass[pass2]'] = ''; $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, 'Save'); - $this->assertText("The specified passwords do not match."); + $this->assertSession()->pageTextContains("The specified passwords do not match."); // Test that the error message appears when attempting to change the mail or // pass without the current password. @@ -116,13 +116,13 @@ public function testUserEdit() { $edit = ['status' => 0]; $this->drupalPostForm('user/' . $user1->id() . '/edit', $edit, 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $this->assertSession()->checkboxChecked('edit-status-0'); $this->assertSession()->checkboxNotChecked('edit-status-1'); $edit = ['status' => 1]; $this->drupalPostForm('user/' . $user1->id() . '/edit', $edit, 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $this->assertSession()->checkboxNotChecked('edit-status-0'); $this->assertSession()->checkboxChecked('edit-status-1'); } diff --git a/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php b/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php index 071450a54f98..5e41d3b14580 100644 --- a/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php +++ b/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php @@ -46,7 +46,7 @@ public function testLocalUserCreation() { 'language_interface[enabled][language-url]' => TRUE, ]; $this->drupalPostForm('admin/config/regional/language/detection', $edit, 'Save settings'); - $this->assertText('Language detection configuration saved.'); + $this->assertSession()->pageTextContains('Language detection configuration saved.'); // Check if the language selector is available on admin/people/create and // set to the currently active language. diff --git a/core/modules/user/tests/src/Functional/UserLanguageTest.php b/core/modules/user/tests/src/Functional/UserLanguageTest.php index cf3cedff7bd2..19f9faee4cf8 100644 --- a/core/modules/user/tests/src/Functional/UserLanguageTest.php +++ b/core/modules/user/tests/src/Functional/UserLanguageTest.php @@ -56,16 +56,16 @@ public function testUserLanguageConfiguration() { $path = 'user/' . $web_user->id() . '/edit'; $this->drupalGet($path); // Ensure language settings widget is available. - $this->assertText('Language'); + $this->assertSession()->pageTextContains('Language'); // Ensure custom language is present. - $this->assertText($name); + $this->assertSession()->pageTextContains($name); // Switch to our custom language. $edit = [ 'preferred_langcode' => $langcode, ]; $this->drupalPostForm($path, $edit, 'Save'); // Ensure form was submitted successfully. - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Check if language was changed. $this->assertTrue($this->assertSession()->optionExists('edit-preferred-langcode', $langcode)->isSelected()); diff --git a/core/modules/user/tests/src/Functional/UserLoginTest.php b/core/modules/user/tests/src/Functional/UserLoginTest.php index 57da5c7cd92d..4d1b750d4edd 100644 --- a/core/modules/user/tests/src/Functional/UserLoginTest.php +++ b/core/modules/user/tests/src/Functional/UserLoginTest.php @@ -195,7 +195,7 @@ public function assertFailedLogin($account, $flood_trigger = NULL) { else { $this->assertSession()->statusCodeEquals(200); $this->assertSession()->fieldValueEquals('pass', ''); - $this->assertText('Unrecognized username or password. Forgot your password?'); + $this->assertSession()->pageTextContains('Unrecognized username or password. Forgot your password?'); } } diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php index 9937070866a3..a53b6f35c7d4 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -130,8 +130,8 @@ public function testUserPasswordReset() { $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check the one-time login page. - $this->assertText($this->account->getAccountName()); - $this->assertText('This login can be used only once.'); + $this->assertSession()->pageTextContains($this->account->getAccountName()); + $this->assertSession()->pageTextContains('This login can be used only once.'); $this->assertSession()->titleEquals('Reset password | Drupal'); // Check successful login. @@ -143,17 +143,17 @@ public function testUserPasswordReset() { $password = \Drupal::service('password_generator')->generate(); $edit = ['pass[pass1]' => $password, 'pass[pass2]' => $password]; $this->submitForm($edit, 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Verify that the password reset session has been destroyed. $this->submitForm($edit, 'Save'); - $this->assertText("Your current password is missing or incorrect; it's required to change the Password."); + $this->assertSession()->pageTextContains("Your current password is missing or incorrect; it's required to change the Password."); // Log out, and try to log in again using the same one-time link. $this->drupalLogout(); $this->drupalGet($resetURL); $this->submitForm([], 'Log in'); - $this->assertText('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'); + $this->assertSession()->pageTextContains('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'); // Request a new password again, this time using the email address. // Count email messages before to compare with after. @@ -179,7 +179,7 @@ public function testUserPasswordReset() { $_uid = $this->account->id(); $this->drupalGet("user/reset/$_uid/$bogus_timestamp/" . user_pass_rehash($this->account, $bogus_timestamp)); $this->submitForm([], 'Log in'); - $this->assertText('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'); + $this->assertSession()->pageTextContains('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'); // Create a user, block the account, and verify that a login link is denied. $timestamp = REQUEST_TIME - 1; @@ -205,7 +205,7 @@ public function testUserPasswordReset() { $this->account->save(); $this->drupalGet($old_email_reset_link); $this->submitForm([], 'Log in'); - $this->assertText('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'); + $this->assertSession()->pageTextContains('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'); // Verify a password reset link will automatically log a user when /login is // appended. @@ -338,7 +338,7 @@ public function testUserPasswordResetLoggedIn() { $another_account->delete(); $this->drupalGet($resetURL); - $this->assertText('The one-time login link you clicked is invalid.'); + $this->assertSession()->pageTextContains('The one-time login link you clicked is invalid.'); // Log in. $this->drupalLogin($this->account); @@ -356,7 +356,7 @@ public function testUserPasswordResetLoggedIn() { $password = \Drupal::service('password_generator')->generate(); $edit = ['pass[pass1]' => $password, 'pass[pass2]' => $password]; $this->submitForm($edit, 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Logged in users should not be able to access the user.reset.login or the // user.reset.form routes. @@ -510,7 +510,7 @@ public function assertNoValidPasswordReset($name) { * Makes assertions about a password reset triggering IP flood control. */ public function assertPasswordIpFlood() { - $this->assertText('Too many password recovery requests from your IP address. It is temporarily blocked. Try again later or contact the site administrator.'); + $this->assertSession()->pageTextContains('Too many password recovery requests from your IP address. It is temporarily blocked. Try again later or contact the site administrator.'); } /** @@ -558,7 +558,7 @@ public function testResetImpersonation() { // Verify that the invalid password reset page does not show the user name. $this->assertNoText($user2->getAccountName()); $this->assertSession()->addressEquals('user/password'); - $this->assertText('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'); + $this->assertSession()->pageTextContains('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'); } } diff --git a/core/modules/user/tests/src/Functional/UserPermissionsTest.php b/core/modules/user/tests/src/Functional/UserPermissionsTest.php index 1a9d5061e525..7ebff34ad366 100644 --- a/core/modules/user/tests/src/Functional/UserPermissionsTest.php +++ b/core/modules/user/tests/src/Functional/UserPermissionsTest.php @@ -73,7 +73,7 @@ public function testUserPermissionChanges() { $edit = []; $edit[$rid . '[administer users]'] = TRUE; $this->drupalPostForm('admin/people/permissions', $edit, 'Save permissions'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $storage->resetCache(); $this->assertTrue($account->hasPermission('administer users'), 'User now has "administer users" permission.'); $current_permissions_hash = $permissions_hash_generator->generate($account); @@ -86,7 +86,7 @@ public function testUserPermissionChanges() { $edit = []; $edit[$rid . '[access user profiles]'] = FALSE; $this->drupalPostForm('admin/people/permissions', $edit, 'Save permissions'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $storage->resetCache(); $this->assertFalse($account->hasPermission('access user profiles'), 'User no longer has "access user profiles" permission.'); $current_permissions_hash = $permissions_hash_generator->generate($account); diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php index b6e8ca8aff5c..64e5d5d6d51f 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -46,7 +46,7 @@ public function testRegistrationWithEmailVerification() { $edit['name'] = $name = $this->randomMachineName(); $edit['mail'] = $mail = $edit['name'] . '@example.com'; $this->drupalPostForm('user/register', $edit, 'Create new account'); - $this->assertText('A welcome message with further instructions has been sent to your email address.'); + $this->assertSession()->pageTextContains('A welcome message with further instructions has been sent to your email address.'); /** @var EntityStorageInterface $storage */ $storage = $this->container->get('entity_type.manager')->getStorage('user'); @@ -86,7 +86,7 @@ public function testRegistrationWithoutEmailVerification() { $edit['pass[pass1]'] = '99999.0'; $edit['pass[pass2]'] = '99999'; $this->drupalPostForm('user/register', $edit, 'Create new account'); - $this->assertText('The specified passwords do not match.'); + $this->assertSession()->pageTextContains('The specified passwords do not match.'); // Enter a correct password. $edit['pass[pass1]'] = $new_pass = $this->randomMachineName(); @@ -97,7 +97,7 @@ public function testRegistrationWithoutEmailVerification() { ->loadByProperties(['name' => $name, 'mail' => $mail]); $new_user = reset($accounts); $this->assertNotNull($new_user, 'New account successfully created with matching passwords.'); - $this->assertText('Registration successful. You are now logged in.'); + $this->assertSession()->pageTextContains('Registration successful. You are now logged in.'); $this->drupalLogout(); // Allow registration by site visitors, but require administrator approval. @@ -108,7 +108,7 @@ public function testRegistrationWithoutEmailVerification() { $edit['pass[pass1]'] = $pass = $this->randomMachineName(); $edit['pass[pass2]'] = $pass; $this->drupalPostForm('user/register', $edit, 'Create new account'); - $this->assertText('Thank you for applying for an account. Your account is currently pending approval by the site administrator.'); + $this->assertSession()->pageTextContains('Thank you for applying for an account. Your account is currently pending approval by the site administrator.'); // Try to log in before administrator approval. $auth = [ @@ -116,7 +116,7 @@ public function testRegistrationWithoutEmailVerification() { 'pass' => $pass, ]; $this->drupalPostForm('user/login', $auth, 'Log in'); - $this->assertText('The username ' . $name . ' has not been activated or is blocked.'); + $this->assertSession()->pageTextContains('The username ' . $name . ' has not been activated or is blocked.'); // Activate the new account. $accounts = $this->container->get('entity_type.manager')->getStorage('user') @@ -132,7 +132,7 @@ public function testRegistrationWithoutEmailVerification() { // Log in after administrator approval. $this->drupalPostForm('user/login', $auth, 'Log in'); - $this->assertText('Member for'); + $this->assertSession()->pageTextContains('Member for'); } public function testRegistrationEmailDuplicates() { @@ -152,13 +152,13 @@ public function testRegistrationEmailDuplicates() { // Attempt to create a new account using an existing email address. $this->drupalPostForm('user/register', $edit, 'Create new account'); - $this->assertText('The email address ' . $duplicate_user->getEmail() . ' is already taken.'); + $this->assertSession()->pageTextContains('The email address ' . $duplicate_user->getEmail() . ' is already taken.'); // Attempt to bypass duplicate email registration validation by adding spaces. $edit['mail'] = ' ' . $duplicate_user->getEmail() . ' '; $this->drupalPostForm('user/register', $edit, 'Create new account'); - $this->assertText('The email address ' . $duplicate_user->getEmail() . ' is already taken.'); + $this->assertSession()->pageTextContains('The email address ' . $duplicate_user->getEmail() . ' is already taken.'); } /** @@ -328,7 +328,7 @@ public function testRegistrationWithUserFields() { ->save(); $this->drupalGet('user/register'); - $this->assertText($field->label()); + $this->assertSession()->pageTextContains($field->label()); $this->assertRegistrationFormCacheTagsWithUserFields(); // Check that validation errors are correctly reported. diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php index 03fa875141b1..0630c73477e3 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -122,7 +122,7 @@ public function testRoleWeightOrdering() { $weight--; } $this->drupalPostForm('admin/people/roles', $edit, 'Save'); - $this->assertText('The role settings have been updated.'); + $this->assertSession()->pageTextContains('The role settings have been updated.'); // Load up the user roles with the new weights. $roles = user_roles(); diff --git a/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php b/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php index c7f6b4552f53..9085a8ce6f10 100644 --- a/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php +++ b/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php @@ -35,13 +35,13 @@ public function testAssignAndRemoveRole() { // Assign the role to the user. $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => $rid], 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $this->assertSession()->checkboxChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid); // Remove the role from the user. $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => FALSE], 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $this->assertSession()->checkboxNotChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid, FALSE); } @@ -61,7 +61,7 @@ public function testCreateUserWithRole() { "roles[$rid]" => $rid, ]; $this->drupalPostForm('admin/people/create', $edit, 'Create new account'); - $this->assertText('Created a new user account for ' . $edit['name'] . '.'); + $this->assertSession()->pageTextContains('Created a new user account for ' . $edit['name'] . '.'); // Get the newly added user. $account = user_load_by_name($edit['name']); @@ -71,7 +71,7 @@ public function testCreateUserWithRole() { // Remove the role again. $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => FALSE], 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $this->assertSession()->checkboxNotChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid, FALSE); } diff --git a/core/modules/user/tests/src/Functional/UserSearchTest.php b/core/modules/user/tests/src/Functional/UserSearchTest.php index b20596ec299e..e221289e2d35 100644 --- a/core/modules/user/tests/src/Functional/UserSearchTest.php +++ b/core/modules/user/tests/src/Functional/UserSearchTest.php @@ -36,14 +36,14 @@ public function testUserSearch() { $keys = $user1->getEmail(); $edit = ['keys' => $keys]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText('Your search yielded no results.'); - $this->assertText('no results'); + $this->assertSession()->pageTextContains('Your search yielded no results.'); + $this->assertSession()->pageTextContains('no results'); // Verify that a non-matching query gives an appropriate message. $keys = 'nomatch'; $edit = ['keys' => $keys]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText('no results'); + $this->assertSession()->pageTextContains('no results'); // Verify that a user with search permission can search for users by name. $keys = $user1->getAccountName(); @@ -74,28 +74,28 @@ public function testUserSearch() { $keys = $user2->getEmail(); $edit = ['keys' => $keys]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText($keys); - $this->assertText($user2->getAccountName()); + $this->assertSession()->pageTextContains($keys); + $this->assertSession()->pageTextContains($user2->getAccountName()); // Verify that a substring works too for email. $subkey = substr($keys, 1, 5); $edit = ['keys' => $subkey]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText($keys); - $this->assertText($user2->getAccountName()); + $this->assertSession()->pageTextContains($keys); + $this->assertSession()->pageTextContains($user2->getAccountName()); // Verify that wildcard search works for email $subkey = substr($keys, 0, 2) . '*' . substr($keys, 4, 2); $edit = ['keys' => $subkey]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText($user2->getAccountName()); + $this->assertSession()->pageTextContains($user2->getAccountName()); // Verify that if they search by user name, they see email address too. $keys = $user1->getAccountName(); $edit = ['keys' => $keys]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText($keys); - $this->assertText($user1->getEmail()); + $this->assertSession()->pageTextContains($keys); + $this->assertSession()->pageTextContains($user1->getEmail()); // Create a blocked user. $blocked_user = $this->drupalCreateUser(); @@ -106,14 +106,14 @@ public function testUserSearch() { // accounts in search results. $edit = ['keys' => $blocked_user->getAccountName()]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText($blocked_user->getAccountName()); + $this->assertSession()->pageTextContains($blocked_user->getAccountName()); // Verify that users without "administer users" permissions do not see // blocked accounts in search results. $this->drupalLogin($user1); $edit = ['keys' => $blocked_user->getAccountName()]; $this->drupalPostForm('search/user', $edit, 'Search'); - $this->assertText('Your search yielded no results.'); + $this->assertSession()->pageTextContains('Your search yielded no results.'); // Ensure that a user without access to user profiles cannot access the // user search page. diff --git a/core/modules/user/tests/src/Functional/UserTimeZoneTest.php b/core/modules/user/tests/src/Functional/UserTimeZoneTest.php index 0aaea7addfb0..3104828d6969 100644 --- a/core/modules/user/tests/src/Functional/UserTimeZoneTest.php +++ b/core/modules/user/tests/src/Functional/UserTimeZoneTest.php @@ -62,49 +62,49 @@ public function testUserTimeZone() { // Confirm date format and time zone. $this->drupalGet('node/' . $node1->id()); // Date should be PST. - $this->assertText('2007-03-09 21:00 0'); + $this->assertSession()->pageTextContains('2007-03-09 21:00 0'); $this->drupalGet('node/' . $node2->id()); // Date should be PST. - $this->assertText('2007-03-11 01:00 0'); + $this->assertSession()->pageTextContains('2007-03-11 01:00 0'); $this->drupalGet('node/' . $node3->id()); // Date should be PST. - $this->assertText('2007-03-20 21:00 1'); + $this->assertSession()->pageTextContains('2007-03-20 21:00 1'); // Change user time zone to Santiago time. $edit = []; $edit['mail'] = $web_user->getEmail(); $edit['timezone'] = 'America/Santiago'; $this->drupalPostForm("user/" . $web_user->id() . "/edit", $edit, 'Save'); - $this->assertText('The changes have been saved.'); + $this->assertSession()->pageTextContains('The changes have been saved.'); // Confirm date format and time zone. $this->drupalGet('node/' . $node1->id()); // Date should be Chile summer time, five hours ahead of PST. - $this->assertText('2007-03-10 02:00 1'); + $this->assertSession()->pageTextContains('2007-03-10 02:00 1'); $this->drupalGet('node/' . $node2->id()); // Date should be Chile time, four hours ahead of PST. - $this->assertText('2007-03-11 05:00 0'); + $this->assertSession()->pageTextContains('2007-03-11 05:00 0'); $this->drupalGet('node/' . $node3->id()); // Date should be Chile time, three hours ahead of PDT. - $this->assertText('2007-03-21 00:00 0'); + $this->assertSession()->pageTextContains('2007-03-21 00:00 0'); // Ensure that anonymous users also use the default timezone. $this->drupalLogout(); $this->drupalGet('node/' . $node1->id()); // Date should be PST. - $this->assertText('2007-03-09 21:00 0'); + $this->assertSession()->pageTextContains('2007-03-09 21:00 0'); $this->drupalGet('node/' . $node2->id()); // Date should be PST. - $this->assertText('2007-03-11 01:00 0'); + $this->assertSession()->pageTextContains('2007-03-11 01:00 0'); $this->drupalGet('node/' . $node3->id()); // Date should be PDT. - $this->assertText('2007-03-20 21:00 1'); + $this->assertSession()->pageTextContains('2007-03-20 21:00 1'); // Format a date without accessing the current user at all and // ensure that it uses the default timezone. $this->drupalGet('/system-test/date'); // Date should be PST. - $this->assertText('2016-01-13 08:29 0'); + $this->assertSession()->pageTextContains('2016-01-13 08:29 0'); } } diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php index a20c44471267..1285974d86c6 100644 --- a/core/modules/user/tests/src/Functional/Views/BulkFormTest.php +++ b/core/modules/user/tests/src/Functional/Views/BulkFormTest.php @@ -51,7 +51,7 @@ public function testBulkForm() { 'action' => 'user_block_user_action', ]; $this->drupalPostForm('test-user-bulk-form', $edit, 'Apply to selected items'); - $this->assertText('No users selected.'); + $this->assertSession()->pageTextContains('No users selected.'); // Assign a role to a user. $account = $user_storage->load($this->users[0]->id()); @@ -101,7 +101,7 @@ public function testBulkForm() { // Ensure the anonymous user is found. $this->drupalGet('test-user-bulk-form'); - $this->assertText($this->config('user.settings')->get('anonymous')); + $this->assertSession()->pageTextContains($this->config('user.settings')->get('anonymous')); // Attempt to block the anonymous user. $edit = [ diff --git a/core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php b/core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php index 96733cda5eed..374bd9bce28b 100644 --- a/core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php +++ b/core/modules/user/tests/src/Functional/Views/FilterPermissionUiTest.php @@ -55,7 +55,7 @@ public function testHandlerUI() { $this->submitForm([], 'Save'); // Verify that we can save the view. $this->assertNoText('No valid values found on filter: User: Permission.'); - $this->assertText('The view test_filter_permission has been saved.'); + $this->assertSession()->pageTextContains('The view test_filter_permission has been saved.'); // Verify that the handler summary is also correct when multiple values are // selected in the filter. @@ -70,7 +70,7 @@ public function testHandlerUI() { $this->submitForm([], 'Save'); // Verify that we can save the view. $this->assertNoText('No valid values found on filter: User: Permission.'); - $this->assertText('The view test_filter_permission has been saved.'); + $this->assertSession()->pageTextContains('The view test_filter_permission has been saved.'); } } diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php index ae67df363bdc..f9e610a58a46 100644 --- a/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php @@ -46,7 +46,7 @@ public function testRole() { $this->drupalGet('/test-views-handler-field-role'); // Verify that the view test_views_handler_field_role renders role assigned // to user in the correct order and markup in role names is escaped. - $this->assertText($rolename_b . Html::escape('<em>' . $rolename_a . '</em>')); + $this->assertSession()->responseContains($rolename_b . Html::escape('<em>' . $rolename_a . '</em>')); // Verify that the view test_views_handler_field_role does not render a role // not assigned to a user. $this->assertNoText($rolename_not_assigned); diff --git a/core/modules/user/tests/src/Functional/Views/UserChangedTest.php b/core/modules/user/tests/src/Functional/Views/UserChangedTest.php index 5b044ea2f266..5813915b3a32 100644 --- a/core/modules/user/tests/src/Functional/Views/UserChangedTest.php +++ b/core/modules/user/tests/src/Functional/Views/UserChangedTest.php @@ -49,7 +49,7 @@ public function testChangedField() { $this->drupalGet($path, $options); - $this->assertText('Updated date: ' . date('Y-m-d', REQUEST_TIME)); + $this->assertSession()->pageTextContains('Updated date: ' . date('Y-m-d', REQUEST_TIME)); } } diff --git a/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php b/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php index 519983a83ee0..40df001dc7ba 100644 --- a/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php +++ b/core/modules/user/tests/src/Functional/Views/UserFieldsAccessChangeTest.php @@ -35,8 +35,8 @@ public function testUserFieldAccess() { $this->drupalGet('test_user_fields_access'); // User has access to name and created date by default. - $this->assertText('Name'); - $this->assertText('Created'); + $this->assertSession()->pageTextContains('Name'); + $this->assertSession()->pageTextContains('Created'); // User does not by default have access to init, mail and status. $this->assertNoText('Init'); @@ -49,9 +49,9 @@ public function testUserFieldAccess() { $this->drupalGet('test_user_fields_access'); // Access for init, mail and status is added in hook_entity_field_access(). - $this->assertText('Init'); - $this->assertText('Email'); - $this->assertText('Status'); + $this->assertSession()->pageTextContains('Init'); + $this->assertSession()->pageTextContains('Email'); + $this->assertSession()->pageTextContains('Status'); } /** @@ -70,7 +70,7 @@ public function testUserNameLink() { // No access, so no link. $this->drupalGet('test_user_fields_access'); - $this->assertText($test_user->getAccountName()); + $this->assertSession()->pageTextContains($test_user->getAccountName()); $result = $this->xpath($xpath); $this->assertCount(0, $result, 'User is not a link'); diff --git a/core/modules/views/tests/src/Functional/BulkFormTest.php b/core/modules/views/tests/src/Functional/BulkFormTest.php index 9349c08a03ae..85c0a4c132fd 100644 --- a/core/modules/views/tests/src/Functional/BulkFormTest.php +++ b/core/modules/views/tests/src/Functional/BulkFormTest.php @@ -35,7 +35,7 @@ public function testBulkForm() { // First, test an empty bulk form with the default style plugin to make sure // the empty region is rendered correctly. $this->drupalGet('test_bulk_form_empty'); - $this->assertText('This view is empty.'); + $this->assertSession()->pageTextContains('This view is empty.'); $nodes = []; for ($i = 0; $i < 10; $i++) { @@ -85,7 +85,7 @@ public function testBulkForm() { $this->assertTrue($changed_node->isSticky(), new FormattableMarkup('Node @nid got marked as sticky.', ['@nid' => $node->id()])); } - $this->assertText('Make content sticky was applied to 10 items.'); + $this->assertSession()->pageTextContains('Make content sticky was applied to 10 items.'); // Unpublish just one node. $node = $node_storage->load($nodes[0]->id()); @@ -94,7 +94,7 @@ public function testBulkForm() { $edit = ['node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action']; $this->submitForm($edit, 'Apply to selected items'); - $this->assertText('Unpublish content was applied to 1 item.'); + $this->assertSession()->pageTextContains('Unpublish content was applied to 1 item.'); // Load the node again. $node_storage->resetCache([$node->id()]); @@ -157,7 +157,7 @@ public function testBulkForm() { // confirmation page. $this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "messages--status")]'); $this->submitForm([], 'Delete'); - $this->assertText('Deleted 5 content items.'); + $this->assertSession()->pageTextContains('Deleted 5 content items.'); // Check if we got redirected to the original page. $this->assertSession()->addressEquals('test_bulk_form'); @@ -193,7 +193,7 @@ public function testBulkForm() { // confirmation page. $this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "messages--status")]'); $this->submitForm([], 'Delete'); - $this->assertText('Deleted 1 content item.'); + $this->assertSession()->pageTextContains('Deleted 1 content item.'); // Test that the bulk form works when multiple nodes are selected // but all of the selected nodes are already deleted @@ -208,7 +208,7 @@ public function testBulkForm() { 'action' => 'node_delete_action', ]; $this->submitForm($edit, 'Apply to selected items'); - $this->assertText('No content selected.'); + $this->assertSession()->pageTextContains('No content selected.'); } } diff --git a/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php b/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php index dbd65f0c2356..e06d4185989f 100644 --- a/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php +++ b/core/modules/views/tests/src/Functional/Entity/BaseFieldAccessTest.php @@ -66,7 +66,7 @@ protected function setUp($import_test_views = TRUE): void { */ public function testProtectedField() { $this->drupalGet('test-entity-protected-access'); - $this->assertText('ok to see this one'); + $this->assertSession()->pageTextContains('ok to see this one'); $this->assertNoText('no access value'); } diff --git a/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php b/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php index d4b6e9c8fe26..18fbb054cf5f 100644 --- a/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php +++ b/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php @@ -44,8 +44,8 @@ public function testViewNoTranslatableEntity() { // Visit the view page and assert it is displayed properly. $this->drupalGet('no-entity-translation-view'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('No Entity Translation View'); - $this->assertText($no_language_entity->uuid()); + $this->assertSession()->pageTextContains('No Entity Translation View'); + $this->assertSession()->pageTextContains($no_language_entity->uuid()); } } diff --git a/core/modules/views/tests/src/Functional/Handler/AreaTest.php b/core/modules/views/tests/src/Functional/Handler/AreaTest.php index 613729ac22e6..3f32d9f8b996 100644 --- a/core/modules/views/tests/src/Functional/Handler/AreaTest.php +++ b/core/modules/views/tests/src/Functional/Handler/AreaTest.php @@ -70,13 +70,13 @@ public function testUI() { // First setup an empty label. $this->drupalPostForm($edit_path, [], 'Apply'); - $this->assertText('Test Example area'); + $this->assertSession()->pageTextContains('Test Example area'); // Then setup a no empty label. $labels[$type] = $this->randomMachineName(); $this->drupalPostForm($edit_path, ['options[admin_label]' => $labels[$type]], 'Apply'); // Make sure that the new label appears on the site. - $this->assertText($labels[$type]); + $this->assertSession()->pageTextContains($labels[$type]); // Test that the settings (empty/admin_label) are accessible. $this->drupalGet($edit_path); @@ -186,7 +186,7 @@ public function testRenderAreaToken() { // Test that each item exists in the list. foreach ($available[$type] as $token => $info) { - $this->assertText("[$type:$token]"); + $this->assertSession()->pageTextContains("[$type:$token]"); } } @@ -223,7 +223,7 @@ public function testTitleArea() { $view->storage->enable()->save(); $this->drupalGet('node'); - $this->assertText('Overridden title'); + $this->assertSession()->pageTextContains('Overridden title'); } } diff --git a/core/modules/views/tests/src/Functional/Handler/FilterDateTest.php b/core/modules/views/tests/src/Functional/Handler/FilterDateTest.php index 940a81f8d1c5..eb3d7812e639 100644 --- a/core/modules/views/tests/src/Functional/Handler/FilterDateTest.php +++ b/core/modules/views/tests/src/Functional/Handler/FilterDateTest.php @@ -196,7 +196,7 @@ protected function _testUiValidation() { // Generate a definitive wrong value, which should be checked by validation. $edit['options[value][value]'] = $this->randomString() . '-------'; $this->submitForm($edit, 'Apply'); - $this->assertText('Invalid date format.'); + $this->assertSession()->pageTextContains('Invalid date format.'); } /** diff --git a/core/modules/views/tests/src/Functional/Plugin/ContextualFiltersBlockContextTest.php b/core/modules/views/tests/src/Functional/Plugin/ContextualFiltersBlockContextTest.php index 7475db404845..c6da4e0af7c0 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ContextualFiltersBlockContextTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ContextualFiltersBlockContextTest.php @@ -129,13 +129,13 @@ public function testBlockContext() { // Make sure view behaves as expected. $this->drupalGet('<front>'); - $this->assertText('Test view: No results found.'); + $this->assertSession()->pageTextContains('Test view: No results found.'); $this->drupalGet($this->nodes[0]->toUrl()); - $this->assertText('Test view row: First test node'); + $this->assertSession()->pageTextContains('Test view row: First test node'); $this->drupalGet($this->nodes[1]->toUrl()); - $this->assertText('Test view row: Second test node'); + $this->assertSession()->pageTextContains('Test view row: Second test node'); // Check the second block which should expose two integer contexts, one // based on the numeric plugin and the other based on numeric validation. diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayEntityReferenceTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayEntityReferenceTest.php index e5b8a07b2a3c..2b285f9b60dc 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayEntityReferenceTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayEntityReferenceTest.php @@ -140,8 +140,8 @@ public function testEntityReferenceDisplay() { // Test that the right fields are shown on the display settings form. $this->drupalGet('admin/structure/views/nojs/display/test_display_entity_reference/entity_reference_1/style_options'); - $this->assertText('Test entity: Name'); - $this->assertText('Test entity: ' . $this->field->label()); + $this->assertSession()->pageTextContains('Test entity: Name'); + $this->assertSession()->pageTextContains('Test entity: ' . $this->field->label()); // Add the new field to the search fields. $this->submitForm(['style_options[search_fields][' . $this->fieldName . ']' => $this->fieldName], 'Apply'); diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php index a78c78b6b48b..81edfd35c09e 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php @@ -123,7 +123,7 @@ public function testDisplayPlugin() { // Test that the display category/summary is in the UI. $this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1'); - $this->assertText('Display test settings'); + $this->assertSession()->pageTextContains('Display test settings'); // Ensure that the order is as expected. $result = $this->xpath('//ul[@id="views-display-menu-tabs"]/li/a/child::text()'); $this->assertEquals('Display test 2', $result[0]->getText()); @@ -308,7 +308,7 @@ public function testInvalidDisplayPlugins() { $this->drupalGet('test_display_invalid'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The "invalid" plugin does not exist.'); + $this->assertSession()->pageTextContains('The "invalid" plugin does not exist.'); // Rebuild the router, and ensure that the path is not accessible anymore. views_invalidate_cache(); @@ -338,7 +338,7 @@ public function testInvalidDisplayPlugins() { // plugin warning message. $this->drupalGet('<front>'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('The "invalid" plugin does not exist.'); + $this->assertSession()->pageTextContains('The "invalid" plugin does not exist.'); $this->assertSession()->elementNotExists('xpath', "//div[@id = 'block-{$block->id()}']"); } @@ -446,15 +446,15 @@ protected function checkTranslationSetting($expected_node_translatability = FALS $this->drupalGet('admin/structure/views/nojs/display/content/page_1/rendering_language'); if ($expected_node_translatability) { $this->assertNoText($not_supported_text); - $this->assertText($supported_text); + $this->assertSession()->pageTextContains($supported_text); } else { - $this->assertText($not_supported_text); + $this->assertSession()->pageTextContains($not_supported_text); $this->assertNoText($supported_text); } $this->drupalGet('admin/structure/views/nojs/display/files/page_1/rendering_language'); - $this->assertText($not_supported_text); + $this->assertSession()->pageTextContains($not_supported_text); $this->assertNoText($supported_text); } diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 23e1a2376629..c42e0d45216c 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -211,7 +211,7 @@ public function testExposedBlock() { // Test that the block label is found. $this->drupalGet('test_exposed_block'); - $this->assertText($view->getTitle()); + $this->assertSession()->pageTextContains($view->getTitle()); // Set a custom label on the exposed filter form block. $block->getPlugin()->setConfigurationValue('views_label', '<strong>Custom</strong> title<script>alert("hacked!");</script>'); @@ -295,7 +295,7 @@ public function testTextInputRequired() { // Ensure that the "on demand text" is displayed when no exposed filters are // applied. $this->drupalGet('test_exposed_form_buttons'); - $this->assertText('Select any filter and click Apply to see results.'); + $this->assertSession()->pageTextContains('Select any filter and click Apply to see results.'); // Ensure that the "on demand text" is not displayed when an exposed filter // is applied. diff --git a/core/modules/views/tests/src/Functional/Plugin/FilterTest.php b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php index 18ec6df545ad..955cdc63d77f 100644 --- a/core/modules/views/tests/src/Functional/Plugin/FilterTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php @@ -211,7 +211,7 @@ public function testLimitExposedOperators() { $edit['options[operator]'] = '='; $edit['options[expose][operator_list][]'] = ['<', '>']; $this->drupalPostForm('admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/nid', $edit, 'Apply'); - $this->assertText('You selected the "Is equal to" operator as the default value but is not included in the list of limited operators.'); + $this->assertSession()->pageTextContains('You selected the "Is equal to" operator as the default value but is not included in the list of limited operators.'); } } diff --git a/core/modules/views/tests/src/Functional/Plugin/MenuLinkTest.php b/core/modules/views/tests/src/Functional/Plugin/MenuLinkTest.php index d4573409cef9..bc48565a7e0a 100644 --- a/core/modules/views/tests/src/Functional/Plugin/MenuLinkTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/MenuLinkTest.php @@ -100,14 +100,14 @@ public function testHierarchicalMenuLinkVisibility() { // Test if the primary menu item (node) is visible, and the secondary menu // item (view) is hidden. - $this->assertText('Primary level node'); + $this->assertSession()->pageTextContains('Primary level node'); $this->assertNoText('Secondary level view page'); // Go to the node page and ensure that both the first and second level items // are visible. $this->drupalGet($node->toUrl()); - $this->assertText('Primary level node'); - $this->assertText('Secondary level view page'); + $this->assertSession()->pageTextContains('Primary level node'); + $this->assertSession()->pageTextContains('Secondary level view page'); } } diff --git a/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php b/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php index 05d6f6a5a548..bb72ff81c730 100644 --- a/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/MiniPagerTest.php @@ -56,30 +56,30 @@ public function testMiniPagerRender() { // On first page, current page and next page link appear, previous page link // does not. $this->drupalGet('test_mini_pager'); - $this->assertText('›› test'); - $this->assertText('Page 1'); + $this->assertSession()->pageTextContains('›› test'); + $this->assertSession()->pageTextContains('Page 1'); $this->assertNoText('‹‹ test'); - $this->assertText($this->nodes[0]->label()); - $this->assertText($this->nodes[1]->label()); - $this->assertText($this->nodes[2]->label()); + $this->assertSession()->pageTextContains($this->nodes[0]->label()); + $this->assertSession()->pageTextContains($this->nodes[1]->label()); + $this->assertSession()->pageTextContains($this->nodes[2]->label()); // On second page, current page and previous/next page links appear. $this->drupalGet('test_mini_pager', ['query' => ['page' => 1]]); - $this->assertText('‹‹ test'); - $this->assertText('Page 2'); - $this->assertText('›› test'); - $this->assertText($this->nodes[3]->label()); - $this->assertText($this->nodes[4]->label()); - $this->assertText($this->nodes[5]->label()); + $this->assertSession()->pageTextContains('‹‹ test'); + $this->assertSession()->pageTextContains('Page 2'); + $this->assertSession()->pageTextContains('›› test'); + $this->assertSession()->pageTextContains($this->nodes[3]->label()); + $this->assertSession()->pageTextContains($this->nodes[4]->label()); + $this->assertSession()->pageTextContains($this->nodes[5]->label()); // On last page, current page and previous page link appear, next page link // does not. $this->drupalGet('test_mini_pager', ['query' => ['page' => 6]]); $this->assertNoText('›› test'); - $this->assertText('Page 7'); - $this->assertText('‹‹ test'); - $this->assertText($this->nodes[18]->label()); - $this->assertText($this->nodes[19]->label()); + $this->assertSession()->pageTextContains('Page 7'); + $this->assertSession()->pageTextContains('‹‹ test'); + $this->assertSession()->pageTextContains($this->nodes[18]->label()); + $this->assertSession()->pageTextContains($this->nodes[19]->label()); // Test @total value in result summary $view = Views::getView('test_mini_pager'); @@ -89,27 +89,27 @@ public function testMiniPagerRender() { $this->assertSame(count($this->nodes), (int) $view->total_rows, 'The total row count is equal to the number of nodes.'); $this->drupalGet('test_mini_pager_total', ['query' => ['page' => 1]]); - $this->assertText('of ' . count($this->nodes)); + $this->assertSession()->pageTextContains('of ' . count($this->nodes)); $this->drupalGet('test_mini_pager_total', ['query' => ['page' => 6]]); - $this->assertText('of ' . count($this->nodes)); + $this->assertSession()->pageTextContains('of ' . count($this->nodes)); // Test a mini pager with just one item per page. $this->drupalGet('test_mini_pager_one'); - $this->assertText('››'); - $this->assertText('Page 1'); - $this->assertText($this->nodes[0]->label()); + $this->assertSession()->pageTextContains('››'); + $this->assertSession()->pageTextContains('Page 1'); + $this->assertSession()->pageTextContains($this->nodes[0]->label()); $this->drupalGet('test_mini_pager_one', ['query' => ['page' => 1]]); - $this->assertText('‹‹'); - $this->assertText('Page 2'); - $this->assertText('››'); - $this->assertText($this->nodes[1]->label()); + $this->assertSession()->pageTextContains('‹‹'); + $this->assertSession()->pageTextContains('Page 2'); + $this->assertSession()->pageTextContains('››'); + $this->assertSession()->pageTextContains($this->nodes[1]->label()); $this->drupalGet('test_mini_pager_one', ['query' => ['page' => 19]]); $this->assertNoText('››'); - $this->assertText('Page 20'); - $this->assertText('‹‹'); - $this->assertText($this->nodes[19]->label()); + $this->assertSession()->pageTextContains('Page 20'); + $this->assertSession()->pageTextContains('‹‹'); + $this->assertSession()->pageTextContains($this->nodes[19]->label()); // Test a mini pager with all items on the page. No pager should display. $this->drupalGet('test_mini_pager_all'); @@ -128,7 +128,7 @@ public function testMiniPagerRender() { $this->assertNoText('‹‹ test'); $this->assertNoText('Page 1'); $this->assertNoText('‹‹ test'); - $this->assertText($this->nodes[19]->label()); + $this->assertSession()->pageTextContains($this->nodes[19]->label()); $view = Views::getView('test_mini_pager'); $this->executeView($view); diff --git a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php index 09bab62efb73..e78c511f7132 100644 --- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php @@ -120,7 +120,7 @@ public function testStorePagerSettings() { 'pager_options[items_per_page]' => 20, ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager_options', $edit, 'Apply'); - $this->assertText('20 items'); + $this->assertSession()->pageTextContains('20 items'); // Change type and check whether the type is new type is stored. $edit = [ @@ -128,7 +128,7 @@ public function testStorePagerSettings() { ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager', $edit, 'Apply'); $this->drupalGet('admin/structure/views/view/test_view/edit'); - $this->assertText('Mini'); + $this->assertSession()->pageTextContains('Mini'); // Test behavior described in // https://www.drupal.org/node/652712#comment-2354400. @@ -143,13 +143,13 @@ public function testStorePagerSettings() { ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager', $edit, 'Apply'); $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit'); - $this->assertText('Full'); + $this->assertSession()->pageTextContains('Full'); $edit = [ 'pager_options[items_per_page]' => 20, ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, 'Apply'); - $this->assertText('20 items'); + $this->assertSession()->pageTextContains('20 items'); // add new display and test the settings again, by override it. $edit = []; @@ -165,15 +165,15 @@ public function testStorePagerSettings() { ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, 'Apply'); $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit/page_1'); - $this->assertText('Mini'); + $this->assertSession()->pageTextContains('Mini'); $edit = [ 'pager_options[items_per_page]' => 10, ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, 'Apply'); - $this->assertText('10 items'); + $this->assertSession()->pageTextContains('10 items'); $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit/page_1'); - $this->assertText('20 items'); + $this->assertSession()->pageTextContains('20 items'); // Test that the override element is only displayed on pager plugin selection form. $this->drupalGet('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager'); diff --git a/core/modules/views/tests/src/Functional/Plugin/ViewsBulkTest.php b/core/modules/views/tests/src/Functional/Plugin/ViewsBulkTest.php index 3db191150ebc..15aa090a3028 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ViewsBulkTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ViewsBulkTest.php @@ -52,7 +52,7 @@ public function testBulkSelection() { // Login as administrator and go to admin/content. $this->drupalLogin($this->admin_user); $this->drupalGet('admin/content'); - $this->assertText($node_1->getTitle()); + $this->assertSession()->pageTextContains($node_1->getTitle()); // Create second node now that the admin overview has been rendered. $node_2 = $this->drupalCreateNode([ @@ -64,7 +64,7 @@ public function testBulkSelection() { // Now click 'Apply to selected items' and assert the first node is selected // on the confirm form. $this->submitForm(['node_bulk_form[0]' => TRUE], 'Apply to selected items'); - $this->assertText($node_1->getTitle()); + $this->assertSession()->pageTextContains($node_1->getTitle()); $this->assertNoText($node_2->getTitle()); // Change the pager limit to 2. @@ -82,7 +82,7 @@ public function testBulkSelection() { // Now click 'Apply to selected items' and assert the second node is // selected on the confirm form. $this->submitForm(['node_bulk_form[1]' => TRUE], 'Apply to selected items'); - $this->assertText($node_1->getTitle()); + $this->assertSession()->pageTextContains($node_1->getTitle()); $this->assertNoText($node_3->getTitle()); } diff --git a/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php b/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php index 785f49d3af0a..c14349ff2331 100644 --- a/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php +++ b/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php @@ -57,7 +57,7 @@ protected function setUp($import_test_views = TRUE): void { public function testTaxonomyGlossaryView() { // Go the taxonomy glossary page for the first term. $this->drupalGet('test_taxonomy_glossary/' . substr($this->taxonomyTerms[0]->getName(), 0, 1)); - $this->assertText($this->taxonomyTerms[0]->getName()); + $this->assertSession()->pageTextContains($this->taxonomyTerms[0]->getName()); } } diff --git a/core/modules/views/tests/src/Functional/ViewsEscapingTest.php b/core/modules/views/tests/src/Functional/ViewsEscapingTest.php index 8734f8be2364..fdffb7fec357 100644 --- a/core/modules/views/tests/src/Functional/ViewsEscapingTest.php +++ b/core/modules/views/tests/src/Functional/ViewsEscapingTest.php @@ -63,7 +63,7 @@ public function testViewsViewFieldsEscaping() { $this->drupalGet('test_page_display_200'); // Assert that we are using the correct template. - $this->assertText('force'); + $this->assertSession()->pageTextContains('force'); // Assert that there are no escaped '<'s characters. $this->assertSession()->assertNoEscaped('<'); diff --git a/core/modules/views/tests/src/Functional/ViewsFormMultipleTest.php b/core/modules/views/tests/src/Functional/ViewsFormMultipleTest.php index d5b0ae5ee39c..49ed139ae0f4 100644 --- a/core/modules/views/tests/src/Functional/ViewsFormMultipleTest.php +++ b/core/modules/views/tests/src/Functional/ViewsFormMultipleTest.php @@ -50,15 +50,15 @@ public function testViewsFormMultiple() { // Get the test page. $this->drupalGet('views_test_form_multiple'); - $this->assertText('Test base form ID with Views forms and arguments.'); + $this->assertSession()->pageTextContains('Test base form ID with Views forms and arguments.'); // Submit the forms, validate argument returned in message set by handler. // @note There is not a way to specify a specific index for a submit button. So // the row index returned is always the last occurrence. $this->getSession()->getPage()->pressButton('edit-field-form-button-test-4--2'); - $this->assertText('The test button at row 4 for test_form_multiple (default) View with args: arg2 was submitted.'); + $this->assertSession()->pageTextContains('The test button at row 4 for test_form_multiple (default) View with args: arg2 was submitted.'); $this->getSession()->getPage()->pressButton('edit-field-form-button-test-4'); - $this->assertText('The test button at row 4 for test_form_multiple (default) View with args: arg1 was submitted.'); + $this->assertSession()->pageTextContains('The test button at row 4 for test_form_multiple (default) View with args: arg1 was submitted.'); } } diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php index 0c03600de8c6..9766d08739c1 100644 --- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php @@ -31,7 +31,7 @@ public function testViewsWizardAndListing() { // Check if we can access the main views admin page. $this->drupalGet('admin/structure/views'); - $this->assertText('Add view'); + $this->assertSession()->pageTextContains('Add view'); // Create a simple and not at all useful view. $view1 = []; @@ -42,8 +42,8 @@ public function testViewsWizardAndListing() { $this->drupalPostForm('admin/structure/views/add', $view1, 'Save and edit'); $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/views'); - $this->assertText($view1['label']); - $this->assertText($view1['description']); + $this->assertSession()->pageTextContains($view1['label']); + $this->assertSession()->pageTextContains($view1['description']); $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.view.edit_form', ['view' => $view1['id']])->toString()); $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.view.delete_form', ['view' => $view1['id']])->toString()); $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.view.duplicate_form', ['view' => $view1['id']])->toString()); @@ -76,9 +76,9 @@ public function testViewsWizardAndListing() { // Since the view has a page, we expect to be automatically redirected to // it. $this->assertSession()->addressEquals($view2['page[path]']); - $this->assertText($view2['page[title]']); - $this->assertText($node1->label()); - $this->assertText($node2->label()); + $this->assertSession()->pageTextContains($view2['page[title]']); + $this->assertSession()->pageTextContains($node1->label()); + $this->assertSession()->pageTextContains($node2->label()); // Check if we have the feed. $this->assertSession()->linkByHrefExists(Url::fromRoute('view.' . $view2['id'] . '.feed_1')->toString()); @@ -89,16 +89,16 @@ public function testViewsWizardAndListing() { // HTML tag being present. $this->assertEquals('2.0', $this->getSession()->getDriver()->getAttribute('//rss', 'version')); // The feed should have the same title and nodes as the page. - $this->assertText($view2['page[title]']); + $this->assertSession()->responseContains($view2['page[title]']); $this->assertRaw($node1->toUrl('canonical', ['absolute' => TRUE])->toString()); - $this->assertText($node1->label()); + $this->assertSession()->responseContains($node1->label()); $this->assertRaw($node2->toUrl('canonical', ['absolute' => TRUE])->toString()); - $this->assertText($node2->label()); + $this->assertSession()->responseContains($node2->label()); // Go back to the views page and check if this view is there. $this->drupalGet('admin/structure/views'); - $this->assertText($view2['label']); - $this->assertText($view2['description']); + $this->assertSession()->pageTextContains($view2['label']); + $this->assertSession()->pageTextContains($view2['description']); $this->assertSession()->linkByHrefExists(Url::fromRoute('view.' . $view2['id'] . '.page_1')->toString()); // The view should not have a REST export display. @@ -126,14 +126,14 @@ public function testViewsWizardAndListing() { // Make sure the view only displays the node we expect. $this->assertSession()->addressEquals($view3['page[path]']); - $this->assertText($view3['page[title]']); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($view3['page[title]']); + $this->assertSession()->pageTextContains($node1->label()); $this->assertNoText($node2->label()); // Go back to the views page and check if this view is there. $this->drupalGet('admin/structure/views'); - $this->assertText($view3['label']); - $this->assertText($view3['description']); + $this->assertSession()->pageTextContains($view3['label']); + $this->assertSession()->pageTextContains($view3['description']); $this->assertSession()->linkByHrefExists(Url::fromRoute('view.' . $view3['id'] . '.page_1')->toString()); // The view should not have a REST export display. @@ -142,7 +142,7 @@ public function testViewsWizardAndListing() { // Confirm that the block is available in the block administration UI. $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); $this->clickLink('Place block'); - $this->assertText($view3['label']); + $this->assertSession()->pageTextContains($view3['label']); // Place the block. $this->drupalPlaceBlock("views_block:{$view3['id']}-block_1"); @@ -150,7 +150,7 @@ public function testViewsWizardAndListing() { // Visit a random page (not the one that displays the view itself) and look // for the expected node title in the block. $this->drupalGet('user'); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node1->label()); $this->assertNoText($node2->label()); // Make sure the listing page doesn't show disabled default views. diff --git a/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php b/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php index 9d314a2775ea..53c059c098c4 100644 --- a/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php @@ -81,12 +81,12 @@ public function testItemsPerPage() { // Make sure the page display shows the nodes we expect, and that they // appear in the expected order. $this->assertSession()->addressEquals($view['page[path]']); - $this->assertText($view['page[title]']); + $this->assertSession()->pageTextContains($view['page[title]']); $content = $this->getSession()->getPage()->getContent(); - $this->assertText($node5->label()); - $this->assertText($node4->label()); - $this->assertText($node3->label()); - $this->assertText($node2->label()); + $this->assertSession()->pageTextContains($node5->label()); + $this->assertSession()->pageTextContains($node4->label()); + $this->assertSession()->pageTextContains($node3->label()); + $this->assertSession()->pageTextContains($node2->label()); $this->assertNoText($node1->label()); $this->assertNoText($page_node->label()); $pos5 = strpos($content, $node5->label()); @@ -100,7 +100,7 @@ public function testItemsPerPage() { // Confirm that the block is listed in the block administration UI. $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); $this->clickLink('Place block'); - $this->assertText($view['label']); + $this->assertSession()->pageTextContains($view['label']); // Place the block, visit a page that displays the block, and check that the // nodes we expect appear in the correct order. @@ -108,9 +108,9 @@ public function testItemsPerPage() { $this->drupalGet('user'); $content = $this->getSession()->getPage()->getContent(); - $this->assertText($node5->label()); - $this->assertText($node4->label()); - $this->assertText($node3->label()); + $this->assertSession()->pageTextContains($node5->label()); + $this->assertSession()->pageTextContains($node4->label()); + $this->assertSession()->pageTextContains($node3->label()); $this->assertNoText($node2->label()); $this->assertNoText($node1->label()); $this->assertNoText($page_node->label()); diff --git a/core/modules/views/tests/src/Functional/Wizard/SortingTest.php b/core/modules/views/tests/src/Functional/Wizard/SortingTest.php index 62b87df09b30..fcdc8ff33c5a 100644 --- a/core/modules/views/tests/src/Functional/Wizard/SortingTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/SortingTest.php @@ -46,11 +46,11 @@ public function testSorting() { // Make sure the view shows the nodes in the expected order. $this->assertSession()->addressEquals($view1['page[path]']); - $this->assertText($view1['page[title]']); + $this->assertSession()->pageTextContains($view1['page[title]']); $content = $this->getSession()->getPage()->getContent(); - $this->assertText($node1->label()); - $this->assertText($node2->label()); - $this->assertText($node3->label()); + $this->assertSession()->pageTextContains($node1->label()); + $this->assertSession()->pageTextContains($node2->label()); + $this->assertSession()->pageTextContains($node3->label()); $pos1 = strpos($content, $node1->label()); $pos2 = strpos($content, $node2->label()); $pos3 = strpos($content, $node3->label()); @@ -72,11 +72,11 @@ public function testSorting() { // Make sure the view shows the nodes in the expected order. $this->assertSession()->addressEquals($view2['page[path]']); - $this->assertText($view2['page[title]']); + $this->assertSession()->pageTextContains($view2['page[title]']); $content = $this->getSession()->getPage()->getContent(); - $this->assertText($node3->label()); - $this->assertText($node2->label()); - $this->assertText($node1->label()); + $this->assertSession()->pageTextContains($node3->label()); + $this->assertSession()->pageTextContains($node2->label()); + $this->assertSession()->pageTextContains($node1->label()); $pos3 = strpos($content, $node3->label()); $pos2 = strpos($content, $node2->label()); $pos1 = strpos($content, $node1->label()); diff --git a/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php b/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php index c3db15b8d306..bccb30beca07 100644 --- a/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php @@ -160,8 +160,8 @@ public function testTaggedWith() { // ones we don't expect are absent. $this->drupalGet($view1['page[path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($node_tag1_title); - $this->assertText($node_tag1_tag2_title); + $this->assertSession()->pageTextContains($node_tag1_title); + $this->assertSession()->pageTextContains($node_tag1_tag2_title); $this->assertNoText($node_no_tags_title); // Create a view that filters by taxonomy term "tag2". It should show only @@ -181,7 +181,7 @@ public function testTaggedWith() { $this->assertSession()->statusCodeEquals(200); $this->drupalGet($view2['page[path]']); $this->assertNoText($node_tag1_title); - $this->assertText($node_tag1_tag2_title); + $this->assertSession()->pageTextContains($node_tag1_tag2_title); $this->assertNoText($node_no_tags_title); } diff --git a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php index fc5db8ff2f49..0fa30c7c612a 100644 --- a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php +++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php @@ -34,7 +34,7 @@ public function testCacheData() { $this->drupalGet('admin/structure/views/view/test_view/edit'); // Make sure we have 'changes' to the view. $this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], 'Apply'); - $this->assertText('You have unsaved changes.'); + $this->assertSession()->pageTextContains('You have unsaved changes.'); $this->assertEquals($views_admin_user_uid, $temp_store->getMetadata('test_view')->getOwnerId(), 'View cache has been saved.'); $view_cache = $temp_store->get('test_view'); diff --git a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php index f2ce8346cb5d..1a8f12995ae5 100644 --- a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php @@ -65,7 +65,7 @@ public function testDefaultViews() { $this->drupalPostForm('admin/structure/views/view/glossary/edit/page_1', [], 'Save'); $this->drupalGet('glossary'); $this->assertSession()->statusCodeEquals(200); - $this->assertText($new_title); + $this->assertSession()->pageTextContains($new_title); // Save another view in the UI. $this->drupalPostForm('admin/structure/views/nojs/display/archive/page_1/title', [], 'Apply'); @@ -141,7 +141,7 @@ public function testDefaultViews() { // Ensure the view is no longer available. $this->drupalGet($edit_href); $this->assertSession()->statusCodeEquals(404); - $this->assertText('Page not found'); + $this->assertSession()->pageTextContains('Page not found'); // Delete all duplicated Glossary views. $this->drupalGet('admin/structure/views'); @@ -158,7 +158,7 @@ public function testDefaultViews() { $this->submitForm([], 'Delete'); $this->drupalGet('glossary'); $this->assertSession()->statusCodeEquals(404); - $this->assertText('Page not found'); + $this->assertSession()->pageTextContains('Page not found'); } /** diff --git a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php index 25459f13f1f5..4a5852d1d8c8 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php @@ -30,7 +30,7 @@ class DisplayAttachmentTest extends UITestBase { */ public function testAttachmentUI() { $this->drupalGet('admin/structure/views/view/test_attachment_ui/edit/attachment_1'); - $this->assertText('Not defined'); + $this->assertSession()->pageTextContains('Not defined'); $attachment_display_url = 'admin/structure/views/nojs/display/test_attachment_ui/attachment_1/displays'; $this->drupalGet($attachment_display_url); @@ -75,7 +75,7 @@ public function testRemoveAttachedDisplay() { // Open the Page display and create the attachment display. $this->drupalGet($path_prefix . '/page_1'); $this->submitForm([], 'Add Attachment'); - $this->assertText('Not defined'); + $this->assertSession()->pageTextContains('Not defined'); // Attach the Attachment to the Page display. $this->drupalPostForm($attachment_display_url, ['displays[page_1]' => 1], 'Apply'); @@ -94,7 +94,7 @@ public function testRemoveAttachedDisplay() { $this->assertNoText("Plugin ID 'page_1' was not found."); // Check that the attachment is no longer linked to the removed display. - $this->assertText('Not defined'); + $this->assertSession()->pageTextContains('Not defined'); } diff --git a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php index 3efd0099a642..d17d473eace1 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php @@ -132,7 +132,7 @@ public function testDuplicateDisplay() { $this->submitForm([], 'Duplicate as Block'); $this->assertSession()->linkByHrefExists($path_prefix . '/block_1', 0, 'Make sure after duplicating the new display appears in the UI'); $this->assertSession()->addressEquals($path_prefix . '/block_1'); - $this->assertText('Block settings'); + $this->assertSession()->pageTextContains('Block settings'); $this->assertNoText('Page settings'); $this->submitForm([], 'Save'); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php index 0fbbbf7c0231..9a2ed40608f2 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php @@ -51,7 +51,7 @@ protected function checkFeedViewUi($view_name) { // Regression test: ViewListBuilder::getDisplayPaths() did not properly // check whether a DisplayPluginCollection was returned in iterating over // all displays. - $this->assertText($view_name); + $this->assertSession()->pageTextContains($view_name); // Check the attach TO interface. $this->drupalGet('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays'); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index 6a7d5e848f80..cb21c0f7cc0c 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -56,7 +56,7 @@ protected function doBasicPathUITest() { // Add a new page display and check the appearing text. $this->submitForm([], 'Add Page'); - $this->assertText('No path is set'); + $this->assertSession()->pageTextContains('No path is set'); $this->assertSession()->linkNotExists('View page', 'No view page link found on the page.'); // Save a path and make sure the summary appears as expected. @@ -66,7 +66,7 @@ protected function doBasicPathUITest() { $random_path = str_replace(':', '', $random_path); $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $random_path], 'Apply'); - $this->assertText('/' . $random_path); + $this->assertSession()->pageTextContains('/' . $random_path); $display_link_text = t('View @display', ['@display' => 'Page']); $this->assertSession()->linkExists($display_link_text, 0, 'view page link found on the page.'); $this->clickLink($display_link_text); @@ -103,11 +103,11 @@ protected function doAdvancedPathsValidationTest() { $this->drupalPostForm($url, ['path' => '%/magrathea'], 'Apply'); $this->assertSession()->addressEquals($url); - $this->assertText('"%" may not be used for the first segment of a path.'); + $this->assertSession()->pageTextContains('"%" may not be used for the first segment of a path.'); $this->drupalPostForm($url, ['path' => 'user/%1/example'], 'Apply'); $this->assertSession()->addressEquals($url); - $this->assertText("Numeric placeholders may not be used. Please use plain placeholders (%)."); + $this->assertSession()->pageTextContains("Numeric placeholders may not be used. Please use plain placeholders (%)."); } /** @@ -132,15 +132,15 @@ public function testMenuOptions() { // Add an invalid path (only fragment). $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => '#foo'], 'Apply'); - $this->assertText('Path is empty'); + $this->assertSession()->pageTextContains('Path is empty'); // Add an invalid path with a query. $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => 'foo?bar'], 'Apply'); - $this->assertText('No query allowed.'); + $this->assertSession()->pageTextContains('No query allowed.'); // Add an invalid path with just a query. $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => '?bar'], 'Apply'); - $this->assertText('Path is empty'); + $this->assertSession()->pageTextContains('Path is empty'); // Provide a random, valid path string. $random_string = $this->randomMachineName(); @@ -244,7 +244,7 @@ public function testDefaultMenuTabRegression() { 'menu[title]' => 'Menu title', ], 'Apply'); - $this->assertText('Default tab options'); + $this->assertSession()->pageTextContains('Default tab options'); $this->submitForm([ 'tab_options[type]' => 'normal', diff --git a/core/modules/views_ui/tests/src/Functional/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php index 77fdb7171629..197bd3d0e5b3 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php @@ -40,7 +40,7 @@ public function testAddDisplay() { $this->assertNoText('Block 2'); $this->submitForm([], 'Add Block'); - $this->assertText('Block'); + $this->assertSession()->pageTextContains('Block'); $this->assertNoText('Block 2'); } @@ -271,7 +271,7 @@ public function testActionLinks() { public function testHideDisplayOverride() { // Test that the override option appears with two displays. $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title'); - $this->assertText('All displays'); + $this->assertSession()->pageTextContains('All displays'); // Remove a display and test if the override option is hidden. $this->drupalPostForm('admin/structure/views/view/test_display/edit/block_1', [], 'Delete Block'); @@ -283,14 +283,14 @@ public function testHideDisplayOverride() { // Test that the override option is shown when default display is on. \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.default_display', TRUE)->save(); $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title'); - $this->assertText('All displays'); + $this->assertSession()->pageTextContains('All displays'); // Test that the override option is shown if the current display is // overridden so that the option to revert is available. $this->submitForm(['override[dropdown]' => 'page_1'], 'Apply'); \Drupal::configFactory()->getEditable('views.settings')->set('ui.show.default_display', FALSE)->save(); $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title'); - $this->assertText('Revert to default'); + $this->assertSession()->pageTextContains('Revert to default'); } } diff --git a/core/modules/views_ui/tests/src/Functional/DuplicateTest.php b/core/modules/views_ui/tests/src/Functional/DuplicateTest.php index 14ebed2d3871..ce4b7b754954 100644 --- a/core/modules/views_ui/tests/src/Functional/DuplicateTest.php +++ b/core/modules/views_ui/tests/src/Functional/DuplicateTest.php @@ -42,7 +42,7 @@ public function testDuplicateView() { $this->assertSession()->addressEquals('admin/structure/views/view/' . $view['id']); // Assert that the page title is correctly displayed. - $this->assertText($view['label']); + $this->assertSession()->pageTextContains($view['label']); } } diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index 22406faf61d1..496a0c33d09d 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -93,12 +93,12 @@ public function testExposedAdminUi() { $edit = []; $edit['options[expose][identifier]'] = ''; $this->submitForm($edit, 'Apply'); - $this->assertText('The identifier is required if the filter is exposed.'); + $this->assertSession()->pageTextContains('The identifier is required if the filter is exposed.'); $edit = []; $edit['options[expose][identifier]'] = 'value'; $this->submitForm($edit, 'Apply'); - $this->assertText('This identifier is not allowed.'); + $this->assertSession()->pageTextContains('This identifier is not allowed.'); // Now check the sort criteria. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created'); @@ -233,7 +233,7 @@ public function testGroupedFilterAdminUiErrors() { $edit["options[group_info][group_items][1][title]"] = ''; $edit["options[group_info][group_items][1][operator]"] = 'empty'; $this->submitForm($edit, 'Apply'); - $this->assertText($this->groupFormUiErrors['missing_title_empty_operator']); + $this->assertSession()->pageTextContains($this->groupFormUiErrors['missing_title_empty_operator']); // Specify a title without a value. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type'); @@ -242,7 +242,7 @@ public function testGroupedFilterAdminUiErrors() { $edit = []; $edit["options[group_info][group_items][1][title]"] = 'Is Article'; $this->submitForm($edit, 'Apply'); - $this->assertText($this->groupFormUiErrors['missing_value']); + $this->assertSession()->pageTextContains($this->groupFormUiErrors['missing_value']); // Specify a value without a title. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type'); @@ -250,7 +250,7 @@ public function testGroupedFilterAdminUiErrors() { $edit["options[group_info][group_items][1][title]"] = ''; $edit["options[group_info][group_items][1][value][article]"] = 'article'; $this->submitForm($edit, 'Apply'); - $this->assertText($this->groupFormUiErrors['missing_title']); + $this->assertSession()->pageTextContains($this->groupFormUiErrors['missing_title']); } /** diff --git a/core/modules/views_ui/tests/src/Functional/FieldUITest.php b/core/modules/views_ui/tests/src/Functional/FieldUITest.php index c03abce18cef..bf88bdc8a40a 100644 --- a/core/modules/views_ui/tests/src/Functional/FieldUITest.php +++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php @@ -31,7 +31,7 @@ class FieldUITest extends UITestBase { public function testFieldUI() { // Ensure the field is not marked as hidden on the first run. $this->drupalGet('admin/structure/views/view/test_view/edit'); - $this->assertText('Views test: Name'); + $this->assertSession()->pageTextContains('Views test: Name'); $this->assertSession()->pageTextNotContains('Views test: Name [hidden]'); // Hides the field and check whether the hidden label is appended. diff --git a/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php index 922dfdddf158..80b58d52b00d 100644 --- a/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php +++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php @@ -64,16 +64,16 @@ public function testFilterNumericUI() { // Test that the exposed filter works as expected. $this->drupalGet('test_view-path'); - $this->assertText('John'); - $this->assertText('Paul'); - $this->assertText('Ringo'); - $this->assertText('George'); - $this->assertText('Meredith'); + $this->assertSession()->pageTextContains('John'); + $this->assertSession()->pageTextContains('Paul'); + $this->assertSession()->pageTextContains('Ringo'); + $this->assertSession()->pageTextContains('George'); + $this->assertSession()->pageTextContains('Meredith'); $this->submitForm(['age' => '2'], 'Apply'); - $this->assertText('John'); - $this->assertText('Paul'); + $this->assertSession()->pageTextContains('John'); + $this->assertSession()->pageTextContains('Paul'); $this->assertNoText('Ringo'); - $this->assertText('George'); + $this->assertSession()->pageTextContains('George'); $this->assertNoText('Meredith'); // Change the filter to a single filter to test the schema when the operator @@ -87,14 +87,14 @@ public function testFilterNumericUI() { // Test that the filter works as expected. $this->drupalGet('test_view-path'); - $this->assertText('John'); + $this->assertSession()->pageTextContains('John'); $this->assertNoText('Paul'); $this->assertNoText('Ringo'); $this->assertNoText('George'); $this->assertNoText('Meredith'); $this->submitForm(['age' => '26'], 'Apply'); $this->assertNoText('John'); - $this->assertText('Paul'); + $this->assertSession()->pageTextContains('Paul'); $this->assertNoText('Ringo'); $this->assertNoText('George'); $this->assertNoText('Meredith'); diff --git a/core/modules/views_ui/tests/src/Functional/FilterUITest.php b/core/modules/views_ui/tests/src/Functional/FilterUITest.php index 09a7f198a9c4..9faae35096cf 100644 --- a/core/modules/views_ui/tests/src/Functional/FilterUITest.php +++ b/core/modules/views_ui/tests/src/Functional/FilterUITest.php @@ -114,14 +114,14 @@ public function testFilterIdentifier() { 'options[expose][identifier]' => '', ]; $this->drupalPostForm($path, $edit, 'Apply'); - $this->assertText('The identifier is required if the filter is exposed.'); + $this->assertSession()->pageTextContains('The identifier is required if the filter is exposed.'); // Set the identifier to 'value'. $edit = [ 'options[expose][identifier]' => 'value', ]; $this->drupalPostForm($path, $edit, 'Apply'); - $this->assertText('This identifier is not allowed.'); + $this->assertSession()->pageTextContains('This identifier is not allowed.'); // Try a few restricted values for the identifier. foreach (['value value', 'value^value'] as $identifier) { @@ -129,7 +129,7 @@ public function testFilterIdentifier() { 'options[expose][identifier]' => $identifier, ]; $this->drupalPostForm($path, $edit, 'Apply'); - $this->assertText('This identifier has illegal characters.'); + $this->assertSession()->pageTextContains('This identifier has illegal characters.'); } } diff --git a/core/modules/views_ui/tests/src/Functional/HandlerTest.php b/core/modules/views_ui/tests/src/Functional/HandlerTest.php index 7c3ae2507c3e..36b1bc3cc837 100644 --- a/core/modules/views_ui/tests/src/Functional/HandlerTest.php +++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php @@ -233,7 +233,7 @@ public function testBrokenHandlers() { ]; foreach ($original_configuration as $key => $value) { - $this->assertText($key . ': ' . $value); + $this->assertSession()->pageTextContains($key . ': ' . $value); } } } diff --git a/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php index b8bc37dd4be5..55c45d9dc3a2 100644 --- a/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php +++ b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php @@ -52,19 +52,19 @@ public function testOverrideDisplays() { // Make sure the title appears in the page. $this->drupalGet($view_path); $this->assertSession()->statusCodeEquals(200); - $this->assertText($original_title); + $this->assertSession()->pageTextContains($original_title); // Confirm that the view block is available in the block administration UI. $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); $this->clickLink('Place block'); - $this->assertText($view['label']); + $this->assertSession()->pageTextContains($view['label']); // Place the block. $this->drupalPlaceBlock("views_block:{$view['id']}-block_1"); // Make sure the title appears in the block. $this->drupalGet(''); - $this->assertText($original_title); + $this->assertSession()->pageTextContains($original_title); // Change the title for the page display only, and make sure that the // original title still appears on the page. @@ -75,8 +75,8 @@ public function testOverrideDisplays() { $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], 'Save'); $this->drupalGet($view_path); $this->assertSession()->statusCodeEquals(200); - $this->assertText($new_title); - $this->assertText($original_title); + $this->assertSession()->pageTextContains($new_title); + $this->assertSession()->pageTextContains($original_title); } /** @@ -107,17 +107,17 @@ public function testWizardMixedDefaultOverriddenDisplays() { // titles. $this->drupalGet($view['page[path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($view['page[title]']); + $this->assertSession()->pageTextContains($view['page[title]']); $this->assertNoText($view['block[title]']); $this->drupalGet($view['page[feed_properties][path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($view['page[title]']); + $this->assertSession()->responseContains($view['page[title]']); $this->assertNoText($view['block[title]']); // Confirm that the block is available in the block administration UI. $this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default')); $this->clickLink('Place block'); - $this->assertText($view['label']); + $this->assertSession()->pageTextContains($view['label']); // Put the block into the first sidebar region, and make sure it will not // display on the view's page display (since we will be searching for the @@ -132,7 +132,7 @@ public function testWizardMixedDefaultOverriddenDisplays() { ]); $this->drupalGet(''); - $this->assertText($view['block[title]']); + $this->assertSession()->pageTextContains($view['block[title]']); $this->assertNoText($view['page[title]']); // Edit the page and change the title. This should automatically change @@ -143,18 +143,18 @@ public function testWizardMixedDefaultOverriddenDisplays() { $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], 'Save'); $this->drupalGet($view['page[path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($new_default_title); + $this->assertSession()->pageTextContains($new_default_title); $this->assertNoText($view['page[title]']); $this->assertNoText($view['block[title]']); $this->drupalGet($view['page[feed_properties][path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($new_default_title); + $this->assertSession()->responseContains($new_default_title); $this->assertNoText($view['page[title]']); $this->assertNoText($view['block[title]']); $this->drupalGet(''); $this->assertNoText($new_default_title); $this->assertNoText($view['page[title]']); - $this->assertText($view['block[title]']); + $this->assertSession()->pageTextContains($view['block[title]']); // Edit the block and change the title. This should automatically change // the block title only, and leave the defaults alone. @@ -164,13 +164,13 @@ public function testWizardMixedDefaultOverriddenDisplays() { $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], 'Save'); $this->drupalGet($view['page[path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($new_default_title); + $this->assertSession()->pageTextContains($new_default_title); $this->drupalGet($view['page[feed_properties][path]']); $this->assertSession()->statusCodeEquals(200); - $this->assertText($new_default_title); + $this->assertSession()->responseContains($new_default_title); $this->assertNoText($new_block_title); $this->drupalGet(''); - $this->assertText($new_block_title); + $this->assertSession()->pageTextContains($new_block_title); $this->assertNoText($view['block[title]']); } @@ -198,7 +198,7 @@ public function testRevertAllDisplays() { $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, 'Apply'); $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], 'Save'); - $this->assertText($view['page[title]']); + $this->assertSession()->pageTextContains($view['page[title]']); } } diff --git a/core/modules/views_ui/tests/src/Functional/PreviewTest.php b/core/modules/views_ui/tests/src/Functional/PreviewTest.php index 44cc27141e57..72b273eed48a 100644 --- a/core/modules/views_ui/tests/src/Functional/PreviewTest.php +++ b/core/modules/views_ui/tests/src/Functional/PreviewTest.php @@ -39,9 +39,9 @@ public function testPreviewContextual() { // Test that area text and exposed filters are present and rendered. $this->assertSession()->fieldExists('id'); - $this->assertText('Test header text'); - $this->assertText('Test footer text'); - $this->assertText('Test empty text'); + $this->assertSession()->pageTextContains('Test header text'); + $this->assertSession()->pageTextContains('Test footer text'); + $this->assertSession()->pageTextContains('Test empty text'); } /** @@ -65,9 +65,9 @@ public function testPreviewUI() { // Test that area text and exposed filters are present and rendered. $this->assertSession()->fieldExists('id'); - $this->assertText('Test header text'); - $this->assertText('Test footer text'); - $this->assertText('Test empty text'); + $this->assertSession()->pageTextContains('Test header text'); + $this->assertSession()->pageTextContains('Test footer text'); + $this->assertSession()->pageTextContains('Test empty text'); // Test feed preview. $view = []; @@ -89,17 +89,17 @@ public function testPreviewUI() { $settings->set('ui.show.performance_statistics', TRUE)->save(); $this->drupalGet('admin/structure/views/view/test_preview/edit'); $this->submitForm($edit = ['view_args' => '100'], 'Update preview'); - $this->assertText('Query build time'); - $this->assertText('Query execute time'); - $this->assertText('View render time'); + $this->assertSession()->pageTextContains('Query build time'); + $this->assertSession()->pageTextContains('Query execute time'); + $this->assertSession()->pageTextContains('View render time'); $this->assertNoRaw('<strong>Query</strong>'); // Statistics and query. $settings->set('ui.show.sql_query.enabled', TRUE)->save(); $this->submitForm($edit = ['view_args' => '100'], 'Update preview'); - $this->assertText('Query build time'); - $this->assertText('Query execute time'); - $this->assertText('View render time'); + $this->assertSession()->pageTextContains('Query build time'); + $this->assertSession()->pageTextContains('Query execute time'); + $this->assertSession()->pageTextContains('View render time'); $this->assertRaw('<strong>Query</strong>'); $query_string = <<<SQL SELECT "views_test_data"."name" AS "views_test_data_name" @@ -153,7 +153,7 @@ public function testPreviewError() { $this->submitForm($edit = [], 'Update preview'); - $this->assertText('Unable to preview due to validation errors.'); + $this->assertSession()->pageTextContains('Unable to preview due to validation errors.'); } } diff --git a/core/modules/views_ui/tests/src/Functional/SettingsTest.php b/core/modules/views_ui/tests/src/Functional/SettingsTest.php index de10b1926893..9017502d342b 100644 --- a/core/modules/views_ui/tests/src/Functional/SettingsTest.php +++ b/core/modules/views_ui/tests/src/Functional/SettingsTest.php @@ -43,7 +43,7 @@ public function testEditUI() { // Test the confirmation message. $this->drupalPostForm('admin/structure/views/settings', [], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); // Configure to always show the default display. $edit = [ @@ -133,7 +133,7 @@ public function testEditUI() { // Test the confirmation message. $this->drupalPostForm('admin/structure/views/settings/advanced', [], 'Save configuration'); - $this->assertText('The configuration options have been saved.'); + $this->assertSession()->pageTextContains('The configuration options have been saved.'); $edit = [ 'skip_cache' => TRUE, @@ -146,7 +146,7 @@ public function testEditUI() { // Test the "Clear Views' cache" button. $this->drupalPostForm('admin/structure/views/settings/advanced', [], "Clear Views' cache"); - $this->assertText('The cache has been cleared.'); + $this->assertSession()->pageTextContains('The cache has been cleared.'); } } diff --git a/core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php b/core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php index 673295322f39..6a6d34dc66ff 100644 --- a/core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php +++ b/core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php @@ -42,9 +42,9 @@ public function testTokenUI() { $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.area]' => 'views.area'], 'Add and configure header'); // Test that field tokens are shown. - $this->assertText('{{ title }} == Content: Title'); + $this->assertSession()->pageTextContains('{{ title }} == Content: Title'); // Test that argument tokens are shown. - $this->assertText('{{ arguments.null }} == Global: Null title'); + $this->assertSession()->pageTextContains('{{ arguments.null }} == Global: Null title'); } } diff --git a/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php index 5ff5e10a9ed1..46589eb9375d 100644 --- a/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php +++ b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php @@ -66,7 +66,7 @@ public function testUnsavedPageDisplayPreview() { $this->submitForm([], 'Update preview'); $this->assertSession()->statusCodeEquals(200); - $this->assertText('This display has no path'); + $this->assertSession()->pageTextContains('This display has no path'); $this->drupalGet('admin/structure/views/view/content/edit/page_2'); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php index 3b17980aacde..fb3dcf24df9b 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php @@ -54,7 +54,7 @@ public function testOtherOptions() { // Test that a long administrative comment is truncated. $edit = ['display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen']; $this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply'); - $this->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...'); + $this->assertSession()->pageTextContains('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...'); // Change the machine name for the display from page_1 to test_1. $edit = ['display_id' => 'test_1']; @@ -90,16 +90,16 @@ public function testOtherOptions() { $edit = ['display_id' => 'test 1']; $this->drupalPostForm($machine_name_edit_url, $edit, 'Apply'); - $this->assertText($error_text); + $this->assertSession()->pageTextContains($error_text); $edit = ['display_id' => 'test_1#']; $this->drupalPostForm($machine_name_edit_url, $edit, 'Apply'); - $this->assertText($error_text); + $this->assertSession()->pageTextContains($error_text); // Test using an existing display ID. $edit = ['display_id' => 'default']; $this->drupalPostForm($machine_name_edit_url, $edit, 'Apply'); - $this->assertText('Display id should be unique.'); + $this->assertSession()->pageTextContains('Display id should be unique.'); // Test that the display ID has not been changed. $this->drupalGet('admin/structure/views/view/test_view/edit/test_1'); @@ -166,7 +166,7 @@ public function testEditFormLanguageOptions() { $this->drupalGet($langcode_url); $this->assertSession()->statusCodeEquals(200); if ($view_name == 'test_view') { - $this->assertText('The view is not based on a translatable entity type or the site is not multilingual.'); + $this->assertSession()->pageTextContains('The view is not based on a translatable entity type or the site is not multilingual.'); } else { $this->assertSession()->fieldValueEquals('rendering_language', '***LANGUAGE_entity_translation***'); diff --git a/core/modules/views_ui/tests/src/Functional/WizardTest.php b/core/modules/views_ui/tests/src/Functional/WizardTest.php index a4dc443fbe3e..1eada2bbc33d 100644 --- a/core/modules/views_ui/tests/src/Functional/WizardTest.php +++ b/core/modules/views_ui/tests/src/Functional/WizardTest.php @@ -38,13 +38,13 @@ public function testWizardFieldLength() { $this->drupalPostForm('admin/structure/views/add', $view, 'Save and edit'); - $this->assertText('Machine-readable name cannot be longer than 128 characters but is currently 129 characters long.'); - $this->assertText('Path cannot be longer than 254 characters but is currently 255 characters long.'); - $this->assertText('Page title cannot be longer than 255 characters but is currently 256 characters long.'); - $this->assertText('View name cannot be longer than 255 characters but is currently 256 characters long.'); - $this->assertText('Feed path cannot be longer than 254 characters but is currently 255 characters long.'); - $this->assertText('Block title cannot be longer than 255 characters but is currently 256 characters long.'); - $this->assertText('REST export path cannot be longer than 254 characters but is currently 255 characters long.'); + $this->assertSession()->pageTextContains('Machine-readable name cannot be longer than 128 characters but is currently 129 characters long.'); + $this->assertSession()->pageTextContains('Path cannot be longer than 254 characters but is currently 255 characters long.'); + $this->assertSession()->pageTextContains('Page title cannot be longer than 255 characters but is currently 256 characters long.'); + $this->assertSession()->pageTextContains('View name cannot be longer than 255 characters but is currently 256 characters long.'); + $this->assertSession()->pageTextContains('Feed path cannot be longer than 254 characters but is currently 255 characters long.'); + $this->assertSession()->pageTextContains('Block title cannot be longer than 255 characters but is currently 256 characters long.'); + $this->assertSession()->pageTextContains('REST export path cannot be longer than 254 characters but is currently 255 characters long.'); $view['label'] = $this->randomMachineName(255); $view['id'] = strtolower($this->randomMachineName(128)); @@ -63,7 +63,7 @@ public function testWizardFieldLength() { $this->drupalPostForm('admin/structure/views/add', $view, 'Save and edit'); $this->assertSession()->addressEquals('admin/structure/views/view/' . $view['id']); // Assert that the page title is correctly truncated. - $this->assertText(views_ui_truncate($view['page[title]'], 32)); + $this->assertSession()->pageTextContains(views_ui_truncate($view['page[title]'], 32)); } } diff --git a/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php b/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php index 0091631649d5..99a9ce7164f2 100644 --- a/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php +++ b/core/modules/workspaces/tests/src/Functional/WorkspaceTest.php @@ -180,11 +180,11 @@ public function testWorkspaceFieldUi() { // Check that the field is displayed on the manage form display page. $this->drupalGet('admin/config/workflow/workspaces/form-display'); - $this->assertText($field_label); + $this->assertSession()->pageTextContains($field_label); // Check that the field is displayed on the manage display page. $this->drupalGet('admin/config/workflow/workspaces/display'); - $this->assertText($field_label); + $this->assertSession()->pageTextContains($field_label); } /** diff --git a/core/profiles/minimal/tests/src/Functional/MinimalTest.php b/core/profiles/minimal/tests/src/Functional/MinimalTest.php index 02e6ec7abaac..44b0aae80a8c 100644 --- a/core/profiles/minimal/tests/src/Functional/MinimalTest.php +++ b/core/profiles/minimal/tests/src/Functional/MinimalTest.php @@ -39,15 +39,15 @@ public function testMinimal() { ]); $this->drupalLogin($user); $this->drupalGet(''); - $this->assertText('Tools'); - $this->assertText('Administration'); + $this->assertSession()->pageTextContains('Tools'); + $this->assertSession()->pageTextContains('Administration'); // Ensure that there are no pending updates after installation. $this->drupalLogin($this->rootUser); $this->drupalGet('update.php/selection'); $this->updateRequirementsProblem(); $this->drupalGet('update.php/selection'); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); // Ensure that there are no pending entity updates after installation. $this->assertFalse($this->container->get('entity.definition_update_manager')->needsUpdates(), 'After installation, entity schema is up to date.'); diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php index d5d3b74ec5e2..0f071645b597 100644 --- a/core/profiles/standard/tests/src/Functional/StandardTest.php +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php @@ -59,7 +59,7 @@ public function testStandard() { ], 'Save block'); // Verify admin user can see the block. $this->drupalGet(''); - $this->assertText('Main navigation'); + $this->assertSession()->pageTextContains('Main navigation'); // Verify we have role = complementary on help_block blocks. $this->drupalGet('admin/structure/block'); @@ -67,7 +67,7 @@ public function testStandard() { // Verify anonymous user can see the block. $this->drupalLogout(); - $this->assertText('Main navigation'); + $this->assertSession()->pageTextContains('Main navigation'); // Ensure comments don't show in the front page RSS feed. // Create an article. @@ -90,7 +90,7 @@ public function testStandard() { ], 'Save'); // Fetch the feed. $this->drupalGet('rss.xml'); - $this->assertText('Foobar'); + $this->assertSession()->responseContains('Foobar'); $this->assertNoText('Then she picked out two somebodies, Sally and me'); // Ensure block body exists. @@ -148,7 +148,7 @@ public function testStandard() { $this->drupalGet('update.php/selection'); $this->updateRequirementsProblem(); $this->drupalGet('update.php/selection'); - $this->assertText('No pending updates.'); + $this->assertSession()->pageTextContains('No pending updates.'); // Ensure that there are no pending entity updates after installation. $this->assertFalse($this->container->get('entity.definition_update_manager')->needsUpdates(), 'After installation, entity schema is up to date.'); @@ -165,10 +165,10 @@ public function testStandard() { \Drupal::service('module_installer')->install(['responsive_image']); $this->rebuildContainer(); $this->drupalGet('admin/config/media/image-styles'); - $this->assertText('Max 325x325'); - $this->assertText('Max 650x650'); - $this->assertText('Max 1300x1300'); - $this->assertText('Max 2600x2600'); + $this->assertSession()->pageTextContains('Max 325x325'); + $this->assertSession()->pageTextContains('Max 650x650'); + $this->assertSession()->pageTextContains('Max 1300x1300'); + $this->assertSession()->pageTextContains('Max 2600x2600'); // Verify certain routes' responses are cacheable by Dynamic Page Cache, to // ensure these responses are very fast for authenticated users. @@ -211,14 +211,14 @@ public function testStandard() { $this->adminUser->save(); $this->rebuildContainer(); $this->drupalGet('admin/config/workflow/workflows/manage/editorial'); - $this->assertText('Draft'); - $this->assertText('Published'); - $this->assertText('Archived'); - $this->assertText('Create New Draft'); - $this->assertText('Publish'); - $this->assertText('Archive'); - $this->assertText('Restore to Draft'); - $this->assertText('Restore'); + $this->assertSession()->pageTextContains('Draft'); + $this->assertSession()->pageTextContains('Published'); + $this->assertSession()->pageTextContains('Archived'); + $this->assertSession()->pageTextContains('Create New Draft'); + $this->assertSession()->pageTextContains('Publish'); + $this->assertSession()->pageTextContains('Archive'); + $this->assertSession()->pageTextContains('Restore to Draft'); + $this->assertSession()->pageTextContains('Restore'); \Drupal::service('module_installer')->install(['media']); $role = Role::create([ diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index c34c61f10656..bfb5f1da4700 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -297,7 +297,7 @@ public function testTextAsserts() { $dangerous = 'Bad html <script>alert(123);</script>'; $sanitized = Html::escape($dangerous); $this->assertNoText($dangerous); - $this->assertText($sanitized); + $this->assertSession()->responseContains($sanitized); } /** @@ -317,6 +317,7 @@ public function testAssertPattern() { * @group legacy */ public function testAssertText() { + $this->expectDeprecation('AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738'); $this->expectDeprecation('Calling AssertLegacyTrait::assertText() with more than one argument is deprecated in drupal:8.2.0 and the method is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738'); $this->drupalGet('test-encoded'); $dangerous = 'Bad html <script>alert(123);</script>'; diff --git a/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php b/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php index 1ff7a9660f7c..505ea6672dfc 100644 --- a/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php +++ b/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php @@ -65,7 +65,7 @@ public function testToolkitSetupForm() { // Test changing the test toolkit parameter. $edit = ['test[test_parameter]' => '0']; $this->submitForm($edit, 'Save configuration'); - $this->assertText('Test parameter should be different from 0.'); + $this->assertSession()->pageTextContains('Test parameter should be different from 0.'); $edit = ['test[test_parameter]' => '20']; $this->submitForm($edit, 'Save configuration'); $this->assertEquals('20', $this->config('system.image.test_toolkit')->get('test_parameter')); diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php index 08481c916333..41721e87b3a0 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php @@ -117,7 +117,7 @@ public function testInstalled() { $this->assertSession()->addressEquals('user/1'); $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getAccountName()); + $this->assertSession()->pageTextContains($this->rootUser->getAccountName()); // Confirm that Drupal recognizes this distribution as the current profile. $this->assertEquals('my_distro', \Drupal::installProfile()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php index b97f26ee4aad..5bd8d6d7969a 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php @@ -74,7 +74,7 @@ public function testInstalled() { $this->assertSession()->addressEquals('root-user'); $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getAccountName()); + $this->assertSession()->pageTextContains($this->rootUser->getAccountName()); // Confirm that Drupal recognizes this distribution as the current profile. $this->assertEquals('my_distro', \Drupal::installProfile()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php index 8fef2671a8ce..2ca5c9ea5069 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php @@ -114,11 +114,11 @@ public function testInstalled() { $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getDisplayName()); + $this->assertSession()->pageTextContains($this->rootUser->getDisplayName()); // Verify German was configured but not English. $this->drupalGet('admin/config/regional/language'); - $this->assertText('German'); + $this->assertSession()->pageTextContains('German'); $this->assertNoText('English'); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php index d6719fd53bd9..6a4712adab4d 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php @@ -105,11 +105,11 @@ public function testInstalled() { $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getDisplayName()); + $this->assertSession()->pageTextContains($this->rootUser->getDisplayName()); // Verify German was configured but not English. $this->drupalGet('admin/config/regional/language'); - $this->assertText('German'); + $this->assertSession()->pageTextContains('German'); $this->assertNoText('English'); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php index 76109a72198e..ece3bed7f528 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php @@ -59,7 +59,7 @@ protected function setUpSite() { * Verifies that installation failed. */ public function testError() { - $this->assertText("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem."); + $this->assertSession()->pageTextContains("An automated attempt to create the directory {$this->configDirectory}/sync failed, possibly due to a permissions problem."); $this->assertDirectoryNotExists($this->configDirectory . '/sync'); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php index 9cceb3ea1d92..acdb6b22de5d 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoConfigTest.php @@ -35,8 +35,8 @@ protected function getConfigTarball() { */ public function testConfigSync() { $this->assertSession()->titleEquals('Configuration validation | Drupal'); - $this->assertText('The configuration synchronization failed validation.'); - $this->assertText('This import is empty and if applied would delete all of your configuration, so has been rejected.'); + $this->assertSession()->pageTextContains('The configuration synchronization failed validation.'); + $this->assertSession()->pageTextContains('This import is empty and if applied would delete all of your configuration, so has been rejected.'); // Ensure there is no continuation button. $this->assertNoText('Save and continue'); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php index 175d2dac6339..bc1483da612d 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigNoSystemSiteTest.php @@ -31,8 +31,8 @@ public function setUpSite() { public function testConfigSync() { $this->htmlOutput(NULL); $this->assertSession()->titleEquals('Configuration validation | Drupal'); - $this->assertText('The configuration synchronization failed validation.'); - $this->assertText('This import does not contain system.site configuration, so has been rejected.'); + $this->assertSession()->pageTextContains('The configuration synchronization failed validation.'); + $this->assertSession()->pageTextContains('This import does not contain system.site configuration, so has been rejected.'); // Ensure there is no continuation button. $this->assertNoText('Save and continue'); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php index e89b36a31e23..51d0773d4761 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigProfileHookInstall.php @@ -55,8 +55,8 @@ protected function getConfigTarball() { */ public function testConfigSync() { $this->assertSession()->titleEquals('Requirements problem | Drupal'); - $this->assertText($this->profile); - $this->assertText('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.'); + $this->assertSession()->pageTextContains($this->profile); + $this->assertSession()->pageTextContains('The selected profile has a hook_install() implementation and therefore can not be installed from configuration.'); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDriectoryProfileMismatchTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDriectoryProfileMismatchTest.php index 197e84ab0688..3af52960667a 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDriectoryProfileMismatchTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigSyncDriectoryProfileMismatchTest.php @@ -50,8 +50,8 @@ protected function setUpSite() { public function testConfigSync() { $this->htmlOutput(NULL); $this->assertSession()->titleEquals('Configuration validation | Drupal'); - $this->assertText('The configuration synchronization failed validation.'); - $this->assertText('The selected installation profile minimal does not match the profile stored in configuration testing_config_install_multilingual.'); + $this->assertSession()->pageTextContains('The configuration synchronization failed validation.'); + $this->assertSession()->pageTextContains('The selected installation profile minimal does not match the profile stored in configuration testing_config_install_multilingual.'); // Ensure there is no continuation button. $this->assertNoText('Save and continue'); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php index 95e0ae9b551f..e720386d7fa6 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonEnglishProfileWithoutLocaleModuleTest.php @@ -63,7 +63,7 @@ public function testNonEnglishProfileWithoutLocaleModule() { $this->assertSession()->statusCodeEquals(200); $this->assertSession()->addressEquals('user/1'); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getAccountName()); + $this->assertSession()->pageTextContains($this->rootUser->getAccountName()); // Verify that the confirmation message appears. require_once $this->root . '/core/includes/install.inc'; diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerPostInstallTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerPostInstallTest.php index 5730ae9e3a0f..dfbecf676021 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerPostInstallTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerPostInstallTest.php @@ -28,13 +28,13 @@ public function testVisitInstallerPostInstall() { $this->resetAll(); // Confirm that the install_profile is correct. $this->drupalGet('/system-test/get-install-profile'); - $this->assertText('minimal'); + $this->assertSession()->pageTextContains('minimal'); // Make an anonymous visit to the installer $this->drupalLogout(); $this->visitInstaller(); // Ensure that the install profile is still correct. $this->drupalGet('/system-test/get-install-profile'); - $this->assertText('minimal'); + $this->assertSession()->pageTextContains('minimal'); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php index 4a8314ca73eb..f7cb5b0f316b 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php @@ -25,7 +25,7 @@ public function testInstaller() { $this->assertSession()->addressEquals('user/1'); $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getAccountName()); + $this->assertSession()->pageTextContains($this->rootUser->getAccountName()); // Verify that the confirmation message appears. require_once $this->root . '/core/includes/install.inc'; diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php index d9eb58803edf..adea0f09a98b 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationMultipleLanguageTest.php @@ -80,13 +80,13 @@ public function testTranslationsLoaded() { // Verify German and Spanish were configured. $this->drupalGet('admin/config/regional/language'); - $this->assertText('German'); - $this->assertText('Spanish'); + $this->assertSession()->pageTextContains('German'); + $this->assertSession()->pageTextContains('Spanish'); // If the installer was English or we used a profile that keeps English, we // expect that configured also. Otherwise English should not be configured // on the site. if ($this->langcode == 'en' || $this->profile == 'testing_multilingual_with_english') { - $this->assertText('English'); + $this->assertSession()->pageTextContains('English'); } else { $this->assertNoText('English'); @@ -174,7 +174,7 @@ protected function verifyImportedStringsTranslated() { $edit['translation'] = 'translated'; $edit['string'] = $sample; $this->drupalPostForm('admin/config/regional/translate', $edit, 'Filter'); - $this->assertText($sample . ' ' . $langcode); + $this->assertSession()->pageTextContains($sample . ' ' . $langcode); } } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php index 20e8080ef11d..6c20e5426adc 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php @@ -62,7 +62,7 @@ public function testInstaller() { // Verify German was configured but not English. $this->drupalGet('admin/config/regional/language'); - $this->assertText('German'); + $this->assertSession()->pageTextContains('German'); $this->assertNoText('English'); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php index f94a2516ed0b..7c82459f1296 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php @@ -85,7 +85,7 @@ public function testInstaller() { // Verify German was configured but not English. $this->drupalGet('admin/config/regional/language'); - $this->assertText('German'); + $this->assertSession()->pageTextContains('German'); $this->assertNoText('English'); // The current container still has the english as current language, rebuild. @@ -116,7 +116,7 @@ public function testInstaller() { $edit['translation'] = 'translated'; $edit['string'] = $sample; $this->drupalPostForm('admin/config/regional/translate', $edit, 'Filter'); - $this->assertText($sample . ' de'); + $this->assertSession()->pageTextContains($sample . ' de'); } /** @var \Drupal\language\ConfigurableLanguageManager $language_manager */ diff --git a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php index 84f92a95cf51..1cf2aa589d8a 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php @@ -78,7 +78,7 @@ public function testInstalled() { $this->assertSession()->addressEquals('user/1'); $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getAccountName()); + $this->assertSession()->pageTextContains($this->rootUser->getAccountName()); // Confirm that Drupal recognizes this distribution as the current profile. $this->assertEquals('distribution_one', \Drupal::installProfile()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php index ee2f60597dd7..816aa46bed2f 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php @@ -59,7 +59,7 @@ public function testInstalled() { $this->assertSession()->addressEquals('user/1'); $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. - $this->assertText($this->rootUser->getAccountName()); + $this->assertSession()->pageTextContains($this->rootUser->getAccountName()); // Confirm that the minimal profile was installed. $this->assertEquals('minimal', \Drupal::installProfile()); } diff --git a/core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php b/core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php index 33b4d61ba386..78844ad89969 100644 --- a/core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php +++ b/core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php @@ -67,7 +67,7 @@ public function testIsUninstallable() { $this->drupalGet('admin/appearance'); $this->cssSelect('a[title="Install Seven as default theme"]')[0]->click(); $this->cssSelect('a[title="Uninstall Claro theme"]')[0]->click(); - $this->assertText('The Claro theme has been uninstalled.'); + $this->assertSession()->pageTextContains('The Claro theme has been uninstalled.'); } } diff --git a/core/tests/Drupal/FunctionalTests/Theme/OliveroTest.php b/core/tests/Drupal/FunctionalTests/Theme/OliveroTest.php index c8098bd5acce..1668bf253131 100644 --- a/core/tests/Drupal/FunctionalTests/Theme/OliveroTest.php +++ b/core/tests/Drupal/FunctionalTests/Theme/OliveroTest.php @@ -84,7 +84,7 @@ public function testIsUninstallable() { $this->drupalGet('admin/appearance'); $this->cssSelect('a[title="Install Bartik as default theme"]')[0]->click(); $this->cssSelect('a[title="Uninstall Olivero theme"]')[0]->click(); - $this->assertText('The Olivero theme has been uninstalled.'); + $this->assertSession()->pageTextContains('The Olivero theme has been uninstalled.'); } } diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php index 547cbb3c2963..4ad49c4c1f95 100644 --- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php @@ -66,7 +66,7 @@ public function testDatabaseLoaded() { $this->assertEquals('standard', \Drupal::config('core.extension')->get('profile')); $this->assertEquals('Site-Install', \Drupal::config('system.site')->get('name')); $this->drupalGet('<front>'); - $this->assertText('Site-Install'); + $this->assertSession()->pageTextContains('Site-Install'); // Ensure that the database tasks have been run during set up. Neither MySQL // nor SQLite make changes that are testable. diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 44d8f9d266ae..8d495121e794 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -121,7 +121,6 @@ public static function getSkippedDeprecations() { "The \"PHPUnit\Framework\TestSuite\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\TestSuites\TestSuiteBase\".", // Simpletest's legacy assertion methods. 'UiHelperTrait::drupalPostForm() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use $this->submitForm() instead. See https://www.drupal.org/node/3168858', - 'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() instead. See https://www.drupal.org/node/3129738', -- GitLab