Mercurial > hg > isophonics-drupal-site
comparison core/modules/breakpoint/tests/src/Unit/BreakpointTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\breakpoint\Unit; | |
4 | |
5 use Drupal\breakpoint\Breakpoint; | |
6 use Drupal\Tests\UnitTestCase; | |
7 use Drupal\Core\StringTranslation\TranslatableMarkup; | |
8 | |
9 /** | |
10 * @coversDefaultClass \Drupal\breakpoint\Breakpoint | |
11 * @group Breakpoint | |
12 */ | |
13 class BreakpointTest extends UnitTestCase { | |
14 | |
15 /** | |
16 * The used plugin ID. | |
17 * | |
18 * @var string | |
19 */ | |
20 protected $pluginId = 'breakpoint'; | |
21 | |
22 /** | |
23 * The used plugin definition. | |
24 * | |
25 * @var array | |
26 */ | |
27 protected $pluginDefinition = [ | |
28 'id' => 'breakpoint', | |
29 ]; | |
30 | |
31 /** | |
32 * The breakpoint under test. | |
33 * | |
34 * @var \Drupal\breakpoint\Breakpoint | |
35 */ | |
36 protected $breakpoint; | |
37 | |
38 /** | |
39 * The mocked translator. | |
40 * | |
41 * @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit_Framework_MockObject_MockObject | |
42 */ | |
43 protected $stringTranslation; | |
44 | |
45 protected function setUp() { | |
46 parent::setUp(); | |
47 | |
48 $this->stringTranslation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'); | |
49 } | |
50 | |
51 /** | |
52 * Sets up the breakpoint defaults. | |
53 */ | |
54 protected function setupBreakpoint() { | |
55 $this->breakpoint = new Breakpoint([], $this->pluginId, $this->pluginDefinition); | |
56 $this->breakpoint->setStringTranslation($this->stringTranslation); | |
57 } | |
58 | |
59 /** | |
60 * @covers ::getLabel | |
61 */ | |
62 public function testGetLabel() { | |
63 $this->pluginDefinition['label'] = 'Test label'; | |
64 $this->setupBreakpoint(); | |
65 $this->assertEquals(new TranslatableMarkup('Test label', [], ['context' => 'breakpoint'], $this->stringTranslation), $this->breakpoint->getLabel()); | |
66 } | |
67 | |
68 /** | |
69 * @covers ::getWeight | |
70 */ | |
71 public function testGetWeight() { | |
72 $this->pluginDefinition['weight'] = '4'; | |
73 $this->setupBreakpoint(); | |
74 // Assert that the type returned in an integer. | |
75 $this->assertSame(4, $this->breakpoint->getWeight()); | |
76 } | |
77 | |
78 /** | |
79 * @covers ::getMediaQuery | |
80 */ | |
81 public function testGetMediaQuery() { | |
82 $this->pluginDefinition['mediaQuery'] = 'only screen and (min-width: 1220px)'; | |
83 $this->setupBreakpoint(); | |
84 $this->assertEquals('only screen and (min-width: 1220px)', $this->breakpoint->getMediaQuery()); | |
85 } | |
86 | |
87 /** | |
88 * @covers ::getMultipliers | |
89 */ | |
90 public function testGetMultipliers() { | |
91 $this->pluginDefinition['multipliers'] = ['1x', '2x']; | |
92 $this->setupBreakpoint(); | |
93 $this->assertSame(['1x', '2x'], $this->breakpoint->getMultipliers()); | |
94 } | |
95 | |
96 /** | |
97 * @covers ::getProvider | |
98 */ | |
99 public function testGetProvider() { | |
100 $this->pluginDefinition['provider'] = 'Breakpoint'; | |
101 $this->setupBreakpoint(); | |
102 $this->assertEquals('Breakpoint', $this->breakpoint->getProvider()); | |
103 } | |
104 | |
105 /** | |
106 * @covers ::getGroup | |
107 */ | |
108 public function testGetGroup() { | |
109 $this->pluginDefinition['group'] = 'Breakpoint'; | |
110 $this->setupBreakpoint(); | |
111 $this->assertEquals('Breakpoint', $this->breakpoint->getGroup()); | |
112 } | |
113 | |
114 } |