X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontact%2Fsrc%2FTests%2FViews%2FContactLinkTest.php;fp=web%2Fcore%2Fmodules%2Fcontact%2Fsrc%2FTests%2FViews%2FContactLinkTest.php;h=0000000000000000000000000000000000000000;hb=bfbba508964731508b9bd6d5835c2edc858db95b;hp=f6b6013b43aef02f34bc24284032fb27fa26088c;hpb=cb9a80db11fc6b014e5b1e693a5a391c95eb5d9a;p=yaffs-website diff --git a/web/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/web/core/modules/contact/src/Tests/Views/ContactLinkTest.php deleted file mode 100644 index f6b6013b4..000000000 --- a/web/core/modules/contact/src/Tests/Views/ContactLinkTest.php +++ /dev/null @@ -1,108 +0,0 @@ -userData = $this->container->get('user.data'); - } - - /** - * Tests contact link. - */ - public function testContactLink() { - $accounts = []; - $accounts['root'] = User::load(1); - // Create an account with access to all contact pages. - $admin_account = $this->drupalCreateUser(['administer users']); - $accounts['admin'] = $admin_account; - // Create an account with no access to contact pages. - $no_contact_account = $this->drupalCreateUser(); - $accounts['no_contact'] = $no_contact_account; - - // Create an account with access to contact pages. - $contact_account = $this->drupalCreateUser(['access user contact forms']); - $accounts['contact'] = $contact_account; - - $this->drupalLogin($admin_account); - $this->drupalGet('test-contact-link'); - // The admin user has access to all contact links beside his own. - $this->assertContactLinks($accounts, ['root', 'no_contact', 'contact']); - - $this->drupalLogin($no_contact_account); - $this->drupalGet('test-contact-link'); - // Ensure that the user without the permission doesn't see any link. - $this->assertContactLinks($accounts, []); - - $this->drupalLogin($contact_account); - $this->drupalGet('test-contact-link'); - $this->assertContactLinks($accounts, ['root', 'admin', 'no_contact']); - - // Disable contact link for no_contact. - $this->userData->set('contact', $no_contact_account->id(), 'enabled', FALSE); - // @todo Remove cache invalidation in https://www.drupal.org/node/2477903. - Cache::invalidateTags($no_contact_account->getCacheTagsToInvalidate()); - $this->drupalGet('test-contact-link'); - $this->assertContactLinks($accounts, ['root', 'admin']); - } - - /** - * Asserts whether certain users contact links appear on the page. - * - * @param array $accounts - * All user objects used by the test. - * @param array $names - * Users which should have contact links. - */ - public function assertContactLinks(array $accounts, array $names) { - $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a'); - $this->assertEqual(count($result), count($names)); - foreach ($names as $name) { - $account = $accounts[$name]; - - $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', [':url' => $account->url('contact-form')]); - $this->assertTrue(count($result)); - } - } - -}