protected function ViewportResolverTest::setUp in Viewport 8
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ ViewportResolverTest.php, line 45
Class
- ViewportResolverTest
- @coversDefaultClass \Drupal\viewport\ViewportResolver @group viewport
Namespace
Drupal\Tests\viewport\UnitCode
protected function setUp() {
parent::setUp();
// Instantiate mocks and stubs.
$configuredPaths = "<front>\n/node/*\n/present-path";
$this->configFactory = $this
->getConfigFactoryStub(array(
'viewport.settings' => array(
'selected_pages' => $configuredPaths,
'width' => '1600',
'height' => 'device-height',
'initial_scale' => '2.0',
'minimum_scale' => '1.0',
'maximum_scale' => '5.0',
'user_scalable' => TRUE,
),
));
$requestStack = $this
->getMock('\\Symfony\\Component\\HttpFoundation\\RequestStack');
$this->currentPathStack = $this
->getMock('\\Drupal\\Core\\Path\\CurrentPathStack', array(), [
$requestStack,
]);
$this->currentPathStack
->expects($this
->any())
->method('getPath')
->will($this
->onConsecutiveCalls('/present-path', '/not-present-path'));
// Mock PathMatcher class directly (instead of interface) to try and add
// some coverage of '<front>'.
$this->pathMatcher = $this
->getMock('\\Drupal\\Core\\Path\\PathMatcher', array(
'getFrontPagePath',
), array(), '', FALSE);
$this->pathMatcher
->expects($this
->any())
->method('getFrontPagePath')
->will($this
->returnValue('/frontpage-path'));
$this->viewportResolver = new ViewportResolver($this->pathMatcher, $this->currentPathStack, $this->configFactory);
}