diff --git a/admin/class-convertkit-admin-setup-wizard.php b/admin/class-convertkit-admin-setup-wizard.php index 4e3096048..92cf0cf83 100644 --- a/admin/class-convertkit-admin-setup-wizard.php +++ b/admin/class-convertkit-admin-setup-wizard.php @@ -51,9 +51,9 @@ class ConvertKit_Admin_Setup_Wizard { * * @since 1.9.8.4 * - * @var int + * @var string */ - public $step = 1; + public $step = 'start'; /** * The programmatic name of the setup screen. @@ -170,7 +170,7 @@ public function maybe_load_setup_screen() { } // Define the step the user is on in the setup process. - $this->step = ( filter_has_var( INPUT_GET, 'step' ) ? absint( filter_input( INPUT_GET, 'step', FILTER_SANITIZE_NUMBER_INT ) ) : 1 ); + $this->step = $this->get_current_step(); // Process any posted form data. $this->process_form(); @@ -193,6 +193,66 @@ public function maybe_load_setup_screen() { } + /** + * Returns the current step in the setup process. + * + * @since 3.1.7 + * + * @return string Current step. + */ + public function get_current_step() { + + $step = ( filter_has_var( INPUT_GET, 'step' ) ? filter_input( INPUT_GET, 'step', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : 'start' ); + + // Fallback to 'start' if the step is a registered step. + if ( ! array_key_exists( $step, $this->steps ) ) { + $step = 'start'; + } + + return $step; + + } + + /** + * Get the number of the current step. + * + * @since 3.1.7 + * + * @return int Step number. + */ + public function get_current_step_number() { + + return array_search( $this->step, array_keys( $this->steps ), true ) + 1; + + } + + /** + * Get the step by number. + * + * @since 3.1.7 + * + * @param int $number Step number (1 based index). + * @return string Step name/key. + */ + public function get_step_key_by_number( $number ) { + + return array_keys( $this->steps )[ $number - 1 ]; + + } + + /** + * Get the total number of steps. + * + * @since 3.1.7 + * + * @return int Total steps. + */ + public function get_total_steps() { + + return count( $this->steps ); + + } + /** * Process submitted form data for the given setup wizard name and current step. * @@ -205,7 +265,7 @@ private function process_form() { * * @since 1.9.8.4 * - * @param int $step Current step number. + * @param string $step Current step. */ do_action( 'convertkit_admin_setup_wizard_process_form_' . $this->page_name, $this->step ); @@ -231,24 +291,24 @@ private function define_step_urls() { ); // Define the previous step URL if we're not on the first or last step. - if ( $this->step > 1 && $this->step < count( $this->steps ) ) { + if ( $this->get_current_step_number() > 1 && $this->get_current_step_number() < $this->get_total_steps() ) { $this->previous_step_url = add_query_arg( array( 'page' => $this->page_name, 'convertkit-modal' => $this->is_modal(), - 'step' => ( $this->step - 1 ), + 'step' => $this->get_step_key_by_number( $this->get_current_step_number() - 1 ), ), admin_url( 'options.php' ) ); } // Define the next step URL if we're not on the last page. - if ( $this->step < count( $this->steps ) ) { + if ( $this->get_current_step_number() < $this->get_total_steps() ) { $this->next_step_url = add_query_arg( array( 'page' => $this->page_name, 'convertkit-modal' => $this->is_modal(), - 'step' => ( $this->step + 1 ), + 'step' => $this->get_step_key_by_number( $this->get_current_step_number() + 1 ), ), admin_url( 'options.php' ) ); @@ -268,7 +328,7 @@ private function load_screen_data() { * * @since 1.9.8.4 * - * @param int $step Current step number. + * @param string $step Current step. */ do_action( 'convertkit_admin_setup_wizard_load_screen_data_' . $this->page_name, $this->step ); diff --git a/admin/setup-wizard/class-convertkit-admin-setup-wizard-landing-page.php b/admin/setup-wizard/class-convertkit-admin-setup-wizard-landing-page.php index 351a4d65d..f2db0c670 100644 --- a/admin/setup-wizard/class-convertkit-admin-setup-wizard-landing-page.php +++ b/admin/setup-wizard/class-convertkit-admin-setup-wizard-landing-page.php @@ -86,13 +86,13 @@ public function __construct() { // Define details for each step in the setup process. $this->steps = array( - 1 => array( + 'start' => array( 'name' => __( 'Setup', 'convertkit' ), 'next_button' => array( 'label' => __( 'Create', 'convertkit' ), ), ), - 2 => array( + 'finish' => array( 'name' => __( 'Done', 'convertkit' ), ), ); @@ -110,7 +110,7 @@ public function __construct() { * * @since 2.5.5 * - * @param int $step Current step. + * @param string $step Current step. */ public function process_form( $step ) { @@ -124,7 +124,7 @@ public function process_form( $step ) { } // Don't process form data if we're not on the second step. - if ( $step !== 2 ) { + if ( $step !== 'finish' ) { return; } @@ -144,7 +144,7 @@ public function process_form( $step ) { // If an error occured creating the Page, go back a step to show the error. if ( is_wp_error( $this->result ) ) { - $this->step = ( $this->step - 1 ); + $this->step = $this->get_step_key_by_number( $this->get_current_step_number() - 1 ); $this->error = $this->result->get_error_message(); } @@ -155,7 +155,7 @@ public function process_form( $step ) { * * @since 2.5.5 * - * @param int $step Current step. + * @param string $step Current step. */ public function load_screen_data( $step ) { @@ -198,7 +198,7 @@ public function load_screen_data( $step ) { ); // Don't load data if not on the first step. - if ( $step !== 1 ) { + if ( $step !== 'start' ) { return; } @@ -211,12 +211,12 @@ public function load_screen_data( $step ) { // Bail if an error occured. if ( is_wp_error( $result ) ) { // Change the next button label and make it a link to reload the screen. - unset( $this->steps[1]['next_button'] ); + unset( $this->steps['start']['next_button'] ); $this->current_url = add_query_arg( array( 'page' => $this->page_name, 'ck_post_type' => $this->post_type, - 'step' => 1, + 'step' => 'start', ), admin_url( 'options.php' ) ); @@ -226,12 +226,12 @@ public function load_screen_data( $step ) { // If no Landing Pages exist in ConvertKit, change the next button label and make it a link to reload // the screen. if ( ! $this->landing_pages->exist() ) { - unset( $this->steps[1]['next_button'] ); + unset( $this->steps['start']['next_button'] ); $this->current_url = add_query_arg( array( 'page' => $this->page_name, 'ck_post_type' => $this->post_type, - 'step' => 1, + 'step' => 'start', ), admin_url( 'options.php' ) ); diff --git a/admin/setup-wizard/class-convertkit-admin-setup-wizard-plugin.php b/admin/setup-wizard/class-convertkit-admin-setup-wizard-plugin.php index 6df21be86..154f0dd9c 100644 --- a/admin/setup-wizard/class-convertkit-admin-setup-wizard-plugin.php +++ b/admin/setup-wizard/class-convertkit-admin-setup-wizard-plugin.php @@ -105,20 +105,20 @@ public function __construct() { // Define details for each step in the setup process. $this->steps = array( - 1 => array( + 'start' => array( 'name' => __( 'Connect', 'convertkit' ), 'next_button' => array( 'label' => __( 'Connect', 'convertkit' ), - 'link' => $this->api->get_oauth_url( admin_url( 'options.php?page=convertkit-setup&step=2' ), get_site_url() ), + 'link' => $this->api->get_oauth_url( admin_url( 'options.php?page=convertkit-setup&step=configuration' ), get_site_url() ), ), ), - 2 => array( + 'configuration' => array( 'name' => __( 'Configuration', 'convertkit' ), 'next_button' => array( 'label' => __( 'Finish Setup', 'convertkit' ), ), ), - 3 => array( + 'finish' => array( 'name' => __( 'Done', 'convertkit' ), ), ); @@ -210,11 +210,11 @@ public function process_form( $step ) { // Depending on the step, process the form data. switch ( $step ) { - case 2: + case 'configuration': // If an error occured from OAuth i.e. the user did not authorize, show it now. if ( array_key_exists( 'error', $_REQUEST ) && array_key_exists( 'error_description', $_REQUEST ) ) { // Decrement the step. - $this->step = ( $this->step - 1 ); + $this->step = 'start'; $this->error = sanitize_text_field( wp_unslash( $_REQUEST['error_description'] ) ); return; } @@ -233,7 +233,7 @@ public function process_form( $step ) { // Show an error message if we could not fetch the access token. if ( is_wp_error( $result ) ) { // Decrement the step. - $this->step = ( $this->step - 1 ); + $this->step = 'start'; $this->error = $result->get_error_message(); return; } @@ -248,12 +248,14 @@ public function process_form( $step ) { ); break; - case 3: + case 'finish': // Run security checks. if ( ! isset( $_REQUEST['_wpnonce'] ) ) { return; } if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), $this->page_name ) ) { + // Decrement the step. + $this->step = 'configuration'; $this->error = __( 'Invalid nonce specified.', 'convertkit' ); return; } @@ -284,7 +286,7 @@ public function load_screen_data( $step ) { // If this wizard is being served in a modal window, change the flow. if ( $this->is_modal() ) { switch ( $step ) { - case 1: + case 'start': // Setup API. $api = new ConvertKit_API_V4( CONVERTKIT_OAUTH_CLIENT_ID, CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI ); @@ -304,10 +306,10 @@ function ( $hosts ) { ); // Redirect to OAuth. - wp_safe_redirect( $api->get_oauth_url( admin_url( 'options.php?page=convertkit-setup&step=2&convertkit-modal=1' ), get_site_url() ) ); + wp_safe_redirect( $api->get_oauth_url( admin_url( 'options.php?page=convertkit-setup&step=configuration&convertkit-modal=1' ), get_site_url() ) ); die(); - case 2: + case 'configuration': // Close modal. $this->maybe_close_modal(); break; @@ -315,7 +317,7 @@ function ( $hosts ) { } switch ( $step ) { - case 2: + case 'configuration': // Re-load settings class now that the Access and Refresh Tokens have been defined. $this->settings = new ConvertKit_Settings(); @@ -326,11 +328,11 @@ function ( $hosts ) { // Bail if an error occured. if ( is_wp_error( $result ) ) { // Change the next button label and make it a link to reload the screen. - $this->steps[2]['next_button']['label'] = __( 'I\'ve created a form in Kit', 'convertkit' ); - $this->steps[2]['next_button']['link'] = add_query_arg( + $this->steps['configuration']['next_button']['label'] = __( 'I\'ve created a form in Kit', 'convertkit' ); + $this->steps['configuration']['next_button']['link'] = add_query_arg( array( 'page' => $this->page_name, - 'step' => 2, + 'step' => 'configuration', ), admin_url( 'options.php' ) ); @@ -340,11 +342,11 @@ function ( $hosts ) { // If no Forms exist in ConvertKit, change the next button label and make it a link to reload // the screen. if ( ! $this->forms->exist() ) { - $this->steps[2]['next_button']['label'] = __( 'I\'ve created a form in Kit', 'convertkit' ); - $this->steps[2]['next_button']['link'] = add_query_arg( + $this->steps['configuration']['next_button']['label'] = __( 'I\'ve created a form in Kit', 'convertkit' ); + $this->steps['configuration']['next_button']['link'] = add_query_arg( array( 'page' => $this->page_name, - 'step' => 2, + 'step' => 'configuration', ), admin_url( 'options.php' ) ); diff --git a/admin/setup-wizard/class-convertkit-admin-setup-wizard-restrict-content.php b/admin/setup-wizard/class-convertkit-admin-setup-wizard-restrict-content.php index bde73a004..001f77e9a 100644 --- a/admin/setup-wizard/class-convertkit-admin-setup-wizard-restrict-content.php +++ b/admin/setup-wizard/class-convertkit-admin-setup-wizard-restrict-content.php @@ -140,16 +140,16 @@ public function __construct() { // Define details for each step in the setup process. $this->steps = array( - 1 => array( + 'start' => array( 'name' => __( 'Setup', 'convertkit' ), ), - 2 => array( + 'configuration' => array( 'name' => __( 'Configure', 'convertkit' ), 'next_button' => array( 'label' => __( 'Submit', 'convertkit' ), ), ), - 3 => array( + 'finish' => array( 'name' => __( 'Done', 'convertkit' ), ), ); @@ -167,7 +167,7 @@ public function __construct() { * * @since 2.1.0 * - * @param int $step Current step. + * @param string $step Current step. */ public function process_form( $step ) { @@ -182,7 +182,7 @@ public function process_form( $step ) { // Depending on the step, process the form data. switch ( $step ) { - case 3: + case 'finish': // Sanitize configuration. $configuration = array( 'type' => ( isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : 'download' ), @@ -215,7 +215,7 @@ public function process_form( $step ) { // If here, an error occured as create_download() and create_course() perform a redirect on success. // Show an error message if Account Details could not be fetched e.g. API credentials supplied are invalid. // Decrement the step. - $this->step = ( $this->step - 1 ); + $this->step = $this->get_step_key_by_number( $this->get_current_step_number() - 1 ); $this->error = $result->get_error_message(); return; @@ -230,7 +230,7 @@ public function process_form( $step ) { * * @since 2.1.0 * - * @param int $step Current step. + * @param string $step Current step. */ public function load_screen_data( $step ) { @@ -274,7 +274,7 @@ public function load_screen_data( $step ) { // Load data depending on the current step. switch ( $step ) { - case 1: + case 'start': // Fetch Forms, Products and Tags. $this->forms = new ConvertKit_Resource_Forms( 'restrict_content_wizard' ); $this->products = new ConvertKit_Resource_Products( 'restrict_content_wizard' ); @@ -287,12 +287,12 @@ public function load_screen_data( $step ) { // Bail if an error occured. if ( is_wp_error( $result ) ) { // Change the next label and make it a link to reload the screen. - unset( $this->steps[1]['next_button'] ); + unset( $this->steps['start']['next_button'] ); $this->current_url = add_query_arg( array( 'page' => $this->page_name, 'ck_post_type' => $this->post_type, - 'step' => 1, + 'step' => 'start', ), admin_url( 'options.php' ) ); @@ -305,12 +305,12 @@ public function load_screen_data( $step ) { // Bail if an error occured. if ( is_wp_error( $result ) ) { // Change the next label and make it a link to reload the screen. - unset( $this->steps[1]['next_button'] ); + unset( $this->steps['start']['next_button'] ); $this->current_url = add_query_arg( array( 'page' => $this->page_name, 'ck_post_type' => $this->post_type, - 'step' => 1, + 'step' => 'start', ), admin_url( 'options.php' ) ); @@ -323,12 +323,12 @@ public function load_screen_data( $step ) { // Bail if an error occured. if ( is_wp_error( $result ) ) { // Change the next label and make it a link to reload the screen. - unset( $this->steps[1]['next_button'] ); + unset( $this->steps['start']['next_button'] ); $this->current_url = add_query_arg( array( 'page' => $this->page_name, 'ck_post_type' => $this->post_type, - 'step' => 1, + 'step' => 'start', ), admin_url( 'options.php' ) ); @@ -338,12 +338,12 @@ public function load_screen_data( $step ) { // If no Forms, Products and Tags exist in ConvertKit, change the next button label and make it a link to reload // the screen. if ( ! $this->forms->exist() && ! $this->products->exist() && ! $this->tags->exist() ) { - unset( $this->steps[1]['next_button'] ); + unset( $this->steps['start']['next_button'] ); $this->current_url = add_query_arg( array( 'page' => $this->page_name, 'ck_post_type' => $this->post_type, - 'step' => 1, + 'step' => 'start', ), admin_url( 'options.php' ) ); @@ -367,7 +367,7 @@ public function load_screen_data( $step ) { } break; - case 2: + case 'configuration': // Define Member Content Type. if ( filter_has_var( INPUT_GET, 'type' ) ) { $this->type = filter_input( INPUT_GET, 'type', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); diff --git a/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php b/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php index 9b7f9b7c3..ecbd7cfab 100644 --- a/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php +++ b/tests/EndToEnd/general/plugin-screens/PluginSetupWizardCest.php @@ -24,7 +24,12 @@ public function testSetupWizardDisplays(EndToEndTester $I) $this->_activatePlugin($I); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 1, 'Welcome to the Kit Setup Wizard'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'start', + stepCount: 1, + title: 'Welcome to the Kit Setup Wizard' + ); } /** @@ -108,7 +113,12 @@ public function testSetupWizardExitLink(EndToEndTester $I) $this->_activatePlugin($I); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 1, 'Welcome to the Kit Setup Wizard'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'start', + stepCount: 1, + title: 'Welcome to the Kit Setup Wizard' + ); // Click Exit wizard link. $I->click('Exit wizard'); @@ -136,7 +146,12 @@ public function testSetupWizardSetupScreenConnectButton(EndToEndTester $I) $this->_activatePlugin($I); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 1, 'Welcome to the Kit Setup Wizard'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'start', + stepCount: 1, + title: 'Welcome to the Kit Setup Wizard' + ); // Test Connect button. $I->click('Connect'); @@ -147,10 +162,15 @@ public function testSetupWizardSetupScreenConnectButton(EndToEndTester $I) // Act as if we completed OAuth. $I->setupKitPluginNoDefaultForms($I); - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2'); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Display an email capture form' + ); } /** @@ -171,7 +191,12 @@ public function testSetupWizardConnectAccountScreenWithInvalidCredentials(EndToE $this->_activatePlugin($I); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 1, 'Welcome to the Kit Setup Wizard'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'start', + stepCount: 1, + title: 'Welcome to the Kit Setup Wizard' + ); // Test Connect button. $I->click('Connect'); @@ -181,10 +206,15 @@ public function testSetupWizardConnectAccountScreenWithInvalidCredentials(EndToE $I->seeInSource('oauth/authorize?client_id=' . $_ENV['CONVERTKIT_OAUTH_CLIENT_ID']); // Act as if OAuth failed i.e. the user didn't authenticate. - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2&error=' . $error . '&error_description=' . urlencode($errorDescription)); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration&error=' . $error . '&error_description=' . urlencode($errorDescription)); // Confirm expected setup wizard screen is still displayed. - $this->_seeExpectedSetupWizardScreen($I, 1, 'Welcome to the Kit Setup Wizard'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'start', + stepCount: 1, + title: 'Welcome to the Kit Setup Wizard' + ); // Confirm error notification is displayed. $I->seeElement('div.notice.notice-error.is-dismissible'); @@ -233,10 +263,15 @@ public function testSetupWizardFormConfigurationScreen(EndToEndTester $I) ); // Load Step 2/3. - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2'); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Display an email capture form' + ); // Select a Post Form. $I->fillSelect2Field( @@ -290,7 +325,12 @@ public function testSetupWizardFormConfigurationScreen(EndToEndTester $I) $I->click('Finish Setup'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 3, 'Setup complete'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'finish', + stepCount: 3, + title: 'Setup complete' + ); // Click Plugin Settings. $I->click('Plugin Settings'); @@ -334,10 +374,15 @@ public function testSetupWizardUsageTrackingSetting(EndToEndTester $I) ); // Load Step 2/3. - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2'); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Display an email capture form' + ); // Uncheck Usage Tracking setting. $I->uncheckOption('#wp-convertkit-usage-tracking'); @@ -346,7 +391,12 @@ public function testSetupWizardUsageTrackingSetting(EndToEndTester $I) $I->click('Finish Setup'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 3, 'Setup complete'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'finish', + stepCount: 3, + title: 'Setup complete' + ); // Click Plugin Settings. $I->click('Plugin Settings'); @@ -358,10 +408,15 @@ public function testSetupWizardUsageTrackingSetting(EndToEndTester $I) $I->dontSeeCheckboxIsChecked('#usage_tracking'); // Load Step 2/3 on the Setup Wizard screen again. - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2'); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Display an email capture form' + ); // Check Usage Tracking setting. $I->checkOption('#wp-convertkit-usage-tracking'); @@ -370,7 +425,12 @@ public function testSetupWizardUsageTrackingSetting(EndToEndTester $I) $I->click('Finish Setup'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 3, 'Setup complete'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'finish', + stepCount: 3, + title: 'Setup complete' + ); // Click Plugin Settings. $I->click('Plugin Settings'); @@ -403,10 +463,16 @@ public function testSetupWizardFormConfigurationScreenWhenNoFormsExist(EndToEndT $I->setupKitPluginCredentialsNoData($I); // Load Step 2/3. - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2'); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Create your first Kit Form', true); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Create your first Kit Form', + nextButtonIsLink: true + ); // Confirm button link to create a form on Kit is correct. $I->seeInSource('click('I\'ve created a form in Kit'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Display an email capture form' + ); // Confirm we can select a Post Form. $I->fillSelect2Field( @@ -449,10 +520,15 @@ public function testSetupWizardFormConfigurationScreenWhenNoPostsOrPagesExist(En $I->setupKitPluginNoDefaultForms($I); // Load Step 2/3. - $I->amOnAdminPage('options.php?page=convertkit-setup&step=2'); + $I->amOnAdminPage('options.php?page=convertkit-setup&step=configuration'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 2, 'Display an email capture form'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'configuration', + stepCount: 2, + title: 'Display an email capture form' + ); // Confirm no Page or Post preview links exist, because there are no Pages or Posts in WordPress. $I->dontSeeElementInDOM('a#convertkit-preview-form-post'); @@ -483,7 +559,12 @@ public function testSetupWizardLinkOnPluginsScreen(EndToEndTester $I) $I->click('tr[data-slug="convertkit"] td div.row-actions span.setup_wizard a'); // Confirm expected setup wizard screen is displayed. - $this->_seeExpectedSetupWizardScreen($I, 1, 'Welcome to the Kit Setup Wizard'); + $this->_seeExpectedSetupWizardScreen( + $I, + step: 'start', + stepCount: 1, + title: 'Welcome to the Kit Setup Wizard' + ); } /** @@ -520,12 +601,13 @@ private function _activatePlugin(EndToEndTester $I) * * @since 1.9.8.4 * - * @param EndToEndTester $I Tester. - * @param int $step Current step. - * @param string $title Expected title. + * @param EndToEndTester $I Tester. + * @param string $step Current step. + * @param int $stepCount Current step count. + * @param string $title Expected title. * @param bool $nextButtonIsLink Check that next button is a link (false = must be a