Skip to content

Commit c98fad9

Browse files
committed
test bootstrap file updated
1 parent 7a76b57 commit c98fad9

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"build-containers": "docker-compose --file docker-compose.build.yml build",
4747
"push-containers": "docker-compose --file docker-compose.build.yml push",
4848
"stop-all": "docker stop $(docker ps -a -q)",
49-
"cli": "docker-compose run --rm --user $(id -u) wordpress xwp_wait db_phpunit:3306 -t 60 --",
50-
"vcli": "vagrant ssh -- docker-compose -f /vagrant/docker-compose.yml run --rm --user $(id -u) wordpress xwp_wait db_phpunit:3306 -t 60 --",
49+
"cli": "docker-compose run --rm --user $(id -u) wordpress xwp_wait db_phpunit:3306 -s -t 300 --",
50+
"vcli": "vagrant ssh -- docker-compose -f /vagrant/docker-compose.yml run --rm --user $(id -u) wordpress xwp_wait db_phpunit:3306 -s -t 300 --",
5151
"phpunit": "npm run cli -- composer test --working-dir=wp-content/plugins/stream-src",
5252
"phpunit-multisite": "npm run cli -- composer test-multisite --working-dir=wp-content/plugins/stream-src",
5353
"vphpunit": "npm run vcli -- composer test --working-dir=wp-content/plugins/stream-src",

tests/bootstrap.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,49 @@ function xwp_filter_active_plugins_for_phpunit( $active_plugins ) {
4444
function() {
4545
// Manually load the plugin.
4646
require dirname( __DIR__ ) . '/stream.php';
47+
48+
// Install database.
49+
$plugin = wp_stream_get_instance();
50+
$plugin->install->check();
4751
}
4852
);
53+
4954
function xwp_manually_load_mercator() {
5055
define( 'MERCATOR_SKIP_CHECKS', true );
5156
require WPMU_PLUGIN_DIR . '/mercator/mercator.php';
5257
}
5358

5459
tests_add_filter( 'muplugins_loaded', 'xwp_manually_load_mercator' );
5560

61+
function xwp_install_edd() {
62+
// Install Easy Digital Downloads
63+
edd_install();
64+
65+
global $current_user, $edd_options;
66+
67+
$edd_options = get_option( 'edd_settings' );
68+
69+
$current_user = new WP_User(1);
70+
$current_user->set_role('administrator');
71+
wp_update_user( array( 'ID' => 1, 'first_name' => 'Admin', 'last_name' => 'User' ) );
72+
add_filter( 'edd_log_email_errors', '__return_false' );
73+
74+
add_filter(
75+
'pre_http_request',
76+
function( $status = false, $args = array(), $url = '') {
77+
return new WP_Error( 'no_reqs_in_unit_tests', __( 'HTTP Requests disabled for unit tests', 'easy-digital-downloads' ) );
78+
}
79+
);
80+
}
81+
5682
// @see https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/bootstrap.php
5783
require $_tests_dir . '/includes/bootstrap.php';
5884

85+
define( 'EDD_USE_PHP_SESSIONS', false );
86+
define( 'WP_USE_THEMES', false );
87+
activate_plugin( 'easy-digital-downloads/easy-digital-downloads.php' );
88+
xwp_install_edd();
89+
5990
require __DIR__ . '/testcase.php';
6091

6192
// Base class for future tests

tests/tests/connectors/test-class-connector-edd.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@
1010
namespace WP_Stream;
1111

1212
class Test_WP_Stream_Connector_EDD extends WP_StreamTestCase {
13-
/**
14-
* Runs before all tests
15-
*/
16-
public static function wpSetUpBeforeClass() {
17-
global $wpdb;
18-
19-
$suppress = $wpdb->suppress_errors();
20-
21-
edd_install();
22-
23-
$wpdb->suppress_errors( $suppress );
24-
}
25-
2613
/**
2714
* Runs before each test
2815
*/
@@ -178,6 +165,7 @@ public function test_check() {
178165
edd_update_option( 'thousands_separator' );
179166

180167
// Check callback test action.
168+
$this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_add_option' ) );
181169
$this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_update_option' ) );
182170
}
183171

0 commit comments

Comments
 (0)