diff --git a/modules/flag_bookmark/tests/src/FunctionalJavascript/FlagBookmarkUITest.php b/modules/flag_bookmark/tests/src/FunctionalJavascript/FlagBookmarkUITest.php index 9c8b9e7..d4796da 100644 --- a/modules/flag_bookmark/tests/src/FunctionalJavascript/FlagBookmarkUITest.php +++ b/modules/flag_bookmark/tests/src/FunctionalJavascript/FlagBookmarkUITest.php @@ -75,7 +75,7 @@ class FlagBookmarkUITest extends JavascriptTestBase { ]); $this->drupalLogin($admin_user); - $flag_service = \Drupal::service('flag'); + $flag_service = $this->container->get('flag'); $bookmark_flag = $flag_service->getFlagById('bookmark'); // Flag the articles. diff --git a/src/Tests/LinkTypeConfirmFormTest.php b/src/Tests/LinkTypeConfirmFormTest.php index 7950217..acd69db 100644 --- a/src/Tests/LinkTypeConfirmFormTest.php +++ b/src/Tests/LinkTypeConfirmFormTest.php @@ -82,8 +82,11 @@ class LinkTypeConfirmFormTest extends FlagTestBase { $user_1 = $this->drupalCreateUser(); $this->drupalLogin($user_1); + /** @var \Drupal\Core\Database\Connection $database */ + $database = $this->container->get('database'); + // Get the flag count before the flagging, querying the database directly. - $flag_count_pre = \Drupal::database()->query('SELECT count FROM {flag_counts} + $flag_count_pre = $database->query('SELECT count FROM {flag_counts} WHERE flag_id = :flag_id AND entity_type = :entity_type AND entity_id = :entity_id', [ ':flag_id' => $flag_id, ':entity_type' => 'node', @@ -106,7 +109,7 @@ class LinkTypeConfirmFormTest extends FlagTestBase { $this->assertLink($this->flag->getShortText('unflag')); // Check the flag count was incremented. - $flag_count_flagged = \Drupal::database()->query('SELECT count FROM {flag_counts} + $flag_count_flagged = $database->query('SELECT count FROM {flag_counts} WHERE flag_id = :flag_id AND entity_type = :entity_type AND entity_id = :entity_id', [ ':flag_id' => $flag_id, ':entity_type' => 'node', @@ -129,7 +132,7 @@ class LinkTypeConfirmFormTest extends FlagTestBase { $this->assertLink($this->flag->getShortText('flag')); // Check the flag count was decremented. - $flag_count_unflagged = \Drupal::database()->query('SELECT count FROM {flag_counts} + $flag_count_unflagged = $database->query('SELECT count FROM {flag_counts} WHERE flag_id = :flag_id AND entity_type = :entity_type AND entity_id = :entity_id', [ ':flag_id' => $flag_id, ':entity_type' => 'node', diff --git a/src/Tests/LinkTypeReloadTest.php b/src/Tests/LinkTypeReloadTest.php index 3a90d21..deee6bd 100644 --- a/src/Tests/LinkTypeReloadTest.php +++ b/src/Tests/LinkTypeReloadTest.php @@ -54,8 +54,11 @@ class LinkTypeReloadTest extends FlagTestBase { $user_1 = $this->drupalCreateUser(); $this->drupalLogin($user_1); + /** @var \Drupal\Core\Database\Connection $database */ + $database = $this->container->get->('database'); + // Get the flag count before the flagging, querying the database directly. - $flag_count_pre = \Drupal::database()->query('SELECT count FROM {flag_counts} + $flag_count_pre = $database->query('SELECT count FROM {flag_counts} WHERE flag_id = :flag_id AND entity_type = :entity_type AND entity_id = :entity_id', [ ':flag_id' => $flag_id, ':entity_type' => 'node', @@ -77,7 +80,7 @@ class LinkTypeReloadTest extends FlagTestBase { $this->assertLink($this->flag->getShortText('unflag')); // Check the flag count was incremented. - $flag_count_flagged = \Drupal::database()->query('SELECT count FROM {flag_counts} + $flag_count_flagged = $database->query('SELECT count FROM {flag_counts} WHERE flag_id = :flag_id AND entity_type = :entity_type AND entity_id = :entity_id', [ ':flag_id' => $flag_id, ':entity_type' => 'node', @@ -98,7 +101,7 @@ class LinkTypeReloadTest extends FlagTestBase { $this->assertLink($this->flag->getShortText('flag')); // Check the flag count was decremented. - $flag_count_unflagged = \Drupal::database()->query('SELECT count FROM {flag_counts} + $flag_count_unflagged = $database->query('SELECT count FROM {flag_counts} WHERE flag_id = :flag_id AND entity_type = :entity_type AND entity_id = :entity_id', [ ':flag_id' => $flag_id, ':entity_type' => 'node', diff --git a/src/Tests/UserFlagTypeTest.php b/src/Tests/UserFlagTypeTest.php index 1aa2163..ec78661 100644 --- a/src/Tests/UserFlagTypeTest.php +++ b/src/Tests/UserFlagTypeTest.php @@ -40,7 +40,11 @@ class UserFlagTypeTest extends FlagTestBase { $flag = $this->createFlagFromArray([ 'link_type' => 'reload', 'entity_type' => 'user', - 'bundles' => array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('user')), + 'bundles' => array_keys( + $this->container + ->get('entity_type.bundle.info') + ->getBundleInfo('user') + ), 'flag_type' => $this->getFlagType('user'), 'show_on_profile' => TRUE, 'flagTypeConfig' => [ diff --git a/tests/src/Functional/AnonymousFlagTest.php b/tests/src/Functional/AnonymousFlagTest.php index ada60c5..b152aa4 100644 --- a/tests/src/Functional/AnonymousFlagTest.php +++ b/tests/src/Functional/AnonymousFlagTest.php @@ -69,7 +69,7 @@ class AnonymousFlagTest extends BrowserTestBase { $this->assertNotEmpty($this->getSession()->getPage()->findLink('switch_this_off')); // Warning: $this->getDatabaseConnection() is the original database // connection, not the current one. - $flagging_id = \Drupal::database()->query('SELECT id FROM {flagging}')->fetchField(); + $flagging_id = $this->container->get('database')->query('SELECT id FROM {flagging}')->fetchField(); $this->assertNotEmpty($flagging_id); $flagging = Flagging::load($flagging_id); diff --git a/tests/src/FunctionalJavascript/FlagContextualLinksTest.php b/tests/src/FunctionalJavascript/FlagContextualLinksTest.php index c09112a..ca0f4fc 100755 --- a/tests/src/FunctionalJavascript/FlagContextualLinksTest.php +++ b/tests/src/FunctionalJavascript/FlagContextualLinksTest.php @@ -134,7 +134,11 @@ class FlagContextualLinksTest extends JavascriptTestBase { 'id' => 'test_label_123', 'label' => $this->randomHTMLString(), 'entity_type' => 'node', - 'bundles' => array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('node')), + 'bundles' => array_keys( + $this->container + ->get('entity_type.bundle.info') + ->getBundleInfo('node') + ), 'flag_short' => $this->randomHTMLString(), 'unflag_short' => $this->randomHTMLString(), 'unflag_denied_text' => $this->randomHTMLString(), diff --git a/tests/src/Kernel/FlagCountsTest.php b/tests/src/Kernel/FlagCountsTest.php index bdbc1b9..b449956 100644 --- a/tests/src/Kernel/FlagCountsTest.php +++ b/tests/src/Kernel/FlagCountsTest.php @@ -82,7 +82,7 @@ class FlagCountsTest extends FlagKernelTestBase { // Create the anonymous role. $this->installConfig(['user']); - $this->flagCountService = \Drupal::service('flag.count'); + $this->flagCountService = $this->container->get('flag.count'); // Create a non-global flag. $this->flag = Flag::create([