/** * Internal events should be scheduled */ function test_events() { \Automattic\WP\Cron_Control\Internal_Events::instance()->schedule_internal_events(); $events = \Automattic\WP\Cron_Control\collapse_events_array(get_option('cron')); // Check that the plugin scheduled the expected number of events $this->assertEquals(count($events), 4); // Confirm that the scheduled jobs came from the Internal Events class foreach ($events as $event) { $this->assertTrue(\Automattic\WP\Cron_Control\is_internal_event($event['action'])); } }
/** * Check format of filtered array returned from CPT */ function test_filter_cron_option_get() { $event = Utils::create_test_event(); $cron = get_option('cron'); // Core versions the cron option (see `_upgrade_cron_array()`) // Without this in the filtered result, all events continually requeue as Core tries to "upgrade" the option $this->assertArrayHasKey('version', $cron); $this->assertEquals($cron['version'], 2); // Validate the remaining structure $cron = \Automattic\WP\Cron_Control\collapse_events_array($cron); foreach ($cron as $single_cron) { $this->assertEquals($single_cron['timestamp'], $event['timestamp']); $this->assertEquals($single_cron['action'], $event['action']); $this->assertArrayHasKey('args', $single_cron); $this->assertArrayHasKey('schedule', $single_cron['args']); $this->assertArrayHasKey('args', $single_cron['args']); $this->assertEquals($single_cron['args']['args'], $event['args']); } }