PHP Classes

File: test/HttpTest.php

Recommend this page to a friend!
  Classes of Lukasz Cepowski   Mock HTTP Server   test/HttpTest.php   Download  
File: test/HttpTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Mock HTTP Server
Setup and start a HTTP server for testing purposes
Author: By
Last change:
Date: 12 years ago
Size: 625 bytes
 

Contents

Class file image Download
<?php

require_once 'Mock_Http_Server.php';

class
HttpTest extends PHPUnit_Framework_TestCase
{

    public function
testConnect()
    {
       
$rootPath = dirname(dirname(__FILE__));
       
       
$server = new Mock_Http_Server();
       
$server
           
->setBinDir($rootPath.'/bin')
            ->
setWebDir($rootPath.'/web')
            ->
start();
       
       
$url = $server->getBaseUrl().'/mock/json.php';
       
$json = json_decode(file_get_contents($url));
       
$this->assertEquals(123, $json->a);
       
$this->assertEquals(456, $json->b);
               
       
$server->stop();
    }

}