PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.29
ووسلام – همگام سازی ووکامرس و باسلام v1.10.29
1.10.29 1.10.28 1.1.26 1.10.27 1.10.24 1.10.25 1.10.23 1.10.22 1.10.21 1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 All 62 releases
sync-basalam / tests / Support / JobsRunnerWordPressStubs.php

JobsRunnerWordPressStubs.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.29, at tests/Support/JobsRunnerWordPressStubs.php

166 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!function_exists('add_action')) {
4 function add_action($hookName, $callback, $priority = 10, $acceptedArgs = 1)
5 {
6 $GLOBALS['sync_basalam_jobs_runner_test_state']['actions'][$hookName][] = [
7 'callback' => $callback,
8 'priority' => $priority,
9 'accepted_args' => $acceptedArgs,
10 ];
11
12 return true;
13 }
14 }
15
16 if (!function_exists('did_action')) {
17 function did_action($hookName)
18 {
19 return $GLOBALS['sync_basalam_jobs_runner_test_state']['did_actions'][$hookName] ?? 0;
20 }
21 }
22
23 if (!function_exists('current_filter')) {
24 function current_filter()
25 {
26 return $GLOBALS['sync_basalam_jobs_runner_test_state']['current_filter'] ?? '';
27 }
28 }
29
30 if (!function_exists('fastcgi_finish_request')) {
31 function fastcgi_finish_request()
32 {
33 $GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'fastcgi_finish_request';
34
35 return true;
36 }
37 }
38
39 if (!function_exists('wp_doing_ajax')) {
40 function wp_doing_ajax()
41 {
42 return $GLOBALS['sync_basalam_jobs_runner_test_state']['doing_ajax'] ?? false;
43 }
44 }
45
46 if (!function_exists('wp_unslash')) {
47 function wp_unslash($value)
48 {
49 return is_string($value) ? stripslashes($value) : $value;
50 }
51 }
52
53 if (!function_exists('sanitize_key')) {
54 function sanitize_key($key)
55 {
56 return preg_replace('/[^a-z0-9_\-]/', '', strtolower((string) $key));
57 }
58 }
59
60 if (!function_exists('get_transient')) {
61 function get_transient($transient)
62 {
63 $GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'get_transient';
64 $GLOBALS['sync_basalam_jobs_runner_test_state']['transient_reads'][] = $transient;
65
66 return $GLOBALS['sync_basalam_jobs_runner_test_state']['transients'][$transient] ?? false;
67 }
68 }
69
70 if (!function_exists('get_option')) {
71 function get_option($name, $default = false)
72 {
73 return $GLOBALS['sync_basalam_test_options'][$name] ?? $default;
74 }
75 }
76
77 if (!function_exists('update_option')) {
78 function update_option($name, $value, $autoload = null)
79 {
80 $GLOBALS['sync_basalam_test_options'][$name] = $value;
81 return true;
82 }
83 }
84
85 if (!function_exists('wp_using_ext_object_cache')) {
86 function wp_using_ext_object_cache()
87 {
88 return $GLOBALS['sync_basalam_jobs_runner_test_state']['external_object_cache'] ?? false;
89 }
90 }
91
92 if (!function_exists('wp_installing')) {
93 function wp_installing()
94 {
95 return false;
96 }
97 }
98
99 if (!function_exists('set_transient')) {
100 function set_transient($transient, $value, $expiration = 0)
101 {
102 $GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'set_transient';
103 $GLOBALS['sync_basalam_jobs_runner_test_state']['transient_writes'][] = [
104 'name' => $transient,
105 'value' => $value,
106 'expiration' => $expiration,
107 ];
108 $GLOBALS['sync_basalam_jobs_runner_test_state']['transients'][$transient] = $value;
109 if ($expiration > 0) {
110 $GLOBALS['sync_basalam_test_options']['_transient_timeout_' . $transient] = time() + $expiration;
111 }
112
113 return true;
114 }
115 }
116
117 if (!function_exists('admin_url')) {
118 function admin_url($path = '')
119 {
120 return 'https://example.test/wp-admin/' . ltrim($path, '/');
121 }
122 }
123
124 if (!function_exists('add_query_arg')) {
125 function add_query_arg($key, $value, $url)
126 {
127 $separator = strpos($url, '?') === false ? '?' : '&';
128
129 return $url . $separator . rawurlencode((string) $key) . '=' . rawurlencode((string) $value);
130 }
131 }
132
133 if (!function_exists('esc_url_raw')) {
134 function esc_url_raw($url)
135 {
136 return $url;
137 }
138 }
139
140 if (!function_exists('wp_create_nonce')) {
141 function wp_create_nonce($action = -1)
142 {
143 return 'test-nonce-for-' . $action;
144 }
145 }
146
147 if (!function_exists('apply_filters')) {
148 function apply_filters($hookName, $value)
149 {
150 return $GLOBALS['sync_basalam_jobs_runner_test_state']['filter_values'][$hookName] ?? $value;
151 }
152 }
153
154 if (!function_exists('wp_remote_post')) {
155 function wp_remote_post($url, $args = [])
156 {
157 $GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'remote_post';
158 $GLOBALS['sync_basalam_jobs_runner_test_state']['remote_requests'][] = [
159 'url' => $url,
160 'args' => $args,
161 ];
162
163 return ['response' => ['code' => 200]];
164 }
165 }
166