• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 6892223656

16 Nov 2023 02:35PM UTC coverage: 49.203% (-0.08%) from 49.287%
6892223656

Pull #20470

github

thijsoo
Fix unit tests.
Pull Request #20470: Introduces indexables verification cron

129 of 283 new or added lines in 25 files covered. (45.58%)

652 existing lines in 2 files now uncovered.

13368 of 27169 relevant lines covered (49.2%)

3.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/src/indexables/application/verification-cron-schedule-handler.php
1
<?php
2

3
namespace Yoast\WP\SEO\Indexables\Application;
4

5
use Yoast\WP\SEO\Helpers\Options_Helper;
6

7
/**
8
 * The Verification_Cron_Schedule_Handler class.
9
 */
10
class Verification_Cron_Schedule_Handler {
11

12
        /**
13
         * The name of the cron job.
14
         */
15
        public const INDEXABLE_VERIFY_POST_INDEXABLES_NAME = 'wpseo_indexable_verify_post_indexables';
16

17
        /**
18
         * The name of the cron job.
19
         */
20
        public const INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME = 'wpseo_indexable_verify_non_timestamped_indexables';
21

22
        /**
23
         * The Cron_Verification_Gate instance.
24
         *
25
         * @var Cron_Verification_Gate
26
         */
27
        private $cron_verification_gate;
28

29
        /**
30
         * The Options_Helper instance.
31
         *
32
         * @var Options_Helper
33
         */
34
        private $options_helper;
35

36
        /**
37
         * The constructor.
38
         *
39
         * @param Cron_Verification_Gate $cron_verification_gate The cron verification gate.
40
         * @param Options_Helper         $options_helper         The options helper.
41
         */
42
        public function __construct( Cron_Verification_Gate $cron_verification_gate, Options_Helper $options_helper ) {
NEW
43
                $this->cron_verification_gate = $cron_verification_gate;
×
NEW
44
                $this->options_helper         = $options_helper;
×
45
        }
46

47
        /**
48
         * Schedules the indexable verification crons.
49
         *
50
         * @return void
51
         */
52
        public function schedule_indexable_verification(): void {
53
                if ( $this->options_helper->get( 'activation_redirect_timestamp_free', 0 ) === 0 ) {
10✔
NEW
54
                        return;
×
55
                }
56

57
                if ( $this->cron_verification_gate->should_verify_on_cron() && ! \wp_next_scheduled( self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME ) ) {
10✔
58
                        \wp_schedule_event( ( \time() + \HOUR_IN_SECONDS ), 'fifteen_minutes', self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME );
2✔
59
                }
60

61
                if ( $this->cron_verification_gate->should_verify_on_cron() && ! \wp_next_scheduled( self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME ) ) {
10✔
62
                        \wp_schedule_event( ( \time() + \HOUR_IN_SECONDS ), 'fifteen_minutes', self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME );
4✔
63
                }
64
        }
5✔
65

66
        /**
67
         * Unschedules the indexable post verification cron.
68
         *
69
         * @return void
70
         */
71
        public function unschedule_verify_post_indexables_cron() {
NEW
72
                $scheduled = \wp_next_scheduled( self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME );
×
NEW
73
                if ( $scheduled ) {
×
NEW
74
                        \wp_unschedule_event( $scheduled, self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME );
×
75
                }
76
        }
77

78
        /**
79
         * Unschedules the non timestamped cron.
80
         *
81
         * @return void
82
         */
83
        public function unschedule_verify_non_timestamped_indexables_cron() {
NEW
84
                $scheduled = \wp_next_scheduled( self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME );
×
NEW
85
                if ( $scheduled ) {
×
NEW
86
                        \wp_unschedule_event( $scheduled, self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME );
×
87
                }
88
        }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc