GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: //proc/self/cwd/vendor/cloudinary/cloudinary_php/tests/Unit/HttpClientTest.php
<?php
/**
 * This file is part of the Cloudinary PHP package.
 *
 * (c) Cloudinary
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Cloudinary\Test\Unit;

use Cloudinary\Exception\Error;
use Cloudinary\HttpClient;
use Monolog\Logger as Monolog;
use ReflectionException;

/**
 * Class HttpClientTest
 */
final class HttpClientTest extends UnitTestCase
{
    /**
     * @throws ReflectionException
     */
    public function testLoggingParseInvalidJsonResponse()
    {
        $httpClient = new HttpClient();

        $message = null;
        $expectedLogMessage = 'Error parsing JSON server response';
        $expectedExceptionMessage = 'Error parsing server response';
        try {
            $httpClient->getJson('http://cloudinary.com/');
        } catch (Error $e) {
            $message = $e->getMessage();
        }

        self::assertStringStartsWith($expectedExceptionMessage, $message);
        self::assertObjectLoggedMessage($httpClient, $expectedLogMessage, Monolog::CRITICAL);
    }
}