Skip to content

Commit 577b99a

Browse files
authored
[TASK] Add some basic tests for CSSString (#999)
Part of #757
1 parent 6d9656c commit 577b99a

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

config/phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ parameters:
414414
count: 1
415415
path: ../src/RuleSet/RuleSet.php
416416

417+
-
418+
message: '#^Parameters should have "string" types as the only types passed to this method$#'
419+
identifier: typePerfect.narrowPublicClassMethodParamType
420+
count: 1
421+
path: ../src/Value/CSSString.php
422+
417423
-
418424
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
419425
identifier: notEqual.notAllowed

tests/Unit/Value/CSSStringTest.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabberworm\CSS\Tests\Unit\Value;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\Value\CSSString;
9+
use Sabberworm\CSS\Value\PrimitiveValue;
10+
use Sabberworm\CSS\Value\Value;
11+
12+
/**
13+
* @covers \Sabberworm\CSS\Value\CSSString
14+
* @covers \Sabberworm\CSS\Value\PrimitiveValue
15+
* @covers \Sabberworm\CSS\Value\Value
16+
*/
17+
final class CSSStringTest extends TestCase
18+
{
19+
/**
20+
* @test
21+
*/
22+
public function isPrimitiveValue(): void
23+
{
24+
$subject = new CSSString('');
25+
26+
self::assertInstanceOf(PrimitiveValue::class, $subject);
27+
}
28+
29+
/**
30+
* @test
31+
*/
32+
public function isValue(): void
33+
{
34+
$subject = new CSSString('');
35+
36+
self::assertInstanceOf(Value::class, $subject);
37+
}
38+
39+
/**
40+
* @test
41+
*/
42+
public function getStringReturnsStringProvidedToConstructor(): void
43+
{
44+
$string = 'coffee';
45+
$subject = new CSSString($string);
46+
47+
self::assertSame($string, $subject->getString());
48+
}
49+
50+
/**
51+
* @test
52+
*/
53+
public function setStringSetsString(): void
54+
{
55+
$subject = new CSSString('');
56+
$string = 'coffee';
57+
58+
$subject->setString($string);
59+
60+
self::assertSame($string, $subject->getString());
61+
}
62+
63+
/**
64+
* @test
65+
*/
66+
public function getLineNoByDefaultReturnsZero(): void
67+
{
68+
$subject = new CSSString('');
69+
70+
self::assertSame(0, $subject->getLineNo());
71+
}
72+
73+
/**
74+
* @test
75+
*/
76+
public function getLineNoReturnsLineNumberProvidedToConstructor(): void
77+
{
78+
$lineNumber = 42;
79+
80+
$subject = new CSSString('', $lineNumber);
81+
82+
self::assertSame($lineNumber, $subject->getLineNo());
83+
}
84+
}

0 commit comments

Comments
 (0)