class BreakpointTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/breakpoint/tests/src/Unit/BreakpointTest.php \Drupal\Tests\breakpoint\Unit\BreakpointTest
@coversDefaultClass \Drupal\breakpoint\Breakpoint @group Breakpoint
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\breakpoint\Unit\BreakpointTest
Expanded class hierarchy of BreakpointTest
File
- core/
modules/ breakpoint/ tests/ src/ Unit/ BreakpointTest.php, line 17 - Contains \Drupal\Tests\breakpoint\Unit\BreakpointTest.
Namespace
Drupal\Tests\breakpoint\UnitView source
class BreakpointTest extends UnitTestCase {
/**
* The used plugin ID.
*
* @var string
*/
protected $pluginId = 'breakpoint';
/**
* The used plugin definition.
*
* @var array
*/
protected $pluginDefinition = array(
'id' => 'breakpoint',
);
/**
* The breakpoint under test.
*
* @var \Drupal\breakpoint\Breakpoint
*/
protected $breakpoint;
/**
* The mocked translator.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $stringTranslation;
protected function setUp() {
parent::setUp();
$this->stringTranslation = $this
->getMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
}
/**
* Sets up the breakpoint defaults.
*/
protected function setupBreakpoint() {
$this->breakpoint = new Breakpoint(array(), $this->pluginId, $this->pluginDefinition);
$this->breakpoint
->setStringTranslation($this->stringTranslation);
}
/**
* @covers ::getLabel
*/
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());
}
/**
* @covers ::getWeight
*/
public function testGetWeight() {
$this->pluginDefinition['weight'] = '4';
$this
->setupBreakpoint();
// Assert that the type returned in an integer.
$this
->assertSame(4, $this->breakpoint
->getWeight());
}
/**
* @covers ::getMediaQuery
*/
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());
}
/**
* @covers ::getMultipliers
*/
public function testGetMultipliers() {
$this->pluginDefinition['multipliers'] = array(
'1x',
'2x',
);
$this
->setupBreakpoint();
$this
->assertSame(array(
'1x',
'2x',
), $this->breakpoint
->getMultipliers());
}
/**
* @covers ::getProvider
*/
public function testGetProvider() {
$this->pluginDefinition['provider'] = 'Breakpoint';
$this
->setupBreakpoint();
$this
->assertEquals('Breakpoint', $this->breakpoint
->getProvider());
}
/**
* @covers ::getGroup
*/
public function testGetGroup() {
$this->pluginDefinition['group'] = 'Breakpoint';
$this
->setupBreakpoint();
$this
->assertEquals('Breakpoint', $this->breakpoint
->getGroup());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BreakpointTest:: |
protected | property | The breakpoint under test. | |
BreakpointTest:: |
protected | property | The used plugin definition. | |
BreakpointTest:: |
protected | property | The used plugin ID. | |
BreakpointTest:: |
protected | property | The mocked translator. | |
BreakpointTest:: |
protected | function |
Overrides UnitTestCase:: |
|
BreakpointTest:: |
protected | function | Sets up the breakpoint defaults. | |
BreakpointTest:: |
public | function | @covers ::getGroup | |
BreakpointTest:: |
public | function | @covers ::getLabel | |
BreakpointTest:: |
public | function | @covers ::getMediaQuery | |
BreakpointTest:: |
public | function | @covers ::getMultipliers | |
BreakpointTest:: |
public | function | @covers ::getProvider | |
BreakpointTest:: |
public | function | @covers ::getWeight | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in 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. |