Add require_once to api3TestTrait
authoreileen <emcnaughton@wikimedia.org>
Tue, 4 Feb 2020 02:11:11 +0000 (15:11 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 4 Feb 2020 02:11:11 +0000 (15:11 +1300)
I used this trait from an extension but it was used with apiv4 before apiv3 (it supports both).

I got an error because utils.php is not included by this file. It 'freeloads' off the fact apiv3 initialises
the file - but in fact the file that includes a function requiring a function
should have the require once - reduces risk & cognitive load

Civi/Test/Api3TestTrait.php

index a0f8e289bc91c8bb37fdbd8a6e13659314e4c265..79e6e8e53cd7670551dac3794161056e5f8aff05 100644 (file)
@@ -4,6 +4,7 @@ namespace Civi\Test;
 
 use Civi\API\Exception\NotImplementedException;
 
+require_once 'api/v3/utils.php';
 /**
  * Class Api3TestTrait
  * @package Civi\Test