class ModalPageTest in Modal 8.2
Same name in this branch
- 8.2 tests/src/Unit/ModalPageTest.php \Drupal\Tests\modal_page\Unit\ModalPageTest
- 8.2 tests/src/Kernel/ModalPageTest.php \Drupal\Tests\modal_page\Kernel\ModalPageTest
Same name and namespace in other branches
- 8.3 tests/src/Unit/ModalPageTest.php \Drupal\Tests\modal_page\Unit\ModalPageTest
Tests for ModalPage class.
@group modal_page
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\modal_page\Unit\ModalPageTest
Expanded class hierarchy of ModalPageTest
File
- tests/
src/ Unit/ ModalPageTest.php, line 21
Namespace
Drupal\Tests\modal_page\UnitView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ModalPageTest:: |
public | function |
Initial setUp to tests. Overrides UnitTestCase:: |
|
ModalPageTest:: |
public | function | Test ModalPage::getAllowTags(). | |
ModalPageTest:: |
public | function | Test ModalPage::clearText(). | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |