Commit e6f8ccd6 authored by Joshua Sedler's avatar Joshua Sedler 🤸🏼 Committed by Merlin Axel Rutz
Browse files

Issue #3271390 by Grevil, Anybody, geek-merlin: Schema error while testing...

Issue #3271390 by Grevil, Anybody, geek-merlin: Schema error while testing module which depends on user_permission_condition
parent 9a0f6224
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
condition.plugin.user_permission:
  type: condition.plugin
  label: 'User Permission'
  mapping:
    permission:
      type: string
      label: 'Permission'
+74 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\user_permission_condition\Functional;

use Drupal\Tests\BrowserTestBase;

/**
 * This class provides testing for user_permission_condition.
 *
 * @group user_permission_condition
 */
class UserPermissionConditionFunctionalTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'test_page_test',
    'user_permission_condition',
  ];

  /**
   * A user with admin permissions.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $adminUser;

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();

    $this->config('system.site')->set('page.front', '/test-page')->save();
    $this->adminUser = $this->drupalCreateUser([]);
    $this->adminUser->addRole($this->createAdminRole('admin', 'admin'));
    $this->adminUser->save();
    $this->drupalLogin($this->adminUser);
  }

  /**
   * Tests if the module installation, won't break the site.
   */
  public function testInstallation() {
    $session = $this->assertSession();
    $this->drupalGet('<front>');
    $session->statusCodeEquals(200);
  }

  /**
   * Tests if uninstalling the module, won't break the site.
   */
  public function testUninstallation() {
    // Go to uninstallation page an uninstall user_permission_condition:
    $session = $this->assertSession();
    $page = $this->getSession()->getPage();
    $this->drupalGet('/admin/modules/uninstall');
    $session->statusCodeEquals(200);
    $page->checkField('edit-uninstall-user-permission-condition');
    $page->pressButton('edit-submit');
    $session->statusCodeEquals(200);
    // Confirm deinstall:
    $page->pressButton('edit-submit');
    $session->statusCodeEquals(200);
    $session->pageTextContains('The selected modules have been uninstalled.');
  }

}