Skip to content

Commit 77ff8b3

Browse files
authored
Merge pull request #296 from oliverklee/cleanup/tests-formatting
2 parents 67578e6 + 2ff8961 commit 77ff8b3

File tree

7 files changed

+537
-272
lines changed

7 files changed

+537
-272
lines changed

config/php-cs-fixer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,17 @@
1111
'@PSR12' => true,
1212
// Disable constant visibility from the PSR12 rule set as this would break compatibility with PHP < 7.1.
1313
'visibility_required' => ['elements' => ['property', 'method']],
14+
15+
'php_unit_construct' => true,
16+
'php_unit_dedicate_assert' => ['target' => '5.0'],
17+
'php_unit_expectation' => ['target' => '5.6'],
18+
'php_unit_fqcn_annotation' => true,
19+
'php_unit_method_casing' => true,
20+
'php_unit_mock' => ['target' => '5.5'],
21+
'php_unit_mock_short_will_return' => true,
22+
'php_unit_namespaced' => ['target' => '5.7'],
23+
'php_unit_set_up_tear_down_visibility' => true,
24+
'php_unit_test_annotation' => ['style' => 'annotation'],
25+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
1426
]
1527
);

tests/CSSList/AtRuleBlockListTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@
77

88
class AtRuleBlockListTest extends TestCase
99
{
10-
public function testMediaQueries()
10+
/**
11+
* @test
12+
*/
13+
public function mediaQueries()
1114
{
1215
$sCss = '@media(min-width: 768px){.class{color:red}}';
1316
$oParser = new Parser($sCss);
1417
$oDoc = $oParser->parse();
1518
$aContents = $oDoc->getContents();
1619
$oMediaQuery = $aContents[0];
17-
$this->assertSame('media', $oMediaQuery->atRuleName(), 'Does not interpret the type as a function');
18-
$this->assertSame('(min-width: 768px)', $oMediaQuery->atRuleArgs(), 'The media query is the value');
20+
self::assertSame('media', $oMediaQuery->atRuleName(), 'Does not interpret the type as a function');
21+
self::assertSame('(min-width: 768px)', $oMediaQuery->atRuleArgs(), 'The media query is the value');
1922

2023
$sCss = '@media (min-width: 768px) {.class{color:red}}';
2124
$oParser = new Parser($sCss);
2225
$oDoc = $oParser->parse();
2326
$aContents = $oDoc->getContents();
2427
$oMediaQuery = $aContents[0];
25-
$this->assertSame('media', $oMediaQuery->atRuleName(), 'Does not interpret the type as a function');
26-
$this->assertSame('(min-width: 768px)', $oMediaQuery->atRuleArgs(), 'The media query is the value');
28+
self::assertSame('media', $oMediaQuery->atRuleName(), 'Does not interpret the type as a function');
29+
self::assertSame('(min-width: 768px)', $oMediaQuery->atRuleArgs(), 'The media query is the value');
2730
}
2831
}

tests/CSSList/DocumentTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
class DocumentTest extends TestCase
99
{
10-
public function testOverrideContents()
10+
/**
11+
* @test
12+
*/
13+
public function overrideContents()
1114
{
1215
$sCss = '.thing { left: 10px; }';
1316
$oParser = new Parser($sCss);
1417
$oDoc = $oParser->parse();
1518
$aContents = $oDoc->getContents();
16-
$this->assertCount(1, $aContents);
19+
self::assertCount(1, $aContents);
1720

1821
$sCss2 = '.otherthing { right: 10px; }';
1922
$oParser2 = new Parser($sCss);
@@ -22,6 +25,6 @@ public function testOverrideContents()
2225

2326
$oDoc->setContents([$aContents[0], $aContents2[0]]);
2427
$aFinalContents = $oDoc->getContents();
25-
$this->assertCount(2, $aFinalContents);
28+
self::assertCount(2, $aFinalContents);
2629
}
2730
}

tests/OutputFormatTest.php

Lines changed: 89 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,57 @@ protected function setUp()
4141
$this->oDocument = $this->oParser->parse();
4242
}
4343

