how to unit test curl call in php

后端 未结 6 1442
既然无缘
既然无缘 2020-12-12 20:41

How would you go about unit testing a curl implementation?

  public function get() {
    $ch = curl_init($this->request->getUrl());

    curl_setopt($c         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 21:29

    Do not use curl directly but through a wrapper like PEAR's HTTP_Request2. With it, you have the ability to exchange the curl driver with a mock driver - ideal for unit tests.

提交回复
热议问题