Skip to content

Commit 0a70406

Browse files
committed
Class ordering from PHPCSFixer
1 parent 86c527c commit 0a70406

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

src/PHPFUI/HTMLUnitTester/Extensions.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,45 @@ public static function setUpBeforeClass() : void
3232
self::$validator = new \HtmlValidator\Validator($url);
3333
}
3434

35+
/**
36+
* Validate all files in a directory.
37+
*
38+
* @param string $type one of 'Valid' (html), 'NotWarning' (html), 'ValidCSS', or 'NotWarningCSS'
39+
* @param array<string> $extensions
40+
*/
41+
public function assertDirectory(string $type, string $directory, string $message = '', bool $recurseSubdirectories = true, array $extensions = ['.css']) : void
42+
{
43+
$this->assertContains($type, ['Valid', 'NotWarning', 'ValidCSS', 'NotWarningCSS'], 'Invalid parameter for ' . __METHOD__);
44+
$method = "assert{$type}File";
45+
46+
if ($recurseSubdirectories)
47+
{
48+
$iterator = new \RecursiveIteratorIterator(
49+
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
50+
\RecursiveIteratorIterator::SELF_FIRST
51+
);
52+
}
53+
else
54+
{
55+
$iterator = new \DirectoryIterator($directory);
56+
}
57+
$exts = \array_flip($extensions);
58+
59+
foreach ($iterator as $item)
60+
{
61+
if ('file' == $item->getType())
62+
{
63+
$file = $item->getPathname();
64+
$ext = \strrchr($file, '.');
65+
66+
if ($ext && isset($exts[$ext]))
67+
{
68+
$this->{$method}($file, $message . ' File: ' . $file);
69+
}
70+
}
71+
}
72+
}
73+
3574
public function assertNotWarningCss(string $css, string $message = '') : void
3675
{
3776
$response = $this->validateCss($css);
@@ -80,45 +119,6 @@ public function assertValidCss(string $css, string $message = '') : void
80119
self::assertThat($response, new ErrorConstraint(), $message);
81120
}
82121

83-
/**
84-
* Validate all files in a directory.
85-
*
86-
* @param string $type one of 'Valid' (html), 'NotWarning' (html), 'ValidCSS', or 'NotWarningCSS'
87-
* @param array<string> $extensions
88-
*/
89-
public function assertDirectory(string $type, string $directory, string $message = '', bool $recurseSubdirectories = true, array $extensions = ['.css']) : void
90-
{
91-
$this->assertContains($type, ['Valid', 'NotWarning', 'ValidCSS', 'NotWarningCSS'], 'Invalid parameter for ' . __METHOD__);
92-
$method = "assert{$type}File";
93-
94-
if ($recurseSubdirectories)
95-
{
96-
$iterator = new \RecursiveIteratorIterator(
97-
new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS),
98-
\RecursiveIteratorIterator::SELF_FIRST
99-
);
100-
}
101-
else
102-
{
103-
$iterator = new \DirectoryIterator($directory);
104-
}
105-
$exts = \array_flip($extensions);
106-
107-
foreach ($iterator as $item)
108-
{
109-
if ('file' == $item->getType())
110-
{
111-
$file = $item->getPathname();
112-
$ext = \strrchr($file, '.');
113-
114-
if ($ext && isset($exts[$ext]))
115-
{
116-
$this->{$method}($file, $message . ' File: ' . $file);
117-
}
118-
}
119-
}
120-
}
121-
122122
public function assertValidCssFile(string $file, string $message = '') : void
123123
{
124124
$response = $this->validateCss($this->getFromFile($file));

tests/UnitTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
*/
1212
class UnitTest extends \PHPFUI\HTMLUnitTester\Extensions
1313
{
14+
public function testDirectory() : void
15+
{
16+
$this->assertDirectory('ValidCSS', 'examples');
17+
$this->assertDirectory('Valid', 'examples');
18+
$this->assertDirectory('NotWarning', 'examples');
19+
$this->assertDirectory('NotWarningCSS', 'examples');
20+
}
21+
1422
public function testNotWarningCss() : void
1523
{
1624
$this->assertNotWarningCss('strong {font-weight: bolder;}');
@@ -71,12 +79,4 @@ public function testValidUrl() : void
7179
{
7280
$this->assertValidUrl('https://raw.githubusercontent.com/phpfui/HTMLUnitTester/master/examples/valid.html');
7381
}
74-
75-
public function testDirectory() : void
76-
{
77-
$this->assertDirectory('ValidCSS', 'examples');
78-
$this->assertDirectory('Valid', 'examples');
79-
$this->assertDirectory('NotWarning', 'examples');
80-
$this->assertDirectory('NotWarningCSS', 'examples');
81-
}
8282
}

0 commit comments

Comments
 (0)