|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Sabberworm\CSS\Tests\Unit; |
| 6 | + |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use Sabberworm\CSS\OutputFormat; |
| 9 | + |
| 10 | +/** |
| 11 | + * @covers \Sabberworm\CSS\OutputFormat |
| 12 | + */ |
| 13 | +final class OutputFormatTest extends TestCase |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @var OutputFormat |
| 17 | + */ |
| 18 | + private $subject; |
| 19 | + |
| 20 | + protected function setUp(): void |
| 21 | + { |
| 22 | + $this->subject = new OutputFormat(); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * @test |
| 27 | + */ |
| 28 | + public function getStringQuotingTypeInitiallyReturnsDoubleQuote(): void |
| 29 | + { |
| 30 | + self::assertSame('"', $this->subject->getStringQuotingType()); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @test |
| 35 | + */ |
| 36 | + public function setStringQuotingTypeSetsStringQuotingType(): void |
| 37 | + { |
| 38 | + $value = 'x'; |
| 39 | + $this->subject->setStringQuotingType($value); |
| 40 | + |
| 41 | + self::assertSame($value, $this->subject->getStringQuotingType()); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @test |
| 46 | + */ |
| 47 | + public function setStringQuotingTypeProvidesFluentInterface(): void |
| 48 | + { |
| 49 | + self::assertSame($this->subject, $this->subject->setStringQuotingType('x')); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @test |
| 54 | + */ |
| 55 | + public function getRGBHashNotationInitiallyReturnsTrue(): void |
| 56 | + { |
| 57 | + self::assertTrue($this->subject->getRGBHashNotation()); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * @return array<string, array{0: bool}> |
| 62 | + */ |
| 63 | + public static function provideBooleans(): array |
| 64 | + { |
| 65 | + return [ |
| 66 | + 'true' => [true], |
| 67 | + 'false' => [false], |
| 68 | + ]; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * @test |
| 73 | + * |
| 74 | + * @dataProvider provideBooleans |
| 75 | + */ |
| 76 | + public function setRGBHashNotationSetsRGBHashNotation(bool $value): void |
| 77 | + { |
| 78 | + $this->subject->setRGBHashNotation($value); |
| 79 | + |
| 80 | + self::assertSame($value, $this->subject->getRGBHashNotation()); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * @test |
| 85 | + */ |
| 86 | + public function setRGBHashNotationProvidesFluentInterface(): void |
| 87 | + { |
| 88 | + self::assertSame($this->subject, $this->subject->setRGBHashNotation(true)); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * @test |
| 93 | + */ |
| 94 | + public function getSemicolonAfterLastRuleInitiallyReturnsTrue(): void |
| 95 | + { |
| 96 | + self::assertTrue($this->subject->getSemicolonAfterLastRule()); |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * @test |
| 101 | + * |
| 102 | + * @dataProvider provideBooleans |
| 103 | + */ |
| 104 | + public function setSemicolonAfterLastRuleSetsSemicolonAfterLastRule(bool $value): void |
| 105 | + { |
| 106 | + $this->subject->setSemicolonAfterLastRule($value); |
| 107 | + |
| 108 | + self::assertSame($value, $this->subject->getSemicolonAfterLastRule()); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * @test |
| 113 | + */ |
| 114 | + public function setSemicolonAfterLastRuleProvidesFluentInterface(): void |
| 115 | + { |
| 116 | + self::assertSame($this->subject, $this->subject->setSemicolonAfterLastRule(true)); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * @test |
| 121 | + */ |
| 122 | + public function getSpaceAfterRuleNameInitiallyReturnsSingleSpace(): void |
| 123 | + { |
| 124 | + self::assertSame(' ', $this->subject->getSpaceAfterRuleName()); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * @test |
| 129 | + */ |
| 130 | + public function setSpaceAfterRuleNameSetsSpaceAfterRuleName(): void |
| 131 | + { |
| 132 | + $value = ' '; |
| 133 | + $this->subject->setSpaceAfterRuleName($value); |
| 134 | + |
| 135 | + self::assertSame($value, $this->subject->getSpaceAfterRuleName()); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * @test |
| 140 | + */ |
| 141 | + public function setSpaceAfterRuleNameProvidesFluentInterface(): void |
| 142 | + { |
| 143 | + self::assertSame($this->subject, $this->subject->setSpaceAfterRuleName(' ')); |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * @test |
| 148 | + */ |
| 149 | + public function getSpaceBeforeRulesInitiallyReturnsEmptyString(): void |
| 150 | + { |
| 151 | + self::assertSame('', $this->subject->getSpaceBeforeRules()); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * @test |
| 156 | + */ |
| 157 | + public function setSpaceBeforeRulesSetsSpaceBeforeRules(): void |
| 158 | + { |
| 159 | + $value = ' '; |
| 160 | + $this->subject->setSpaceBeforeRules($value); |
| 161 | + |
| 162 | + self::assertSame($value, $this->subject->getSpaceBeforeRules()); |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * @test |
| 167 | + */ |
| 168 | + public function setSpaceBeforeRulesProvidesFluentInterface(): void |
| 169 | + { |
| 170 | + self::assertSame($this->subject, $this->subject->setSpaceBeforeRules(' ')); |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * @test |
| 175 | + */ |
| 176 | + public function getSpaceAfterRulesInitiallyReturnsEmptyString(): void |
| 177 | + { |
| 178 | + self::assertSame('', $this->subject->getSpaceAfterRules()); |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * @test |
| 183 | + */ |
| 184 | + public function setSpaceAfterRulesSetsSpaceAfterRules(): void |
| 185 | + { |
| 186 | + $value = ' '; |
| 187 | + $this->subject->setSpaceAfterRules($value); |
| 188 | + |
| 189 | + self::assertSame($value, $this->subject->getSpaceAfterRules()); |
| 190 | + } |
| 191 | + |
| 192 | + /** |
| 193 | + * @test |
| 194 | + */ |
| 195 | + public function setSpaceAfterRulesProvidesFluentInterface(): void |
| 196 | + { |
| 197 | + self::assertSame($this->subject, $this->subject->setSpaceAfterRules(' ')); |
| 198 | + } |
| 199 | + |
| 200 | + /** |
| 201 | + * @test |
| 202 | + */ |
| 203 | + public function getSpaceBetweenRulesInitiallyReturnsEmptyString(): void |
| 204 | + { |
| 205 | + self::assertSame('', $this->subject->getSpaceBetweenRules()); |
| 206 | + } |
| 207 | + |
| 208 | + /** |
| 209 | + * @test |
| 210 | + */ |
| 211 | + public function setSpaceBetweenRulesSetsSpaceBetweenRules(): void |
| 212 | + { |
| 213 | + $value = ' '; |
| 214 | + $this->subject->setSpaceBetweenRules($value); |
| 215 | + |
| 216 | + self::assertSame($value, $this->subject->getSpaceBetweenRules()); |
| 217 | + } |
| 218 | + |
| 219 | + /** |
| 220 | + * @test |
| 221 | + */ |
| 222 | + public function setSpaceBetweenRulesProvidesFluentInterface(): void |
| 223 | + { |
| 224 | + self::assertSame($this->subject, $this->subject->setSpaceBetweenRules(' ')); |
| 225 | + } |
| 226 | + |
| 227 | + /** |
| 228 | + * @test |
| 229 | + */ |
| 230 | + public function getSpaceBeforeBlocksInitiallyReturnsEmptyString(): void |
| 231 | + { |
| 232 | + self::assertSame('', $this->subject->getSpaceBeforeBlocks()); |
| 233 | + } |
| 234 | + |
| 235 | + /** |
| 236 | + * @test |
| 237 | + */ |
| 238 | + public function setSpaceBeforeBlocksSetsSpaceBeforeBlocks(): void |
| 239 | + { |
| 240 | + $value = ' '; |
| 241 | + $this->subject->setSpaceBeforeBlocks($value); |
| 242 | + |
| 243 | + self::assertSame($value, $this->subject->getSpaceBeforeBlocks()); |
| 244 | + } |
| 245 | + |
| 246 | + /** |
| 247 | + * @test |
| 248 | + */ |
| 249 | + public function setSpaceBeforeBlocksProvidesFluentInterface(): void |
| 250 | + { |
| 251 | + self::assertSame($this->subject, $this->subject->setSpaceBeforeBlocks(' ')); |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * @test |
| 256 | + */ |
| 257 | + public function getSpaceAfterBlocksInitiallyReturnsEmptyString(): void |
| 258 | + { |
| 259 | + self::assertSame('', $this->subject->getSpaceAfterBlocks()); |
| 260 | + } |
| 261 | + |
| 262 | + /** |
| 263 | + * @test |
| 264 | + */ |
| 265 | + public function setSpaceAfterBlocksSetsSpaceAfterBlocks(): void |
| 266 | + { |
| 267 | + $value = ' '; |
| 268 | + $this->subject->setSpaceAfterBlocks($value); |
| 269 | + |
| 270 | + self::assertSame($value, $this->subject->getSpaceAfterBlocks()); |
| 271 | + } |
| 272 | + |
| 273 | + /** |
| 274 | + * @test |
| 275 | + */ |
| 276 | + public function setSpaceAfterBlocksProvidesFluentInterface(): void |
| 277 | + { |
| 278 | + self::assertSame($this->subject, $this->subject->setSpaceAfterBlocks(' ')); |
| 279 | + } |
| 280 | + |
| 281 | + /** |
| 282 | + * @test |
| 283 | + */ |
| 284 | + public function getSpaceBetweenBlocksInitiallyReturnsNewline(): void |
| 285 | + { |
| 286 | + self::assertSame("\n", $this->subject->getSpaceBetweenBlocks()); |
| 287 | + } |
| 288 | + |
| 289 | + /** |
| 290 | + * @test |
| 291 | + */ |
| 292 | + public function setSpaceBetweenBlocksSetsSpaceBetweenBlocks(): void |
| 293 | + { |
| 294 | + $value = ' '; |
| 295 | + $this->subject->setSpaceBetweenBlocks($value); |
| 296 | + |
| 297 | + self::assertSame($value, $this->subject->getSpaceBetweenBlocks()); |
| 298 | + } |
| 299 | + |
| 300 | + /** |
| 301 | + * @test |
| 302 | + */ |
| 303 | + public function setSpaceBetweenBlocksProvidesFluentInterface(): void |
| 304 | + { |
| 305 | + self::assertSame($this->subject, $this->subject->setSpaceBetweenBlocks(' ')); |
| 306 | + } |
| 307 | +} |
0 commit comments