-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(WPLoader) add support for activatePluginsSilently
- Loading branch information
Showing
26 changed files
with
562 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,47 @@ | ||
<?php | ||
// This is global bootstrap for autoloading. | ||
use Codeception\Events; | ||
use Codeception\Util\Autoload; | ||
|
||
use function tad\WPBrowser\addListener; | ||
use function tad\WPBrowser\Tests\Support\createTestDatabasesIfNotExist; | ||
|
||
createTestDatabasesIfNotExist(); | ||
|
||
// Make sure traits can be autoloaded from tests/_support/Traits | ||
Autoload::addNamespace('\lucatume\WPBrowser\Tests\Traits', codecept_root_dir('tests/_support/Traits')); | ||
Autoload::addNamespace( '\lucatume\WPBrowser\Tests\Traits', codecept_root_dir( 'tests/_support/Traits' ) ); | ||
|
||
// If the `uopz` extension is installed, then ensure `exit` and `die` to work normally. | ||
if (function_exists('uopz_allow_exit')) { | ||
uopz_allow_exit(true); | ||
if ( function_exists( 'uopz_allow_exit' ) ) { | ||
uopz_allow_exit( true ); | ||
} | ||
|
||
//addListener( Events::SUITE_BEFORE, function ( Codeception\Event\SuiteEvent $event ) { | ||
// $suiteName = $event->getSuite()->getName(); | ||
// | ||
// if ( $suiteName !== 'wploader_plugin_silent_activation' ) { | ||
// return; | ||
// } | ||
// | ||
// $wpRootDir = realpath( getenv( 'WORDPRESS_ROOT_DIR' ) ); | ||
// | ||
// if ( ! is_dir( $wpRootDir ) ) { | ||
// throw new \RuntimeException( "The WORDPRESS_ROOT_DIR is not a valid directory." ); | ||
// } | ||
// | ||
// $wpRootDir = rtrim( $wpRootDir, '/\\' ); | ||
// | ||
// foreach ( | ||
// [ | ||
// codecept_data_dir( 'plugins/doing-it-wrong-1' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-1', | ||
// codecept_data_dir( 'plugins/doing-it-wrong-2' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-2', | ||
// ] as $source => $destination | ||
// ) { | ||
// if ( ! copy( | ||
// $source, | ||
// $destination | ||
// ) ) { | ||
// throw new \RuntimeException( "Could not copy the plugin to the WordPress plugins directory." ); | ||
// } | ||
// } | ||
//} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Doing It Right | ||
*/ | ||
|
||
register_activation_hook( __FILE__, function () { | ||
update_option( 'doing_it_right_activation', 'activated' ); | ||
} ); | ||
|
||
add_action('plugins_loaded', function(){ | ||
global $doing_it_right_plugin_loaded; | ||
$doing_it_right_plugin_loaded = true; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Doing It Wrong 1 | ||
*/ | ||
|
||
function doing_it_wrong_1_activation(){ | ||
_doing_it_wrong( __FUNCTION__, 'This is a test', '1.0.0' ); | ||
update_option('doing_it_wrong_1j_activation', 'activated'); | ||
} | ||
register_activation_hook(__FILE__,'doing_it_wrong_1_activation'); | ||
|
||
add_action('plugins_loaded', function(){ | ||
global $doing_it_wrong_1_plugin_loaded; | ||
$doing_it_wrong_1_plugin_loaded = true; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Doing It Wrong 2 | ||
*/ | ||
|
||
function doing_it_wrong_2_activation() { | ||
_doing_it_wrong( __FUNCTION__, 'This is a test', '1.0.0' ); | ||
update_option('doing_it_wrong_2_activation', 'activated'); | ||
} | ||
|
||
register_activation_hook( __FILE__, 'doing_it_wrong_2_activation' ); | ||
|
||
add_action('plugins_loaded', function(){ | ||
global $doing_it_wrong_2_plugin_loaded; | ||
$doing_it_wrong_2_plugin_loaded = true; | ||
}); |
10 changes: 10 additions & 0 deletions
10
tests/_support/Helper/Wploader_plugin_silent_activation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace Helper; | ||
|
||
// here you can define custom actions | ||
// all public methods declared in helper class will be available in $I | ||
|
||
class Wploader_plugin_silent_activation extends \Codeception\Module | ||
{ | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
tests/_support/Wploader_plugin_silent_activationTester.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method void pause() | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class Wploader_plugin_silent_activationTester extends \Codeception\Actor | ||
{ | ||
use _generated\Wploader_plugin_silent_activationTesterActions; | ||
|
||
/** | ||
* Define custom actions here | ||
*/ | ||
} |
Oops, something went wrong.