PHP Classes
elePHPant
Icontem

File: HttpTest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Lukasz Cepowski  >  Mock HTTP Server  >  HttpTest.php  >  Download  
File: HttpTest.php
Role: Unit test script
Content type: text/plain
Description: Sample unit test.
Class: Mock HTTP Server
Setup and start a HTTP server for testing purposes
Author: By
Last change:
Date: 2 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();
    }

}