BreakpointTest.php in Drupal 10
File
core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
View source
<?php
namespace Drupal\Tests\breakpoint\Unit;
use Drupal\breakpoint\Breakpoint;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
class BreakpointTest extends UnitTestCase {
protected $pluginId = 'breakpoint';
protected $pluginDefinition = [
'id' => 'breakpoint',
];
protected $breakpoint;
protected $stringTranslation;
protected function setUp() : void {
parent::setUp();
$this->stringTranslation = $this
->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
}
protected function setupBreakpoint() {
$this->breakpoint = new Breakpoint([], $this->pluginId, $this->pluginDefinition);
$this->breakpoint
->setStringTranslation($this->stringTranslation);
}
public function testGetLabel() {
$this->pluginDefinition['label'] = 'Test label';
$this
->setupBreakpoint();
$this
->assertEquals(new TranslatableMarkup('Test label', [], [
'context' => 'breakpoint',
], $this->stringTranslation), $this->breakpoint
->getLabel());
}
public function testGetWeight() {
$this->pluginDefinition['weight'] = '4';
$this
->setupBreakpoint();
$this
->assertSame(4, $this->breakpoint
->getWeight());
}
public function testGetMediaQuery() {
$this->pluginDefinition['mediaQuery'] = 'only screen and (min-width: 1220px)';
$this
->setupBreakpoint();
$this
->assertEquals('only screen and (min-width: 1220px)', $this->breakpoint
->getMediaQuery());
}
public function testGetMultipliers() {
$this->pluginDefinition['multipliers'] = [
'1x',
'2x',
];
$this
->setupBreakpoint();
$this
->assertSame([
'1x',
'2x',
], $this->breakpoint
->getMultipliers());
}
public function testGetProvider() {
$this->pluginDefinition['provider'] = 'Breakpoint';
$this
->setupBreakpoint();
$this
->assertEquals('Breakpoint', $this->breakpoint
->getProvider());
}
public function testGetGroup() {
$this->pluginDefinition['group'] = 'Breakpoint';
$this
->setupBreakpoint();
$this
->assertEquals('Breakpoint', $this->breakpoint
->getGroup());
}
}