Blogger Information
Blog 142
fans 5
comment 0
visits 130549
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
编写测试用例 phpunit
php开发大牛
Original
732 people have browsed it

<?php

$basedir = dirname(__FILE__);

require_once($basedir . '/lib/basetestdev.php');

define("PHONE", "xxx");

define("PWD", "xxx");

define("POSTURL","xxx");

class TestAPI extends PHPUnit_Framework_TestCase {

    private function call_http($path, $param, $expect = 'ok') {

        $_param = build_get_param($param);

        $url = PREFIX . "$path?" . $_param;

        $buf = do_Get($url);

        $obj = json_decode($buf, True);

        $this->assertEquals($obj['retval'], $expect);

        return $obj;

    }

    private function call_https($path, $param, $expect = 'ok') {

        $_param = build_get_param($param);

        $url = HTTPSPREFIX . "$path?" . $_param;

        $buf = do_Get($url);

        $obj = json_decode($buf, True);

        $this->assertEquals($obj['retval'], $expect);

        return $obj;

    }

  public function testLogin(){

    $param = array(

      'type' => 'phone'

      ,'token' => PHONE

      ,'password' => PWD

    );

    $url = 'login';

    return $this->call_http($url, $param);

  }

  /**

   * @depends testLogin

   */

  public function testInfo(array $user){

    $session = $user['retinfo']['session'];

    $param = array(

      'session' => $session

    );

    $url ='info';

    return $this->call_http($url, $param);

  }


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post