This repository has been archived by the owner on May 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
wp-codeception.php
153 lines (129 loc) · 4.95 KB
/
wp-codeception.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/**
* Plugin Name: WP Codeception
* Plugin URI: https://github.com/10up/wp-codeception
* Description: Registers WP-CLI commands which allow you to execute Codeception tests.
* Author: 10up Inc
* Author URI: https://10up.com/
* Version: 1.0.3
* License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// +----------------------------------------------------------------------+
// | Copyright 2015 10up Inc |
// +----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License, version 2, as |
// | published by the Free Software Foundation. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
// | MA 02110-1301 USA |
// +----------------------------------------------------------------------+
// do nothing if PHP version is less than 5.5
if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
return;
}
// Do nothing if WP_CLI is not defined
if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
return;
}
// Only ever load wp-codeception once
if ( ! defined( 'WP_CODECEPTION_LOADED' ) ) {
// Define constants
define( 'WPCC_VERSION', '1.0.3' );
define( 'WPCC_ABSPATH', __DIR__ );
define( 'WP_CODECEPTION_LOADED', true );
// See if the codeception library is available, if not, try to load it
if ( ! class_exists( 'Codeception\Codecept' ) ) {
try {
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
throw new Exception( 'You must run composer first if running this as a standalone plugin' );
}
require_once __DIR__ . '/vendor/autoload.php';
} catch ( Exception $e ) {
WP_CLI::error( $e->getMessage() );
}
}
// Register WP-CLI commands
WP_CLI::add_command( 'codeception', '\WPCC\CLI\Codeception' );
WP_CLI::add_command( 'selenium', '\WPCC\CLI\Selenium' );
}
/**
* Following functions were copied from the Codeception's autoload file, because
* we are not going to load it anymore, but these functions are still required
* and used in the depths of the framework, so we have to load it here.
*/
if ( ! function_exists( 'codecept_debug' ) ) :
/**
* Registers debug message which will be printed if --debug argument is passed to the command.
*
* @since 1.0.1
*
* @param mixed $data The debug data, it will be serialized if we need to display it.
*/
function codecept_debug( $data ) {
\Codeception\Util\Debug::debug( $data );
}
endif;
if ( ! function_exists( 'codecept_root_dir' ) ) :
/**
* Returns absolute path to the requested object which is expected to be in
* the root directory of a testing project.
*
* @since 1.0.1
*
* @param string $appendPath A relative path to the requested object.
* @return string The absolute path to the object.
*/
function codecept_root_dir( $appendPath = '' ) {
return \Codeception\Configuration::projectDir() . $appendPath;
}
endif;
if ( ! function_exists( 'codecept_output_dir' ) ) :
/**
* Returns absolute path to the requested object which is expected to be in
* the output directory of a testing project.
*
* @since 1.0.1
*
* @param string $appendPath A relative path to the requested object.
* @return string The absolute path to the object.
*/
function codecept_output_dir( $appendPath = '' ) {
return \Codeception\Configuration::outputDir() . $appendPath;
}
endif;
if ( ! function_exists( 'codecept_log_dir' ) ) :
/**
* Returns absolute path to the requested object which is expected to be in
* the log directory of a testing project.
*
* @since 1.0.1
*
* @param string $appendPath A relative path to the requested object.
* @return string The absolute path to the object.
*/
function codecept_log_dir( $appendPath = '' ) {
return \Codeception\Configuration::outputDir() . $appendPath;
}
endif;
if ( ! function_exists( 'codecept_data_dir' ) ) :
/**
* Returns absolute path to the requested object which is expected to be in
* the data directory of a testing project.
*
* @since 1.0.1
*
* @param string $appendPath A relative path to the requested object.
* @return string The absolute path to the object.
*/
function codecept_data_dir( $appendPath = '' ) {
return \Codeception\Configuration::dataDir() . $appendPath;
}
endif;