# wp-optimize/3.2.5/vendor/rosell-dk/file-util/tests/PathValidatorTest.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 3.2.5. 66 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/3.2.5/code/vendor/rosell-dk/file-util/tests/PathValidatorTest.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/3.2.5/raw/vendor/rosell-dk/file-util/tests/PathValidatorTest.php
- Modified: 2022-06-03T18:20:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/3.2.5/code/vendor/rosell-dk/file-util/tests/PathValidatorTest.php#L10-L20`.

```php
<?php

namespace FileUtil\Tests;

use PHPUnit\Framework\TestCase;
use FileUtil\PathValidator;
use org\bovigo\vfs\vfsStream;

class PathValidatorTest extends TestCase
{
    public function testFilenameNotString()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkPath(10);
        //$this->mimeSniff(10);
    }

    public function testFilenameHasNULChar()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkPath("a\0");
    }
    public function testFilenameHasControlChars()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkPath("..\1..");
    }

    public function testFilenameIsEmpty()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkPath("");
    }

    public function testFilenameIsPhar()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkPath('phar://aoeu');
    }

    public function testFileNotFound()
    {
       // why does this fail in PHP 7.2 ? (Uninitialized string offset: 0)
        $this->expectException(\Exception::class);
        PathValidator::checkFilePathIsRegularFile(__DIR__ . '/images/no-such-file.jpg');
    }
    public function testFileIsDir()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkFilePathIsRegularFile(__DIR__ . '/images');
    }

    public function testFileOnWebNotFound()
    {
       // why does this fail in PHP 7.2 ? (Uninitialized string offset: 0)
        $this->expectException(\Exception::class);
        PathValidator::checkFilePathIsRegularFile('http://aoeuhtaoeu.eau');
    }

    public function testPhPStreamWrapper()
    {
        $this->expectException(\Exception::class);
        PathValidator::checkFilePathIsRegularFile('php://input');
    }
}

```
