@@ -15,26 +15,7 @@ public function setUp()
1515 $ this ->linter = new \CssLint \Linter ();
1616 }
1717
18- public function testLintBootstrapCssFile ()
19- {
20- $ this ->assertTrue ($ this ->linter ->lintFile (getcwd () . DIRECTORY_SEPARATOR . '_files/bootstrap.css ' ), print_r ($ this ->linter ->getErrors (), true ));
21- }
22-
23- public function testLintFoundationCssFile ()
24- {
25- $ this ->assertTrue ($ this ->linter ->lintFile (getcwd () . DIRECTORY_SEPARATOR . '_files/foundation.css ' ), print_r ($ this ->linter ->getErrors (), true ));
26- }
27-
28- public function testLintNotValidCssFile ()
29- {
30- $ this ->assertFalse ($ this ->linter ->lintFile (getcwd () . DIRECTORY_SEPARATOR . '_files/not_valid.css ' ));
31- $ this ->assertSame (array (
32- 'Unknown CSS property "bordr-top-style" (line: 8, char: 20) ' ,
33- 'Unexpected char ":" (line: 15, char: 5) '
34- ), $ this ->linter ->getErrors ());
35- }
36-
37- public function testLintString ()
18+ public function testLintValidString ()
3819 {
3920 $ this ->assertTrue ($ this ->linter ->lintString ('.button.dropdown::after {
4021 display: block;
@@ -55,4 +36,71 @@ public function testLintString()
5536 float: none;
5637 margin-left: 0; } ' ));
5738 }
39+
40+ public function testLintNotValidString ()
41+ {
42+ $ this ->assertFalse ($ this ->linter ->lintString ('.button.dropdown::after {
43+ displady: block;
44+ width: 0;
45+ :
46+ ' ));
47+ $ this ->assertSame (array (
48+ 'Unknown CSS property "displady" (line: 2, char: 22) ' ,
49+ 'Unexpected char ":" (line: 4, char: 5) ' ,
50+ ), $ this ->linter ->getErrors ());
51+ }
52+
53+ public function testLintStringWithUnterminatedContext ()
54+ {
55+ $ this ->assertFalse ($ this ->linter ->lintString ('* { ' ));
56+ $ this ->assertSame (array (
57+ 'Unterminated "selector content" (line: 1, char: 3) '
58+ ), $ this ->linter ->getErrors ());
59+ }
60+
61+ /**
62+ * @expectedException \InvalidArgumentException
63+ * @expectedExceptionMessage Argument "$sString" expects a string, "boolean" given
64+ */
65+ public function testLintStringWithWrongTypeParam ()
66+ {
67+ $ this ->linter ->lintString (false );
68+ }
69+
70+ /**
71+ * @expectedException \InvalidArgumentException
72+ * @expectedExceptionMessage Argument "$sFilePath" expects a string, "boolean" given
73+ */
74+ public function testLintFileWithWrongTypeParam ()
75+ {
76+ $ this ->linter ->lintFile (false );
77+ }
78+
79+ /**
80+ * @expectedException \InvalidArgumentException
81+ * @expectedExceptionMessage Argument "$sFilePath" "wrong" is not an existing file path
82+ */
83+ public function testLintFileWithUnkownFilePathParam ()
84+ {
85+ $ this ->linter ->lintFile ('wrong ' );
86+ }
87+
88+ public function testLintBootstrapCssFile ()
89+ {
90+ $ this ->assertTrue ($ this ->linter ->lintFile (getcwd () . DIRECTORY_SEPARATOR . '_files/bootstrap.css ' ), print_r ($ this ->linter ->getErrors (), true ));
91+ }
92+
93+ public function testLintFoundationCssFile ()
94+ {
95+ $ this ->assertTrue ($ this ->linter ->lintFile (getcwd () . DIRECTORY_SEPARATOR . '_files/foundation.css ' ), print_r ($ this ->linter ->getErrors (), true ));
96+ }
97+
98+ public function testLintNotValidCssFile ()
99+ {
100+ $ this ->assertFalse ($ this ->linter ->lintFile (getcwd () . DIRECTORY_SEPARATOR . '_files/not_valid.css ' ));
101+ $ this ->assertSame (array (
102+ 'Unknown CSS property "bordr-top-style" (line: 8, char: 20) ' ,
103+ 'Unterminated "selector content" (line: 17, char: 0) '
104+ ), $ this ->linter ->getErrors ());
105+ }
58106}
0 commit comments