• 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

68.42
/src/indexables/application/commands/verify-post-indexables-command-handler.php
1
<?php
2

3
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case.
4
namespace Yoast\WP\SEO\Indexables\Application\Commands;
5

6
use Yoast\WP\SEO\Builders\Indexable_Builder;
7
use Yoast\WP\SEO\Indexables\Application\Ports\Outdated_Post_Indexables_Repository_Interface;
8
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Batch_Handler;
9
use Yoast\WP\SEO\Indexables\Application\Verification_Cron_Schedule_Handler;
10
use Yoast\WP\SEO\Indexables\Domain\Exceptions\No_Outdated_Posts_Found_Exception;
11

12
/**
13
 * Command handler class.
14
 */
15
class Verify_Post_Indexables_Command_Handler {
16

17
        /**
18
         * The Outdated_Post_Indexables_Repository_Interface instance.
19
         *
20
         * @var Outdated_Post_Indexables_Repository_Interface
21
         */
22
        protected $outdated_post_indexables_repository;
23

24
        /**
25
         * The Verification_Cron_Batch_Handler instance.
26
         *
27
         * @var Verification_Cron_Batch_Handler
28
         */
29
        protected $verification_cron_batch_handler;
30

31
        /**
32
         * The Verification_Cron_Schedule_Handler instance.
33
         *
34
         * @var Verification_Cron_Schedule_Handler
35
         */
36
        private $cron_schedule_handler;
37

38
        /**
39
         * The Indexable_Builder instance.
40
         *
41
         * @var Indexable_Builder
42
         */
43
        protected $indexable_builder;
44

45
        /**
46
         * The constructor.
47
         *
48
         * @param Outdated_Post_Indexables_Repository_Interface $outdated_post_indexables_repository The outdated post
49
         *                                                                                           indexables repository.
50
         * @param Verification_Cron_Schedule_Handler            $cron_schedule_handler               The cron schedule
51
         *                                                                                           handler.
52
         * @param Verification_Cron_Batch_Handler               $verification_cron_batch_handler     The verification cron
53
         *                                                                                           batch handler.
54
         * @param Indexable_Builder                             $indexable_builder                   The indexable builder.
55
         */
56
        public function __construct(
57
                Outdated_Post_Indexables_Repository_Interface $outdated_post_indexables_repository,
58
                Verification_Cron_Schedule_Handler $cron_schedule_handler,
59
                Verification_Cron_Batch_Handler $verification_cron_batch_handler,
60
                Indexable_Builder $indexable_builder
61
        ) {
62

NEW
63
                $this->outdated_post_indexables_repository = $outdated_post_indexables_repository;
×
NEW
64
                $this->cron_schedule_handler               = $cron_schedule_handler;
×
NEW
65
                $this->indexable_builder                   = $indexable_builder;
×
NEW
66
                $this->verification_cron_batch_handler     = $verification_cron_batch_handler;
×
67
        }
68

69
        /**
70
         * Handles the Verify_Post_Indexables_Command command.
71
         *
72
         * @param Verify_Post_Indexables_Command $verify_post_indexables_command The command.
73
         */
74
        public function handle( Verify_Post_Indexables_Command $verify_post_indexables_command ): void {
75
                try {
76
                        $outdated_post_indexables_list = $this->outdated_post_indexables_repository->get_outdated_post_indexables( $verify_post_indexables_command->get_last_batch_count() );
4✔
77
                } catch ( No_Outdated_Posts_Found_Exception $exception ) {
2✔
78
                        $this->cron_schedule_handler->unschedule_verify_post_indexables_cron();
2✔
79

80
                        return;
2✔
81
                }
82

83
                foreach ( $outdated_post_indexables_list as $post_indexable ) {
2✔
84
                        $this->indexable_builder->build( $post_indexable );
2✔
85
                }
86

87
                if ( ! $verify_post_indexables_command->get_batch_size()
2✔
88
                        ->should_keep_going( $outdated_post_indexables_list->count() ) ) {
2✔
NEW
89
                        $this->cron_schedule_handler->unschedule_verify_post_indexables_cron();
×
90

NEW
91
                        return;
×
92
                }
93

94
                $this->verification_cron_batch_handler->set_current_post_indexables_batch(
2✔
95
                        $verify_post_indexables_command->get_last_batch_count(),
2✔
96
                        $verify_post_indexables_command->get_batch_size()
2✔
97
                );
1✔
98
        }
1✔
99
}
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