title: Unable to find wrapper when testing Guzzle call with PHPUnit
body: <p>I am writing a unit test for an API that I am developing. The API is written in the Codeigniter framework, that calls another API using Guzzle. The test I am writing verifies that the API call returns the correct response.</p>
  
  <p>The Test.php file contains the following code</p>
  
  <pre><code>require '/application/libraries/apiWrappers/Breathehr.php';
  
  class BreathehrTest extends PHPUnit_Framework_TestCase {
  
      public function testCanReturnEmployeeArray() {
          $breatheHR = new Breathehr();
  
          $employees = $breatheHR-&gt;list_employees(1);
          $this-&gt;assertArrayHasKey('employees', $employees);
      }
  
  
  }
  </code></pre>
  
  <p>The method that is being tested is as follows</p>
  
  <pre><code>class Breathehr {
  
      function __construct() {
  
      }
  
      public function list_employees($page)
      {
          $client = new GuzzleHttp\Client(
              ['base_uri' =&gt; 'https://xxx/',
                  'headers' =&gt; ['X-API-KEY' =&gt; 'xxx'],
                  'verify' =&gt; false]
          );
  
          $request = $client-&gt;get('employees?page='.$page);
          $employees = json_decode($request-&gt;getBody(true));
  
          $employeeData = array(
              'employees' =&gt; array(),
              'pagination' =&gt; array()
          );
  
          $i = 0;
          foreach($employees-&gt;employees as $employee) {
              if($employee-&gt;status !== 'Ex-employee') {
                  $employeeData['employees'][$i]['firstName'] = $employee-&gt;first_name;
                  $employeeData['employees'][$i]['lastName'] = $employee-&gt;last_name;
                  $employeeData['employees'][$i]['jobTitle'] = $employee-&gt;job_title;
                  if(isset($employee-&gt;line_manager)) {
                      $employeeData['employees'][$i]['lineManagerName'] = $employee-&gt;line_manager-&gt;first_name . ' '. $employee-&gt;line_manager-&gt;last_name;
                      $employeeData['employees'][$i]['lineManagerID'] = $employee-&gt;line_manager-&gt;id;
                  }
                  $employeeData['employees'][$i]['workingHours'] = $employee-&gt;full_or_part_time;
                  $employeeData['employees'][$i]['email'] = $employee-&gt;email;
                  $employeeData['employees'][$i]['workPhone'] = $employee-&gt;ddi;
                  $employeeData['employees'][$i]['personalMobile'] = $employee-&gt;personal_mobile;
                  $employeeData['employees'][$i]['homeTelephone'] = $employee-&gt;home_telephone;
                  $employeeData['employees'][$i]['birthday'] = $employee-&gt;dob;
                  $i++;
              }
          }
  
          $nextLink = $request-&gt;getHeader('Link');
          $nextLinkSplit = explode(',', $nextLink[0]);
  
          $pageination = array();
  
          foreach($nextLinkSplit as $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;
      }
  
  }
  </code></pre>
  
  <p>The API call works correctly via Postman and from a browser, but the result of running PHPUnit from the command line is the following</p>
  
  <blockquote>
    <p>RuntimeException: Error creating resource: [message] fopen(): Unable
    to find the wrapper "https" - did you forget to enable it when you
    configured PHP?</p>
    
    <p>[message] fopen(<a href="https://api.breathehr.com/v1/employees?page=1" rel="nofollow noreferrer">https://api.breathehr.com/v1/employees?page=1</a>): failed
    to open stream: No such file or directory</p>
  </blockquote>
  
  <p>I have googled the error message and came across this SO post <a href="https://stackoverflow.com/questions/5444249/unable-to-find-the-wrapper-https-did-you-forget-to-enable-it-when-you-config">Unable to find the wrapper &quot;https&quot; - did you forget to enable it when you configured PHP?</a></p>
  
  <p>Making these changes has made no difference. It's worth noting this is on localhost, running MAMP.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>