-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathfunctions.php
More file actions
49 lines (41 loc) · 1.09 KB
/
functions.php
File metadata and controls
49 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Shared functionality for all test suites.
*
* @package KnowTheCode\GitContributing\Tests\PHP
* @since 1.0.0
* @link https://github.com/KnowTheCode/git-contributing
* @license GNU-2.0+
*/
namespace KnowTheCode\GitContributing\Tests\PHP;
if ( version_compare( phpversion(), '5.6.0', '<' ) ) {
die( 'Whoops, PHP 5.6 or higher is required.' );
}
/**
* Gets the plugin's root directory.
*
* @since 1.0.0
*
* @return string
*/
function get_plugin_root_dir() {
static $root_dir;
if ( is_null( $root_dir ) ) {
$root_dir = dirname( dirname( __DIR__ ) ) . DIRECTORY_SEPARATOR;
}
return $root_dir;
}
/**
* Attempts to load Composer's autoloader.
*
* @since 1.0.0
*
* @return void
*/
function load_composer_autoloader() {
$path_to_vendor_dir = get_plugin_root_dir() . 'vendor' . DIRECTORY_SEPARATOR;
if ( ! is_readable( $path_to_vendor_dir . 'autoload.php' ) ) {
die( 'Whoops, we need Composer before we start running tests. Please type: `composer install`. When done, try running `phpunit` again.' );
}
require_once $path_to_vendor_dir . 'autoload.php';
}