Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); namespace App\Services; use PHPUnit\Framework\TestCase; ..

Decoded Output download

<?php

declare(strict_types=1);

namespace App\Services;

use PHPUnit\Framework\TestCase;

class CacheTest extends TestCase
{
    /**
     * @covers App\Services\Cache::getRedisConfig
     */
    public function testGetRedisConfig()
    {
        // Scenario 1: All parameters are set
        $_ENV['redis_host'] = 'localhost';
        $_ENV['redis_port'] = '6379';
        $_ENV['redis_connect_timeout'] = '1.0';
        $_ENV['redis_read_timeout'] = '1.0';
        $_ENV['redis_username'] = 'username';
        $_ENV['redis_password'] = 'password';
        $_ENV['redis_ssl'] = true;
        $_ENV['redis_ssl_context'] = [];

        $expected1 = [
            'host' => 'localhost',
            'port' => '6379',
            'connectTimeout' => '1.0',
            'readTimeout' => '1.0',
            'auth' => [
                'user' => 'username',
                'pass' => 'password',
            ],
            'ssl' => [],
        ];

        $result1 = Cache::getRedisConfig();
        $this->assertEquals($expected1, $result1);

        // Scenario 2: Optional parameters are not set
        $_ENV['redis_username'] = '';
        $_ENV['redis_password'] = '';
        $_ENV['redis_ssl'] = false;

        $expected2 = [
            'host' => 'localhost',
            'port' => '6379',
            'connectTimeout' => '1.0',
            'readTimeout' => '1.0',
        ];

        $result2 = Cache::getRedisConfig();
        $this->assertEquals($expected2, $result2);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace App\Services;

use PHPUnit\Framework\TestCase;

class CacheTest extends TestCase
{
    /**
     * @covers App\Services\Cache::getRedisConfig
     */
    public function testGetRedisConfig()
    {
        // Scenario 1: All parameters are set
        $_ENV['redis_host'] = 'localhost';
        $_ENV['redis_port'] = '6379';
        $_ENV['redis_connect_timeout'] = '1.0';
        $_ENV['redis_read_timeout'] = '1.0';
        $_ENV['redis_username'] = 'username';
        $_ENV['redis_password'] = 'password';
        $_ENV['redis_ssl'] = true;
        $_ENV['redis_ssl_context'] = [];

        $expected1 = [
            'host' => 'localhost',
            'port' => '6379',
            'connectTimeout' => '1.0',
            'readTimeout' => '1.0',
            'auth' => [
                'user' => 'username',
                'pass' => 'password',
            ],
            'ssl' => [],
        ];

        $result1 = Cache::getRedisConfig();
        $this->assertEquals($expected1, $result1);

        // Scenario 2: Optional parameters are not set
        $_ENV['redis_username'] = '';
        $_ENV['redis_password'] = '';
        $_ENV['redis_ssl'] = false;

        $expected2 = [
            'host' => 'localhost',
            'port' => '6379',
            'connectTimeout' => '1.0',
            'readTimeout' => '1.0',
        ];

        $result2 = Cache::getRedisConfig();
        $this->assertEquals($expected2, $result2);
    }
}

Function Calls

None

Variables

None

Stats

MD5 3028ea1072eb353ce8218d1288dbcc4f
Eval Count 0
Decode Time 100 ms