You are here

class ModalPageTest in Modal 8.3

Same name in this branch
  1. 8.3 tests/src/Unit/ModalPageTest.php \Drupal\Tests\modal_page\Unit\ModalPageTest
  2. 8.3 tests/src/Kernel/ModalPageTest.php \Drupal\Tests\modal_page\Kernel\ModalPageTest
Same name and namespace in other branches
  1. 8.2 tests/src/Unit/ModalPageTest.php \Drupal\Tests\modal_page\Unit\ModalPageTest

Tests for ModalPage class.

@group modal_page

Hierarchy

Expanded class hierarchy of ModalPageTest

File

tests/src/Unit/ModalPageTest.php, line 21

Namespace

Drupal\Tests\modal_page\Unit
View source
class ModalPageTest extends UnitTestCase {

  /**
   * Initial setUp to tests.
   */
  public function setUp() {
    parent::setUp();
    $this->languageManager = $this
      ->createMock(LanguageManager::class);
    $this->entityTypeManager = $this
      ->createMock(EntityTypeManager::class);
    $this->configFactory = $this
      ->getConfigFactoryStub([
      'modal_page.settings' => [
        'no_modal_page_external_js' => TRUE,
        'allowed_tags' => "h1,h2,a,b,big,code,del,em,i,ins,pre,q,small,span,strong,sub,sup,tt,ol,ul,li,p,br,img",
      ],
    ]);
    $this->database = $this
      ->createMock(Connection::class);
    $this->requestStack = $this
      ->createMock(RequestStack::class);
    $this->pathMatcher = $this
      ->createMock(PathMatcher::class);
    $this->uuid = $this
      ->createMock(UuidInterface::class);
    $this->currentUser = $this
      ->createMock(AccountProxy::class);
    $this->aliasManager = $this
      ->createMock(AliasManager::class);
    $this->modalPage = new ModalPage($this->languageManager, $this->entityTypeManager, $this->configFactory, $this->database, $this->requestStack, $this->pathMatcher, $this->uuid, $this->currentUser, $this->aliasManager);
  }

  /**
   * Test ModalPage::clearText().
   */
  public function testClearText() {
    $this
      ->assertEquals($this->modalPage
      ->clearText('  This is a test!'), 'This is a test!');
  }

  /**
   * Test ModalPage::getAllowTags().
   */
  public function testAllowTags() {
    $this
      ->assertCount(24, $this->modalPage
      ->getAllowTags());
    $this
      ->assertContains('h2', $this->modalPage
      ->getAllowTags());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ModalPageTest::setUp public function Initial setUp to tests. Overrides UnitTestCase::setUp
ModalPageTest::testAllowTags public function Test ModalPage::getAllowTags().
ModalPageTest::testClearText public function Test ModalPage::clearText().
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.