mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-06 10:45:44 +03:00
Tools: Add formatting command, run to fix minor phpcs issues
This commit is contained in:
parent
28b102bc4c
commit
bb25e0c78b
13 changed files with 55 additions and 53 deletions
|
@ -21,9 +21,11 @@ require_once $_tests_dir . '/includes/functions.php';
|
|||
* Manually load the plugin being tested.
|
||||
*/
|
||||
function _manually_load_plugin() {
|
||||
define( 'WPORG_SUPPORT_FORUMS_BLOGID', 1 );
|
||||
if ( ! defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
|
||||
define( 'WPORG_SUPPORT_FORUMS_BLOGID', 1 );
|
||||
}
|
||||
|
||||
require dirname( __FILE__, 2 ) . '/index.php';
|
||||
require dirname( __DIR__, 1 ) . '/index.php';
|
||||
require __DIR__ . '/helpers.php';
|
||||
}
|
||||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
||||
|
|
|
@ -9,7 +9,7 @@ use WP_UnitTest_Factory;
|
|||
*
|
||||
* Call in `set_up_before_class()`.
|
||||
*/
|
||||
function database_setup_before_class( WP_UnitTest_Factory $factory ) : array {
|
||||
function database_setup_before_class( WP_UnitTest_Factory $factory ): array {
|
||||
global $wpdb;
|
||||
|
||||
$fixtures = array();
|
||||
|
@ -70,7 +70,7 @@ function database_setup_before_class( WP_UnitTest_Factory $factory ) : array {
|
|||
) );
|
||||
|
||||
// Pages.
|
||||
$for_organizations = $factory->post->create_and_get( array(
|
||||
$for_organizations = $factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'For Organizations',
|
||||
'post_status' => 'publish',
|
||||
|
@ -103,7 +103,7 @@ function database_setup_before_class( WP_UnitTest_Factory $factory ) : array {
|
|||
*
|
||||
* Call in `set_up()`.
|
||||
*/
|
||||
function database_set_up( array $user_ids ) : void {
|
||||
function database_set_up( array $user_ids ): void {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->query( 'TRUNCATE TABLE `bpmain_bp_xprofile_data` ' );
|
||||
|
@ -140,7 +140,7 @@ function database_set_up( array $user_ids ) : void {
|
|||
*
|
||||
* Call in `tear_down_after_class()`.
|
||||
*/
|
||||
function database_tear_down_after_class() : void {
|
||||
function database_tear_down_after_class(): void {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->query( 'DROP TABLE `bpmain_bp_xprofile_data` ' );
|
||||
|
|
|
@ -52,7 +52,7 @@ class Test_Auth extends WP_UnitTestCase {
|
|||
/**
|
||||
* Setup fixtures that are unique for each test.
|
||||
*/
|
||||
public function set_up() : void {
|
||||
public function set_up(): void {
|
||||
parent::set_up();
|
||||
|
||||
/*
|
||||
|
@ -115,7 +115,7 @@ class Test_Auth extends WP_UnitTestCase {
|
|||
'wrong-data-type' => array( 'this string is not an array' ),
|
||||
'wrong-array-items' => array( 'this' => "doesn't have `value` and `expiration` items" ),
|
||||
|
||||
'invalid-value' => array(
|
||||
'invalid-value' => array(
|
||||
// Must have TOKEN_LENGTH characters, otherwise could be rejected for the wrong reason.
|
||||
'value' => 'Has special characters !@#$%^&*)',
|
||||
'expiration' => time() + MINUTE_IN_SECONDS,
|
||||
|
|
|
@ -55,7 +55,7 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
* @covers WordPressDotOrg\FiveForTheFuture\XProfile\get_contributor_user_data
|
||||
* @covers WordPressDotOrg\FiveForTheFuture\Pledge\deactivate
|
||||
*/
|
||||
public function test_data_reset_once_no_active_sponsors() : void {
|
||||
public function test_data_reset_once_no_active_sponsors(): void {
|
||||
// Setup scenario where Jane is sponsored by two companies.
|
||||
$mailer = tests_retrieve_phpmailer_instance();
|
||||
$jane = self::$users['jane'];
|
||||
|
@ -122,7 +122,7 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
* @covers WordPressDotOrg\FiveForTheFuture\XProfile\get_contributor_user_data
|
||||
* @covers WordPressDotOrg\FiveForTheFuture\Pledge\deactivate
|
||||
*/
|
||||
public function test_data_not_reset_when_unconfirmed_sponsor() : void {
|
||||
public function test_data_not_reset_when_unconfirmed_sponsor(): void {
|
||||
// Setup scenario where Jane was invited to join a company but didn't respond.
|
||||
$mailer = tests_retrieve_phpmailer_instance();
|
||||
$jane = self::$users['jane'];
|
||||
|
@ -163,7 +163,7 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\add_pledge_contributors
|
||||
* @covers WordPressDotOrg\FiveForTheFuture\XProfile\get_contributor_user_data
|
||||
*/
|
||||
public function test_data_reset_when_single_contributor_removed_from_pledge() : void {
|
||||
public function test_data_reset_when_single_contributor_removed_from_pledge(): void {
|
||||
// Setup scenario where Jane and Ashish are sponsored by a company.
|
||||
$mailer = tests_retrieve_phpmailer_instance();
|
||||
$jane = self::$users['jane'];
|
||||
|
@ -226,21 +226,21 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
);
|
||||
|
||||
$contributors = array(
|
||||
'active + due for email' => array(
|
||||
'active + due for email' => array(
|
||||
'user_id' => self::$users['jane']->ID,
|
||||
'last_logged_in' => strtotime( '1 week ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => 0,
|
||||
),
|
||||
|
||||
'active + not due for email' => array(
|
||||
'active + not due for email' => array(
|
||||
'user_id' => self::$users['ashish']->ID,
|
||||
'last_logged_in' => strtotime( '1 week ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '1 month ago' ),
|
||||
),
|
||||
|
||||
'inactive + due for email' => array(
|
||||
'inactive + due for email' => array(
|
||||
'user_id' => self::$users['andrea']->ID,
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
|
@ -254,14 +254,14 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
'5ftf_last_inactivity_email' => strtotime( '2 months ago' ),
|
||||
),
|
||||
|
||||
'new user' => array(
|
||||
'new user' => array(
|
||||
'user_id' => self::$users['jane']->ID,
|
||||
'last_logged_in' => 0,
|
||||
'user_registered' => strtotime( '1 week ago' ),
|
||||
'5ftf_last_inactivity_email' => 0,
|
||||
),
|
||||
|
||||
'inactive + blocked' => array(
|
||||
'inactive + blocked' => array(
|
||||
'user_id' => self::$users['kimi']->ID,
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue