public function VisualDiffThemeNegotiatorTest::testApplies in Diff 8
Tests if the theme negotiator applies under correct conditions.
@covers ::applies @covers ::isDiffRoute
@dataProvider providerTestApplies
Parameters
string $filter_parameter: The filter parameter.
string $route_name: The route name.
string $config_value: The configuration value of the element taken from the form values.
bool $expected: The expected result.
File
- tests/
src/ Unit/ VisualDiffThemeNegotiatorTest.php, line 73
Class
- VisualDiffThemeNegotiatorTest
- Tests theme negotiator.
Namespace
Drupal\Tests\diff\UnitCode
public function testApplies($filter_parameter, $route_name, $config_value, $expected) {
$route_match = $this
->prophesize(RouteMatchInterface::class);
$route_match
->getParameter('filter')
->willReturn($filter_parameter);
if ($route_name) {
$route_match
->getRouteName()
->willReturn($route_name);
}
else {
$route_match
->getRouteName()
->shouldNotBeCalled();
}
if ($config_value) {
$diff_config = $this
->prophesize(ImmutableConfig::class);
$diff_config
->get('general_settings.visual_inline_theme')
->willReturn($config_value);
$this->configFactory
->get('diff.settings')
->willReturn($diff_config
->reveal());
}
else {
$this->configFactory
->get('diff.settings')
->shouldNotBeCalled();
}
$this
->assertSame($expected, $this->themeNegotiator
->applies($route_match
->reveal()));
}