BreakpointTest.php in Zircon Profile 8.0
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;
class BreakpointTest extends UnitTestCase {
protected $pluginId = 'breakpoint';
protected $pluginDefinition = array(
'id' => 'breakpoint',
);
protected $breakpoint;
protected $stringTranslation;
protected function setUp() {
parent::setUp();
$this->stringTranslation = $this
->getMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
}
protected function setupBreakpoint() {
$this->breakpoint = new Breakpoint(array(), $this->pluginId, $this->pluginDefinition);
$this->breakpoint
->setStringTranslation($this->stringTranslation);
}
public function testGetLabel() {
$this->pluginDefinition['label'] = 'Test label';
$this->stringTranslation
->expects($this
->once())
->method('translate')
->with($this->pluginDefinition['label'], array(), array(
'context' => 'breakpoint',
))
->will($this
->returnValue('Test label translated'));
$this
->setupBreakpoint();
$this
->assertEquals('Test label translated', $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'] = array(
'1x',
'2x',
);
$this
->setupBreakpoint();
$this
->assertSame(array(
'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());
}
}