forked from GatoGraphQL/GatoGraphQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatographql-testing.php
executable file
·58 lines (52 loc) · 1.73 KB
/
gatographql-testing.php
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
50
51
52
53
54
55
56
57
58
<?php
/*
Plugin Name: Gato GraphQL - PHPUnit & Testing Utilities
Description: Utilities for testing Gato GraphQL
Version: 1.6.0-dev
Requires at least: 5.4
Requires PHP: 8.1
Author: Gato GraphQL
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Text Domain: gatographql-testing
Domain Path: /languages
*/
use GatoGraphQL\GatoGraphQL\Plugin as GatoGraphQLMainPlugin;
use PHPUnitForGatoGraphQL\GatoGraphQLTesting\Plugin;
use PHPUnitForGatoGraphQL\GatoGraphQLTesting\PluginHelpers;
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
add_action(
'plugins_loaded',
function (): void {
// Validate Gato GraphQL is installed, or exit
if (!class_exists(GatoGraphQLMainPlugin::class)) {
return;
}
// Load Composer’s autoloader
require_once(__DIR__ . '/vendor/autoload.php');
/**
* Activate the plugin, only if:
*
* - we are in the DEV environment, or
* - we are executing integration tests (hosted in InstaWP)
*/
if (!PluginHelpers::enablePlugin()) {
\add_action('admin_notices', function () {
$adminNotice_safe = sprintf(
'<div class="notice notice-error"><p>%s</p></div>',
sprintf(
__('Functionality in plugin <strong>%s</strong> can only be enabled during development or testing.', 'gatographql-testing'),
__('Gato GraphQL - Testing', 'gatographql-testing')
)
);
echo $adminNotice_safe;
});
return;
}
// Initialize the plugin
(new Plugin())->initialize();
}
);