HEX
Server: LiteSpeed
System: Linux srv1.dhviews.com 5.14.0-570.23.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 24 11:27:16 EDT 2025 x86_64
User: bdedition (1723)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/bdedition/www/core/vendor/sendgrid/php-http-client/test/unit/ResponseTest.php
<?php

namespace SendGrid\Test;

use PHPUnit\Framework\TestCase;
use SendGrid\Response;

class ResponseTest extends TestCase
{
    public function testConstructor()
    {
        $response = new Response();

        $this->assertEquals(200, $response->statusCode());
        $this->assertEquals('', $response->body());
        $this->assertEquals([], $response->headers());

        $response = new Response(201, 'test', ['Content-Encoding: gzip']);

        $this->assertEquals(201, $response->statusCode());
        $this->assertEquals('test', $response->body());
        $this->assertEquals(['Content-Encoding: gzip'], $response->headers());
    }

    public function testStatusCode()
    {
        $response = new Response(404);

        $this->assertEquals(404, $response->statusCode());
    }

    public function testBody()
    {
        $response = new Response(null, 'foo');

        $this->assertEquals('foo', $response->body());
    }

    public function testHeaders()
    {
        $response = new Response(null, null, ['Content-Type: text/html']);

        $this->assertEquals(['Content-Type: text/html'], $response->headers());
    }

    public function testAssociativeHeaders()
    {
        $response = new Response(null, null, ['Content-Type: text/html', 'HTTP/1.1 200 OK']);

        $this->assertEquals(['Content-Type' => 'text/html', 'Status' => 'HTTP/1.1 200 OK'], $response->headers(true));
    }
}