Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/framework/Filesystem/Test/Unit/Driver/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/framework/Filesystem/Test/Unit/Driver/FileTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Framework\Filesystem\Test\Unit\Driver;

use Magento\Framework\Filesystem\Driver\File;
use PHPUnit\Framework\TestCase;

class FileTest extends TestCase
{
    /** @var string Result of file_get_contents() function */
    public static $fileGetContents;

    /** @var bool Result of file_put_contents() function */
    public static $filePutContents;

    /**
     * @inheritdoc
     */
    protected function setUp(): void
    {
        self::$fileGetContents = '';
        self::$filePutContents = true;
    }

    /**
     * Test for getAbsolutePath method.
     *
     * @dataProvider dataProviderForTestGetAbsolutePath
     * @param string $basePath
     * @param string $path
     * @param string $expected
     */
    public function testGetAbsolutePath(string $basePath, string $path, string $expected)
    {
        $file = new File();
        $this->assertEquals($expected, $file->getAbsolutePath($basePath, $path));
    }

    /**
     * Data provider for testGetAbsolutePath.
     *
     * @return array
     */
    public function dataProviderForTestGetAbsolutePath(): array
    {
        return [
            ['/root/path/', 'sub', '/root/path/sub'],
            ['/root/path/', '/sub', '/root/path/sub'],
            ['/root/path/', '../sub', '/root/path/../sub'],
            ['/root/path/', '/root/path/sub', '/root/path/sub'],
            ['', '', ''],
            ['0', '0', '0']
        ];
    }

    /**
     * Test for getRelativePath method.
     *
     * @dataProvider dataProviderForTestGetRelativePath
     * @param string $basePath
     * @param string $path
     * @param string $expected
     */
    public function testGetRelativePath(string $basePath, string $path, string $expected)
    {
        $file = new File();
        $this->assertEquals($expected, $file->getRelativePath($basePath, $path));
    }

    /**
     * Data provider for testGetRelativePath.
     *
     * @return array
     */
    public function dataProviderForTestGetRelativePath(): array
    {
        return [
            ['/root/path/', 'sub', 'sub'],
            ['/root/path/', '/sub', '/sub'],
            ['/root/path/', '/root/path/sub', 'sub'],
            ['/root/path/sub', '/root/path/other', '/root/path/other'],
            ['/root/path/', '', ''],
            ['0', '0', '']
        ];
    }

    /**
     * Test for getRealPathSafety method.
     *
     * @dataProvider dataProviderForTestGetRealPathSafety
     * @param string $path
     * @param string $expected
     */
    public function testGetRealPathSafety(string $path, string $expected)
    {
        $file = new File();
        $this->assertEquals($expected, $file->getRealPathSafety($path));
    }

    /**
     * Data provider for testGetRealPathSafety;
     *
     * @return array
     */
    public function dataProviderForTestGetRealPathSafety(): array
    {
        return [
            ['/1/2/3', '/1/2/3'],
            ['/1/.test', '/1/.test'],
            ['/1/..test', '/1/..test'],
            ['/1/.test/.test', '/1/.test/.test'],
            ['/1/2/./.', '/1/2'],
            ['/1/2/./././', '/1/2'],
            ['/1/2/3/../..', '/1'],
            ['/1/2/3/.', '/1/2/3'],
            ['/1/2/3/./4/5', '/1/2/3/4/5'],
            ['/1/2/3/../4/5', '/1/2/4/5'],
            ['1/2/.//.\3/4/..\..\5', '1/2/5'],
            ['\./.test', '/.test'],
            ['\\1/\\\.\..test', '/1/..test'],
            ['/1/2\\3\\\.', '/1/2/3']
        ];
    }
}

Spamworldpro Mini