summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsvenryen2018-02-25 13:40:33 (GMT)
committerSven Berg Ryen2018-02-25 13:40:33 (GMT)
commitd9636fa81c1a48ec2aa5a1e658ffd11e35206e30 (patch)
treec2819e7d62d5d1923c4cd4c48986312a050af56b
parente34aaf99e4cc7cf6917f162ff5691aca617c860f (diff)
Issue #2900209 by svenryen: 8.x tests are failing
-rw-r--r--src/Tests/EuCookieComplianceConfigFormTest.php135
-rw-r--r--src/Tests/EuCookieComplianceTestBase.php31
-rw-r--r--src/Tests/Update/EuCookieComplianceUpdateTest.php67
-rw-r--r--tests/fixtures/update/drupal-8.eu-cookie-compliance-beta5.standard.php.gzbin138504 -> 0 bytes
-rw-r--r--tests/fixtures/update/drupal-8.user-role-manager-2774143.php52
-rw-r--r--tests/fixtures/update/user.role.secondtestfor2774143.yml10
-rw-r--r--tests/fixtures/update/user.role.testfor2774143.yml10
-rw-r--r--tests/modules/eu_cookie_compliance_test.info.yml8
8 files changed, 0 insertions, 313 deletions
diff --git a/src/Tests/EuCookieComplianceConfigFormTest.php b/src/Tests/EuCookieComplianceConfigFormTest.php
deleted file mode 100644
index 704ef85..0000000
--- a/src/Tests/EuCookieComplianceConfigFormTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-namespace Drupal\eu_cookie_compliance\Tests;
-
-use Drupal\Core\Url;
-
-/**
- * Test functionality for EU Cookie Compliance Config form.
- *
- * @group eu_cookie_compliance
- */
-class EuCookieComplianceConfigFormTest extends EuCookieComplianceTestBase {
-
- /**
- * An admin user with administrative permissions for EUCC.
- *
- * @var \Drupal\user\UserInterface
- */
- protected $adminUser;
-
- /**
- * Modules to enable.
- *
- * @var array
- */
- public static $modules = [
- 'eu_cookie_compliance',
- 'eu_cookie_compliance_test',
- 'node',
- 'path',
- ];
-
- /**
- * {@inheritdoc}
- */
- protected function setUp() {
- parent::setUp();
- // Create and log in admin user.
- $this->adminUser = $this->drupalCreateUser([
- 'display eu cookie compliance popup',
- 'administer eu cookie compliance popup',
- 'access content',
- 'administer url aliases',
- ]);
- $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
- }
-
- /**
- * Tests the EuCookieComplianceConfigForm.
- */
- public function testEuCookieComplianceConfigForm() {
- $this->drupalLogin($this->adminUser);
- $this->drupalGet('admin/config/system/eu-cookie-compliance');
- $this->assertNoFieldChecked('edit-popup-enabled');
- $edit = ['popup_enabled' => 1];
-
- $this->drupalPostForm(NULL, $edit, 'Save configuration');
- $this->assertFieldChecked('edit-popup-enabled');
- $this->assertText('Privacy policy link field is required.');
-
- $edit += ['popup_link' => 'https://drupal.org'];
- $this->drupalPostForm(NULL, $edit, 'Save configuration');
- $this->assertText('The configuration options have been saved.');
- }
-
- /**
- * Tests the popup link validation and configuration.
- */
- public function testPopupLinks() {
- $this->drupalLogin($this->adminUser);
-
- // Create 2 nodes.
- $this->createNode();
- $this->createNode();
-
- // Set a path alias for the second node.
- $this->drupalPostForm('/admin/config/search/path/add', ['source' => '/node/2', 'alias' => '/alias'], t('Save'));
-
- // Verify that the popup link field is a textfield, since type='url' only
- // accepts absolute urls.
- $this->drupalGet('/admin/config/system/eu-cookie-compliance');
- $this->assertFieldByXpath('//input[@id="edit-popup-link" and @type="text"]');
-
- $scenarios = [
- // Format: User-entered value, value displayed in form, actual value for
- // link.
- // External URLs.
- ['http://example.com/', 'http://example.com/', 'http://example.com/'],
- ['https://drupal.org', 'https://drupal.org', 'https://drupal.org'],
-
- // Internal URL without alias.
- ['/node/1', '/node/1', '/node/1'],
-
- // Internal URL with alias.
- ['/node/2', '/node/2', '/alias'],
-
- // Internal URL with alias with fragment.
- ['/node/2#anchor', '/node/2#anchor', '/alias#anchor'],
-
- // Special-case URLs.
- ['<front>', '<front>', '/'],
-
- // Spaces.
- ['/lorem ipsum', '/lorem ipsum', '/lorem ipsum'],
- ];
-
- foreach ($scenarios as $scenario) {
- // Configure EU cookie compliance.
- $edit = ['popup_link' => $scenario[0], 'popup_enabled' => TRUE];
- $this->drupalPostForm('/admin/config/system/eu-cookie-compliance', $edit, t('Save configuration'));
-
- // Verify the popup link input field after submit.
- $this->assertFieldByXpath('//input[@id="edit-popup-link"]', $scenario[1]);
-
- // Load a page and verify the popup link in the page settings.
- $this->drupalGet('/node/1');
- $settings = $this->getDrupalSettings();
- $expected_url = strpos($scenario[2], '/') === 0 ? Url::fromUserInput($scenario[2])->toString() : $scenario[2];
- $this->assertEqual($settings['eu_cookie_compliance']['popup_link'], $expected_url);
- }
-
- // Test validation for the popup link setting.
- $invalid_url_scenarios = [
- 'node/1' => "The user-entered string &#039;node/1&#039; must begin with a &#039;/&#039;, &#039;?&#039;, or &#039;#&#039;.",
- 'ftp://example.com' => "Invalid protocol specified for",
- ];
-
- foreach ($invalid_url_scenarios as $input => $message) {
- $edit = ['popup_link' => $input];
- $this->drupalPostForm('/admin/config/system/eu-cookie-compliance', $edit, t('Save configuration'));
- $this->assertRaw($message);
- }
- }
-
-}
diff --git a/src/Tests/EuCookieComplianceTestBase.php b/src/Tests/EuCookieComplianceTestBase.php
deleted file mode 100644
index 4a330a9..0000000
--- a/src/Tests/EuCookieComplianceTestBase.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-namespace Drupal\eu_cookie_compliance\Tests;
-
-use Drupal\simpletest\WebTestBase;
-
-/**
- * Base class for testing EUCC functionality.
- */
-abstract class EuCookieComplianceTestBase extends WebTestBase {
-
- /**
- * Assert function.
- *
- * Assert function to determine if EU Cookie Compliance rendered to the page
- * have a corresponding page element.
- *
- * @code
- * // Basic example.
- * $this->assertEuCookieCompliance();
- * @endcode
- */
- public function assertEuCookieCompliance() {
-
- $rendered_eucc = $this->xpath('//div[@id = "sliding-popup"]//div[starts-with(@class, "popup-content")]');
-
- $this->assertTrue($rendered_eucc, 'EU Cookie Compliance render.');
-
- }
-
-}
diff --git a/src/Tests/Update/EuCookieComplianceUpdateTest.php b/src/Tests/Update/EuCookieComplianceUpdateTest.php
deleted file mode 100644
index 5fd25fe..0000000
--- a/src/Tests/Update/EuCookieComplianceUpdateTest.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-namespace Drupal\eu_cookie_compliance\Tests\Update;
-
-use Drupal\system\Tests\Update\UpdatePathTestBase;
-use Drupal\user\Entity\Role;
-
-/**
- * Tests the upgrade path for eu Cookie Compliance permission keys.
- *
- * @see https://www.drupal.org/node/2774143
- *
- * @group eu_cookie_compliance
- */
-class EuCookieComplianceUpdateTest extends UpdatePathTestBase {
-
- /**
- * {@inheritdoc}
- */
- protected static $modules = ['eu_cookie_compliance'];
-
- /**
- * {@inheritdoc}
- */
- protected function setDatabaseDumpFiles() {
- $this->databaseDumpFiles = [
- __DIR__ . '/../../../tests/fixtures/update/drupal-8.eu-cookie-compliance-beta5.standard.php.gz',
- __DIR__ . '/../../../tests/fixtures/update/drupal-8.user-role-manager-2774143.php',
- ];
- }
-
- /**
- * Tests Eu Cookie Compliance permission keys updates.
- *
- * @see eu_cookie_compliance_post_update_permission_keys_to_lowercase()
- */
- public function testPostUpdatePermissionKeys() {
- // Login using root user.
- $this->drupalLogin($this->rootUser);
- $this->drupalGet('admin/people/permissions');
-
- // Tests to ensure that before updates the permission keys are in camelcase.
- /** @var \Drupal\user\RoleInterface $testfor2774143 */
- $testfor2774143 = Role::load('testfor2774143');
- $this->assertTrue($testfor2774143->hasPermission('administer EU Cookie Compliance popup'));
- $this->assertFalse($testfor2774143->hasPermission('administer eu cookie compliance popup'));
- /** @var \Drupal\user\RoleInterface $secondtestfor2774143 */
- $secondtestfor2774143 = Role::load('secondtestfor2774143');
- $this->assertTrue($secondtestfor2774143->hasPermission('display EU Cookie Compliance popup'));
- $this->assertFalse($secondtestfor2774143->hasPermission('display eu cookie compliance popup'));
-
- $this->runUpdates();
-
- $this->drupalGet('admin/people/permissions');
-
- // Tests to ensure that after updates the permission keys are in lowercase.
- /** @var \Drupal\user\RoleInterface $testfor2774143 */
- $testfor2774143 = Role::load('testfor2774143');
- $this->assertFalse($testfor2774143->hasPermission('administer EU Cookie Compliance popup'));
- $this->assertTrue($testfor2774143->hasPermission('administer eu cookie compliance popup'));
- /** @var \Drupal\user\RoleInterface $secondtestfor2774143 */
- $secondtestfor2774143 = Role::load('secondtestfor2774143');
- $this->assertFalse($secondtestfor2774143->hasPermission('display EU Cookie Compliance popup'));
- $this->assertTrue($secondtestfor2774143->hasPermission('display eu cookie compliance popup'));
- }
-
-}
diff --git a/tests/fixtures/update/drupal-8.eu-cookie-compliance-beta5.standard.php.gz b/tests/fixtures/update/drupal-8.eu-cookie-compliance-beta5.standard.php.gz
deleted file mode 100644
index 91640a3..0000000
--- a/tests/fixtures/update/drupal-8.eu-cookie-compliance-beta5.standard.php.gz
+++ /dev/null
Binary files differ
diff --git a/tests/fixtures/update/drupal-8.user-role-manager-2774143.php b/tests/fixtures/update/drupal-8.user-role-manager-2774143.php
deleted file mode 100644
index 8adfbdf..0000000
--- a/tests/fixtures/update/drupal-8.user-role-manager-2774143.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-/**
- * @file
- * Name: drupal-8.user-role-manager-2774143.php.
- *
- * Contains database additions to
- * drupal-8.eu-cookie-compliance-beta5.minimal.php.gz.
- * for testing the upgrade path of https://www.drupal.org/node/2774143.
- */
-
-use Drupal\Component\Serialization\Yaml;
-use Drupal\Core\Database\Database;
-
-$connection = Database::getConnection();
-
-// A custom role with 'administer EU Cookie Compliance popup' permissions.
-$role_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/user.role.testfor2774143.yml'));
-
-// A custom role with 'display EU Cookie Compliance popup' permissions.
-$role_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/user.role.secondtestfor2774143.yml'));
-
-foreach ($role_configs as $role_config) {
- $connection->insert('config')
- ->fields(array(
- 'collection',
- 'name',
- 'data',
- ))
- ->values(array(
- 'collection' => '',
- 'name' => 'user.role.' . $role_config['id'],
- 'data' => serialize($role_config),
- ))
- ->execute();
-}
-
-// Update the config entity query "index".
-$existing_roles = $connection->select('key_value')
- ->fields('key_value', ['value'])
- ->condition('collection', 'config.entity.key_store.user_role')
- ->execute()
- ->fetchField();
-$existing_roles = unserialize($existing_roles);
-
-$connection->update('key_value')
- ->fields([
- 'value' => serialize(array_merge($existing_roles, ['user.role.testfor2774143', 'user.role.secondtestfor2774143'])),
- ])
- ->condition('collection', 'config.entity.key_store.user_role')
- ->condition('name', 'theme:bartik')
- ->execute();
diff --git a/tests/fixtures/update/user.role.secondtestfor2774143.yml b/tests/fixtures/update/user.role.secondtestfor2774143.yml
deleted file mode 100644
index f517289..0000000
--- a/tests/fixtures/update/user.role.secondtestfor2774143.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-uuid: c1719bd6-e5a7-45d4-88bd-6930f3a2d97e
-langcode: en
-status: true
-dependencies: { }
-id: secondtestfor2774143
-label: secondtestfor2774143
-weight: 4
-is_admin: null
-permissions:
- - 'display EU Cookie Compliance popup'
diff --git a/tests/fixtures/update/user.role.testfor2774143.yml b/tests/fixtures/update/user.role.testfor2774143.yml
deleted file mode 100644
index 8549ab2..0000000
--- a/tests/fixtures/update/user.role.testfor2774143.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-uuid: f147ed49-543f-41df-9409-58a58bfaf357
-langcode: en
-status: true
-dependencies: { }
-id: testfor2774143
-label: testfor2774143
-weight: 3
-is_admin: null
-permissions:
- - 'administer EU Cookie Compliance popup'
diff --git a/tests/modules/eu_cookie_compliance_test.info.yml b/tests/modules/eu_cookie_compliance_test.info.yml
deleted file mode 100644
index c853453..0000000
--- a/tests/modules/eu_cookie_compliance_test.info.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-name: EUCC module tests
-type: module
-description: Support module for EUCC testing.
-package: Testing
-version: VERSION
-core: 8.x
-dependencies:
- - eu_cookie_compliance