service_test_id; }, $tests ); self::set_option(); $request = Service::run_manual_tests( $service_test_ids, [ 'trigger_meta' => [ 'user_id' => get_current_user_id() ], ] ); $test_ids = array_map( function ( $test ) { return $test->id; }, $tests ); if ( 201 === $request['status_code'] ) { self::set_option( 1 ); $response = $request['response']; $service = new Test_Run_Service(); $id = $service->create_test_run( $response['id'], [ 'tests' => maybe_serialize( $test_ids ), 'trigger' => 'manual', 'started_at' => current_time( 'mysql' ), ] ); Cron_Jobs::schedule_initial_fetch_test_run_updates( $id ); } else { self::set_option( 2 ); } } }