-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moving some of the conditionals and functionalities from bootstrap.php file into a separate class - Moving the "require" bits into the Bootstrap::init() function
- Loading branch information
1 parent
4b69ba2
commit 882efd5
Showing
4 changed files
with
62 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aldavigdis\WpTestsStrapon; | ||
|
||
use Aldavigdis\WpTestsStrapon\Config; | ||
|
||
/** | ||
* The SetEnv class initiates environment variables and global constants and | ||
* helps us with going around limitations set by PHPUnit 9 | ||
*/ | ||
class SetEnv { | ||
/** | ||
* Supress PHPUnit framework errors if the current version of PHPUnit is | ||
* version 10 or newer. | ||
* | ||
* This is because WordPress itself is stuck with version 9 of PHPUnit and | ||
* thus assumes certain classes to exsist. If we don't fake them like this, | ||
* the WP test suite will throw an error. | ||
*/ | ||
public static function supress(): void { | ||
if ( 1 === version_compare( \PHPUnit\Runner\Version::id(), '10' ) ) { | ||
require __DIR__ . '/../supressors/SupressFramework.php'; | ||
require __DIR__ . '/../supressors/SupressFrameworkError.php'; | ||
} | ||
} | ||
|
||
/** | ||
* Set the WP_VERSION environment variable if it is not set already | ||
*/ | ||
public static function setWpVersion(): void { | ||
if (getenv('WP_VERSION') === false) { | ||
putenv('WP_VERSION=master'); | ||
} | ||
} | ||
|
||
/** | ||
* Set the global WP_TESTS_CONFIG_FILE_PATH constant if not set already | ||
*/ | ||
public static function setConfigFilePath(): void { | ||
if (defined('WP_TESTS_CONFIG_FILE_PATH') === false) { | ||
define( | ||
'WP_TESTS_CONFIG_FILE_PATH', | ||
Config::path() | ||
); | ||
} | ||
} | ||
} |