Skip to content

Commit de664f9

Browse files
committed
Add some more dummy tests to figure out where travis expects the wp-api plugin
1 parent c73fcb9 commit de664f9

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

tests/bootstrap.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,29 @@ function _tests_cmb2_manually_load_plugin() {
3636
}
3737

3838
$plugin = dirname( dirname( __FILE__ ) );
39-
$wp_content = dirname( dirname( $plugin ) );
39+
40+
define( 'CMB2_WP_CONTENT', dirname( dirname( $plugin ) ) );
4041

4142
if (
43+
( $rest_api = CMB2_WP_CONTENT . '/plugins/WP-API/plugin.php' )
44+
&& file_exists( $rest_api )
45+
) {
46+
require_once $rest_api;
47+
} elseif (
48+
( $rest_api = CMB2_WP_CONTENT . '/plugins/rest-api/plugin.php' )
49+
&& file_exists( $rest_api )
50+
) {
51+
require_once $rest_api;
52+
} elseif (
4253
( $rest_api = dirname( $test_root ) . '/wp-content/plugins/rest-api/plugin.php' )
4354
&& file_exists( $rest_api )
4455
) {
4556
require_once $rest_api;
57+
} elseif (
58+
( $rest_api = dirname( dirname( $test_root ) ) . '/wordpress/wp-content/plugins/rest-api/plugin.php' )
59+
&& file_exists( $rest_api )
60+
) {
61+
require_once $rest_api;
4662
}
4763

4864
require_once $plugin . '/init.php';

tests/test-cmb-rest-registered-fields.php

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,44 @@ public function tearDown() {
6868
public function test_wp_api_installed() {
6969
global $test_root;
7070

71-
$this->assertEquals( '/tmp/wordpress/tests', $test_root );
72-
$rest_api = dirname( $test_root ) . '/wp-content/plugins/rest-api/plugin.php';
73-
$this->assertEquals( '/tmp/wordpress/wp-content/plugins/rest-api/plugin.php', $rest_api );
74-
$this->assertTrue( file_exists( $rest_api ) );
71+
$rest_api = '';
72+
73+
if (
74+
( $rest_api = CMB2_WP_CONTENT . '/plugins/WP-API/plugin.php' )
75+
&& file_exists( $rest_api )
76+
) {
77+
require_once $rest_api;
78+
} elseif (
79+
( $rest_api = CMB2_WP_CONTENT . '/plugins/rest-api/plugin.php' )
80+
&& file_exists( $rest_api )
81+
) {
82+
require_once $rest_api;
83+
} elseif (
84+
( $rest_api = dirname( $test_root ) . '/wp-content/plugins/rest-api/plugin.php' )
85+
&& file_exists( $rest_api )
86+
) {
87+
require_once $rest_api;
88+
} elseif (
89+
( $rest_api = dirname( dirname( $test_root ) ) . '/wordpress/wp-content/plugins/rest-api/plugin.php' )
90+
&& file_exists( $rest_api )
91+
) {
92+
require_once $rest_api;
93+
} elseif (
94+
( $rest_api = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/plugins/rest-api/plugin.php' )
95+
&& file_exists( $rest_api )
96+
) {
97+
require_once $rest_api;
98+
}
99+
100+
$this->assertEquals( array(
101+
'/tmp/wordpress/tests',
102+
dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/plugins/WP-API/plugin.php',
103+
true
104+
), array(
105+
$test_root,
106+
$rest_api,
107+
file_exists( $rest_api ),
108+
) );
75109
}
76110

77111
public function test_rest_posts_controller_exists() {

0 commit comments

Comments
 (0)