PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / file-util / tests / PathValidatorTest.php

PathValidatorTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/file-util/tests/PathValidatorTest.php

66 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FileUtil\Tests;
4
5 use PHPUnit\Framework\TestCase;
6 use FileUtil\PathValidator;
7 use org\bovigo\vfs\vfsStream;
8
9 class PathValidatorTest extends TestCase
10 {
11 public function testFilenameNotString()
12 {
13 $this->expectException(\Exception::class);
14 PathValidator::checkPath(10);
15 //$this->mimeSniff(10);
16 }
17
18 public function testFilenameHasNULChar()
19 {
20 $this->expectException(\Exception::class);
21 PathValidator::checkPath("a\0");
22 }
23 public function testFilenameHasControlChars()
24 {
25 $this->expectException(\Exception::class);
26 PathValidator::checkPath("..\1..");
27 }
28
29 public function testFilenameIsEmpty()
30 {
31 $this->expectException(\Exception::class);
32 PathValidator::checkPath("");
33 }
34
35 public function testFilenameIsPhar()
36 {
37 $this->expectException(\Exception::class);
38 PathValidator::checkPath('phar://aoeu');
39 }
40
41 public function testFileNotFound()
42 {
43 // why does this fail in PHP 7.2 ? (Uninitialized string offset: 0)
44 $this->expectException(\Exception::class);
45 PathValidator::checkFilePathIsRegularFile(__DIR__ . '/images/no-such-file.jpg');
46 }
47 public function testFileIsDir()
48 {
49 $this->expectException(\Exception::class);
50 PathValidator::checkFilePathIsRegularFile(__DIR__ . '/images');
51 }
52
53 public function testFileOnWebNotFound()
54 {
55 // why does this fail in PHP 7.2 ? (Uninitialized string offset: 0)
56 $this->expectException(\Exception::class);
57 PathValidator::checkFilePathIsRegularFile('http://aoeuhtaoeu.eau');
58 }
59
60 public function testPhPStreamWrapper()
61 {
62 $this->expectException(\Exception::class);
63 PathValidator::checkFilePathIsRegularFile('php://input');
64 }
65 }
66