PHP Classes

File: test/Response/ResponseTest.php

Recommend this page to a friend!
  Classes of nvb   PHP CURL Component   test/Response/ResponseTest.php   Download  
File: test/Response/ResponseTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP CURL Component
Compose and execute HTTP requests with Curl
Author: By
Last change: replaced >>array()<< notation with >>[]<<
Date: 7 years ago
Size: 2,218 bytes
 

Contents

Class file image Download
<?php
/**
 * @author: stev leibelt <artodeto@bazzline.net>
 * @since: 2015-12-14
 */

namespace Test\Net\Bazzline\Component\Curl;

class
ResponseTest extends AbstractTestCase
{
    public function
testHeaderLineWithExistingPrefixes()
    {
       
$content = 'the content';
       
$contentType = 'the content type';
       
$error = 'this is an error';
       
$errorCode = __LINE__;
       
$headerLines = [
           
'bar' => 'foo',
           
'foo' => 'bar'
       
];
       
$statusCode = __LINE__;

       
$response = $this->getNewResponse($content, $contentType, $error, $errorCode, $headerLines, $statusCode);

        foreach (
$headerLines as $prefix => $suffix) {
           
$this->assertEquals($suffix, $response->headerLine($prefix));
        }
    }

   
/**
     * @expectedException \InvalidArgumentException
     * @expectedExceptionMessage no headline available for prefix: "foobar"
     */
   
public function testHeaderLineWithNotExistingPrefixes()
    {
       
$content = 'the content';
       
$contentType = 'the content type';
       
$error = 'this is an error';
       
$errorCode = __LINE__;
       
$headerLines = [];
       
$statusCode = __LINE__;

       
$response = $this->getNewResponse($content, $contentType, $error, $errorCode, $headerLines, $statusCode);

       
$this->assertEquals(null, $response->headerLine('foobar'));
    }

    public function
testAll()
    {
       
$content = 'the content';
       
$contentType = 'the content type';
       
$error = 'this is an error';
       
$errorCode = __LINE__;
       
$headerLines = [];
       
$statusCode = __LINE__;

       
$response = $this->getNewResponse($content, $contentType, $error, $errorCode, $headerLines, $statusCode);

       
$this->assertEquals($content, $response->content());
       
$this->assertEquals($contentType, $response->contentType());
       
$this->assertEquals($error, $response->error());
       
$this->assertEquals($errorCode, $response->errorCode());
       
$this->assertEquals($headerLines, $response->headerLines());
       
$this->assertEquals($statusCode, $response->statusCode());
    }
}