Skip to content

Commit 6a09851

Browse files
oliverkleeJakeQZ
andauthored
[TASK] Add some basic unit tests for URL (#1164)
Part of #757 Co-authored-by: JakeQZ <jake.github@qzdesign.co.uk>
1 parent 7e688fc commit 6a09851

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

tests/Unit/Value/URLTest.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\URL;
11+
use Sabberworm\CSS\Value\Value;
12+
13+
/**
14+
* @covers \Sabberworm\CSS\Value\PrimitiveValue
15+
* @covers \Sabberworm\CSS\Value\URL
16+
* @covers \Sabberworm\CSS\Value\Value
17+
*/
18+
final class URLTest extends TestCase
19+
{
20+
/**
21+
* @test
22+
*/
23+
public function isPrimitiveValue(): void
24+
{
25+
$subject = new URL(new CSSString('http://example.com'));
26+
27+
self::assertInstanceOf(PrimitiveValue::class, $subject);
28+
}
29+
30+
/**
31+
* @test
32+
*/
33+
public function isValue(): void
34+
{
35+
$subject = new URL(new CSSString('http://example.com'));
36+
37+
self::assertInstanceOf(Value::class, $subject);
38+
}
39+
40+
/**
41+
* @test
42+
*/
43+
public function getUrlByDefaultReturnsUrlProvidedToConstructor(): void
44+
{
45+
$subject = new CSSString('http://example.com');
46+
47+
self::assertSame($subject, (new URL($subject))->getURL());
48+
}
49+
50+
/**
51+
* @test
52+
*/
53+
public function setUrlReplacesUrl(): void
54+
{
55+
$subject = new URL(new CSSString('http://example.com'));
56+
57+
$newUrl = new CSSString('http://example.org');
58+
$subject->setURL($newUrl);
59+
60+
self::assertSame($newUrl, $subject->getURL());
61+
}
62+
63+
/**
64+
* @test
65+
*/
66+
public function getLineNoByDefaultReturnsZero(): void
67+
{
68+
$subject = new URL(new CSSString('http://example.com'));
69+
70+
self::assertSame(0, $subject->getLineNo());
71+
}
72+
73+
/**
74+
* @test
75+
*/
76+
public function getLineNoReturnsLineNumberProvidedToConstructor(): void
77+
{
78+
$lineNumber = 17;
79+
80+
$subject = new URL(new CSSString('http://example.com'), $lineNumber);
81+
82+
self::assertSame($lineNumber, $subject->getLineNo());
83+
}
84+
}

0 commit comments

Comments
 (0)