44-
public function testPlain()
44+
/**
45+
* @test
46+
*/
47+
public function plain()
4548
{
46-
$this->assertSame(
49+
self::assertSame(
4750
'.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
4851
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
4952
$this->oDocument->render()
5053
);
5154
}
5255

53-
public function testCompact()
56+
/**
57+
* @test
58+
*/
59+
public function compact()
5460
{
55-
$this->assertSame(
61+
self::assertSame(
5662
'.main,.test{font:italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background:white;}'
5763
. '@media screen{.main{background-size:100% 100%;font-size:1.3em;background-color:#fff;}}',
5864
$this->oDocument->render(OutputFormat::createCompact())
5965
);
6066
}
6167

62-
public function testPretty()
68+
/**
69+
* @test
70+
*/
71+
public function pretty()
6372
{
64-
$this->assertSame(self::TEST_CSS, $this->oDocument->render(OutputFormat::createPretty()));
73+
self::assertSame(self::TEST_CSS, $this->oDocument->render(OutputFormat::createPretty()));
6574
}
6675

67-
public function testSpaceAfterListArgumentSeparator()
76+
/**
77+
* @test
78+
*/
79+
public function spaceAfterListArgumentSeparator()
6880
{
69-
$this->assertSame(
81+
self::assertSame(
7082
'.main, .test {font: italic normal bold 16px/ 1.2 '
7183
. '"Helvetica", Verdana, sans-serif;background: white;}'
7284
. "\n@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}",
7385
$this->oDocument->render(OutputFormat::create()->setSpaceAfterListArgumentSeparator(" "))
7486
);
7587
}
7688

77-
public function testSpaceAfterListArgumentSeparatorComplex()
89+
/**
90+
* @test
91+
*/
92+
public function spaceAfterListArgumentSeparatorComplex()
7893
{
79-
$this->assertSame(
94+
self::assertSame(
8095
'.main, .test {font: italic normal bold 16px/1.2 "Helvetica", Verdana, sans-serif;background: white;}'
8196
. "\n@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}",
8297
$this->oDocument->render(OutputFormat::create()->setSpaceAfterListArgumentSeparator([
@@ -88,55 +103,73 @@ public function testSpaceAfterListArgumentSeparatorComplex()
88103
);
89104
}
90105

91-
public function testSpaceAfterSelectorSeparator()
106+
/**
107+
* @test
108+
*/
109+
public function spaceAfterSelectorSeparator()
92110
{
93-
$this->assertSame(
111+
self::assertSame(
94112
'.main,
95113
.test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
96114
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
97115
$this->oDocument->render(OutputFormat::create()->setSpaceAfterSelectorSeparator("\n"))
98116
);
99117
}
100118

101-
public function testStringQuotingType()
119+
/**
120+
* @test
121+
*/
122+
public function stringQuotingType()
102123
{
103-
$this->assertSame(
124+
self::assertSame(
104125
'.main, .test {font: italic normal bold 16px/1.2 \'Helvetica\',Verdana,sans-serif;background: white;}
105126
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
106127
$this->oDocument->render(OutputFormat::create()->setStringQuotingType("'"))
107128
);
108129
}
109130

110-
public function testRGBHashNotation()
131+
/**
132+
* @test
133+
*/
134+
public function rGBHashNotation()
111135
{
112-
$this->assertSame(
136+
self::assertSame(
113137
'.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
114138
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: rgb(255,255,255);}}',
115139
$this->oDocument->render(OutputFormat::create()->setRGBHashNotation(false))
116140
);
117141
}
118142

119-
public function testSemicolonAfterLastRule()
143+
/**
144+
* @test
145+
*/
146+
public function semicolonAfterLastRule()
120147
{
121-
$this->assertSame(
148+
self::assertSame(
122149
'.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white}
123150
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff}}',
124151
$this->oDocument->render(OutputFormat::create()->setSemicolonAfterLastRule(false))
125152
);
126153
}
127154

128-
public function testSpaceAfterRuleName()
155+
/**
156+
* @test
157+
*/
158+
public function spaceAfterRuleName()
129159
{
130-
$this->assertSame(
160+
self::assertSame(
131161
'.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
132162
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
133163
$this->oDocument->render(OutputFormat::create()->setSpaceAfterRuleName("\t"))
134164
);
135165
}
136166

137-
public function testSpaceRules()
167+
/**
168+
* @test
169+
*/
170+
public function spaceRules()
138171
{
139-
$this->assertSame('.main, .test {
172+
self::assertSame('.main, .test {
140173
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
141174
background: white;
142175
}
@@ -147,19 +180,25 @@ public function testSpaceRules()
147180
}}', $this->oDocument->render(OutputFormat::create()->set('Space*Rules', "\n")));
148181
}
149182

150-
public function testSpaceBlocks()
183+
/**
184+
* @test
185+
*/
186+
public function spaceBlocks()
151187
{
152-
$this->assertSame('
188+
self::assertSame('
153189
.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
154190
@media screen {
155191
.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}
156192
}
157193
', $this->oDocument->render(OutputFormat::create()->set('Space*Blocks', "\n")));
158194
}
159195

160-
public function testSpaceBoth()
196+
/**
197+
* @test
198+
*/
199+
public function spaceBoth()
161200
{
162-
$this->assertSame('
201+
self::assertSame('
163202
.main, .test {
164203
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
165204
background: white;
@@ -174,18 +213,24 @@ public function testSpaceBoth()
174213
', $this->oDocument->render(OutputFormat::create()->set('Space*Rules', "\n")->set('Space*Blocks', "\n")));
175214
}
176215

177-
public function testSpaceBetweenBlocks()
216+
/**
217+
* @test
218+
*/
219+
public function spaceBetweenBlocks()
178220
{
179-
$this->assertSame(
221+
self::assertSame(
180222
'.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}'
181223
. '@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
182224
$this->oDocument->render(OutputFormat::create()->setSpaceBetweenBlocks(''))
183225
);
184226
}
185227

186-
public function testIndentation()
228+
/**
229+
* @test
230+
*/
231+
public function indentation()
187232
{
188-
$this->assertSame('
233+
self::assertSame('
189234
.main, .test {
190235
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
191236
background: white;
@@ -203,9 +248,12 @@ public function testIndentation()
203248
->setIndentation('')));
204249
}
205250

206-
public function testSpaceBeforeBraces()
251+
/**
252+
* @test
253+
*/
254+
public function spaceBeforeBraces()
207255
{
208-
$this->assertSame(
256+
self::assertSame(
209257
'.main, .test{font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
210258
@media screen{.main{background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
211259
$this->oDocument->render(OutputFormat::create()->setSpaceBeforeOpeningBrace(''))
@@ -214,13 +262,15 @@ public function testSpaceBeforeBraces()
214262

215263
/**
216264
* @expectedException \Sabberworm\CSS\Parsing\OutputException
265+
*
266+
* @test
217267
*/
218-
public function testIgnoreExceptionsOff()
268+
public function ignoreExceptionsOff()
219269
{
220270
$aBlocks = $this->oDocument->getAllDeclarationBlocks();
221271
$oFirstBlock = $aBlocks[0];
222272
$oFirstBlock->removeSelector('.main');
223-
$this->assertSame(
273+
self::assertSame(
224274
'.test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
225275
@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
226276
$this->oDocument->render(OutputFormat::create()->setIgnoreExceptions(false))
@@ -229,13 +279,16 @@ public function testIgnoreExceptionsOff()
229279
$this->oDocument->render(OutputFormat::create()->setIgnoreExceptions(false));
230280
}
231281

232-
public function testIgnoreExceptionsOn()
282+
/**
283+
* @test
284+
*/
285+
public function ignoreExceptionsOn()
233286
{
234287
$aBlocks = $this->oDocument->getAllDeclarationBlocks();
235288
$oFirstBlock = $aBlocks[0];
236289
$oFirstBlock->removeSelector('.main');
237290
$oFirstBlock->removeSelector('.test');
238-
$this->assertSame(
291+
self::assertSame(
239292
'@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}',
240293
$this->oDocument->render(OutputFormat::create()->setIgnoreExceptions(true))
241294
);

0 commit comments

Comments
 (0)