php - Unable to find wrapper when testing Guzzle call with PHPUnit -


i writing unit test api developing. api written in codeigniter framework, calls api using guzzle. test writing verifies api call returns correct response.

the test.php file contains following code

require '/application/libraries/apiwrappers/breathehr.php';  class breathehrtest extends phpunit_framework_testcase {      public function testcanreturnemployeearray() {         $breathehr = new breathehr();          $employees = $breathehr->list_employees(1);         $this->assertarrayhaskey('employees', $employees);     }   } 

the method being tested follows

class breathehr {      function __construct() {      }      public function list_employees($page)     {         $client = new guzzlehttp\client(             ['base_uri' => 'https://xxx/',                 'headers' => ['x-api-key' => 'xxx'],                 'verify' => false]         );          $request = $client->get('employees?page='.$page);         $employees = json_decode($request->getbody(true));          $employeedata = array(             'employees' => array(),             'pagination' => array()         );          $i = 0;         foreach($employees->employees $employee) {             if($employee->status !== 'ex-employee') {                 $employeedata['employees'][$i]['firstname'] = $employee->first_name;                 $employeedata['employees'][$i]['lastname'] = $employee->last_name;                 $employeedata['employees'][$i]['jobtitle'] = $employee->job_title;                 if(isset($employee->line_manager)) {                     $employeedata['employees'][$i]['linemanagername'] = $employee->line_manager->first_name . ' '. $employee->line_manager->last_name;                     $employeedata['employees'][$i]['linemanagerid'] = $employee->line_manager->id;                 }                 $employeedata['employees'][$i]['workinghours'] = $employee->full_or_part_time;                 $employeedata['employees'][$i]['email'] = $employee->email;                 $employeedata['employees'][$i]['workphone'] = $employee->ddi;                 $employeedata['employees'][$i]['personalmobile'] = $employee->personal_mobile;                 $employeedata['employees'][$i]['hometelephone'] = $employee->home_telephone;                 $employeedata['employees'][$i]['birthday'] = $employee->dob;                 $i++;             }         }          $nextlink = $request->getheader('link');         $nextlinksplit = explode(',', $nextlink[0]);          $pageination = array();          foreach($nextlinksplit $data) {             $split = explode(';', $data);             preg_match('/"(.*?)"/', $split[1], $keymatch);             $key = isset($keymatch[1]) ? $keymatch[1] : false;             $number = substr($split[0], -2, 1);              $pageination[$key] = $number;         }          array_push($employeedata['pagination'], $pageination);          return $employeedata;     }  } 

the api call works correctly via postman , browser, result of running phpunit command line following

runtimeexception: error creating resource: [message] fopen(): unable find wrapper "https" - did forget enable when configured php?

[message] fopen(https://api.breathehr.com/v1/employees?page=1): failed open stream: no such file or directory

i have googled error message , came across post unable find wrapper "https" - did forget enable when configured php?

making these changes has made no difference. it's worth noting on localhost, running mamp.

any ideas?

thanks

sometime cli use different php.ini apache, settings made through wamp menu don't apply cli.

check if correct extension loaded launching

command php -i | grep ssl  

in same manner can locate php.ini script:

php -i | grep ini 

hope help


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -