class LanguageInterfaceContextTest in Page Manager 8.4
Tests the current language interface context.
@coversDefaultClass \Drupal\page_manager\EventSubscriber\LanguageInterfaceContext
@group PageManager
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\page_manager\Unit\PageContextTestBase
- class \Drupal\Tests\page_manager\Unit\LanguageInterfaceContextTest
- class \Drupal\Tests\page_manager\Unit\PageContextTestBase
Expanded class hierarchy of LanguageInterfaceContextTest
File
- tests/
src/ Unit/ LanguageInterfaceContextTest.php, line 18
Namespace
Drupal\Tests\page_manager\UnitView source
class LanguageInterfaceContextTest extends PageContextTestBase {
/**
* The context repository service.
*
* @var \Drupal\Core\Plugin\Context\ContextRepositoryInterface
*/
protected $contextRepository;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$language_manager = $this
->getMockBuilder('\\Drupal\\Core\\Language\\LanguageManagerInterface')
->disableOriginalConstructor()
->getMock();
$context = new Context(new ContextDefinition('language', 'current_language_context'), $language_manager
->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE));
$this->contextRepository = $this
->getMockBuilder('\\Drupal\\Core\\Plugin\\Context\\ContextRepositoryInterface')
->disableOriginalConstructor()
->getMock();
$this->contextRepository
->expects($this
->once())
->method('getRunTimeContexts')
->willReturn([
'@language.current_language_context:language_interface' => $context,
]);
}
/**
* @covers ::onPageContext
*/
public function testOnPageContext() {
$this->page
->addContext('language_interface', Argument::type(Context::class))
->shouldBeCalled();
$language_interface_context = new LanguageInterfaceContext($this->contextRepository);
$language_interface_context
->onPageContext($this->event);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LanguageInterfaceContextTest:: |
protected | property | The context repository service. | |
LanguageInterfaceContextTest:: |
public | function |
Overrides PageContextTestBase:: |
|
LanguageInterfaceContextTest:: |
public | function | @covers ::onPageContext | |
PageContextTestBase:: |
protected | property | The event. | |
PageContextTestBase:: |
protected | property | The page entity. | |
PageContextTestBase:: |
protected | property | The typed data manager. | |
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. |