class BreakpointTest
Tests Drupal\breakpoint\Breakpoint.
Attributes
#[CoversClass(Breakpoint::class)]
#[Group('Breakpoint')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\breakpoint\Unit\BreakpointTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of BreakpointTest
File
-
core/
modules/ breakpoint/ tests/ src/ Unit/ BreakpointTest.php, line 16
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 = [
'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;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->stringTranslation = $this->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
}
/**
* Sets up the breakpoint defaults.
*/
protected function setupBreakpoint() : void {
$this->breakpoint = new Breakpoint([], $this->pluginId, $this->pluginDefinition);
$this->breakpoint
->setStringTranslation($this->stringTranslation);
}
/**
* Tests get label.
*
* @legacy-covers ::getLabel
*/
public function testGetLabel() : void {
$this->pluginDefinition['label'] = 'Test label';
$this->setupBreakpoint();
$this->assertEquals(new TranslatableMarkup('Test label', [], [
'context' => 'breakpoint',
], $this->stringTranslation), $this->breakpoint
->getLabel());
}
/**
* Tests get weight.
*
* @legacy-covers ::getWeight
*/
public function testGetWeight() : void {
$this->pluginDefinition['weight'] = '4';
$this->setupBreakpoint();
// Assert that the type returned in an integer.
$this->assertSame(4, $this->breakpoint
->getWeight());
}
/**
* Tests get media query.
*
* @legacy-covers ::getMediaQuery
*/
public function testGetMediaQuery() : void {
$this->pluginDefinition['mediaQuery'] = 'only screen and (min-width: 1220px)';
$this->setupBreakpoint();
$this->assertEquals('only screen and (min-width: 1220px)', $this->breakpoint
->getMediaQuery());
}
/**
* Tests get multipliers.
*
* @legacy-covers ::getMultipliers
*/
public function testGetMultipliers() : void {
$this->pluginDefinition['multipliers'] = [
'1x',
'2x',
];
$this->setupBreakpoint();
$this->assertSame([
'1x',
'2x',
], $this->breakpoint
->getMultipliers());
}
/**
* Tests get provider.
*
* @legacy-covers ::getProvider
*/
public function testGetProvider() : void {
$this->pluginDefinition['provider'] = 'Breakpoint';
$this->setupBreakpoint();
$this->assertEquals('Breakpoint', $this->breakpoint
->getProvider());
}
/**
* Tests get group.
*
* @legacy-covers ::getGroup
*/
public function testGetGroup() : void {
$this->pluginDefinition['group'] = 'Breakpoint';
$this->setupBreakpoint();
$this->assertEquals('Breakpoint', $this->breakpoint
->getGroup());
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|
| BreakpointTest::$breakpoint | protected | property | The breakpoint under test. | |
| BreakpointTest::$pluginDefinition | protected | property | The used plugin definition. | |
| BreakpointTest::$pluginId | protected | property | The used plugin ID. | |
| BreakpointTest::$stringTranslation | protected | property | The mocked translator. | |
| BreakpointTest::setUp | protected | function | Overrides UnitTestCase::setUp | |
| BreakpointTest::setupBreakpoint | protected | function | Sets up the breakpoint defaults. | |
| BreakpointTest::testGetGroup | public | function | Tests get group. | |
| BreakpointTest::testGetLabel | public | function | Tests get label. | |
| BreakpointTest::testGetMediaQuery | public | function | Tests get media query. | |
| BreakpointTest::testGetMultipliers | public | function | Tests get multipliers. | |
| BreakpointTest::testGetProvider | public | function | Tests get provider. | |
| BreakpointTest::testGetWeight | public | function | Tests get weight. | |
| ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |
| ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |
| ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
| UnitTestCase::$root | protected | property | The app root. | |
| UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |
| UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |
| UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |
| UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |
| UnitTestCase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |
| UnitTestCase::setupMockIterator | protected | function | Set up a traversable class mock to return specific items when iterated. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.