PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.8.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.8.0
2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.7 2.6.8 2.6.5 2.6.4 2.6.3 2.6.2 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2.0 2.0 2.1.0 2.1.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1
reviews-feed / tests / Unit / Doubles / FeedCacheWpdbDouble.php
reviews-feed / tests / Unit / Doubles Last commit date
FeedCacheWpdbDouble.php 1 month ago
FeedCacheWpdbDouble.php
62 lines
1 <?php
2
3 namespace SmashBalloon\Reviews\Tests\Unit\Doubles;
4
5 /**
6 * Minimal `wpdb` test double for FeedCacheUpdateServiceTest.
7 *
8 * Captures the SQL handed to prepare()/get_results() so the dedupe + ordering
9 * contract on `FeedCacheUpdateService::feed_caches_query()` can be asserted
10 * without a live database. Exists in its own file (PSR1 — one class per file)
11 * and uses untyped properties (PHP 7.1+ baseline per phpcs.xml).
12 */
13 class FeedCacheWpdbDouble
14 {
15 /** @var string */
16 public $prefix = 'wp_';
17
18 /** @var string|null */
19 public $last_prepared_sql = null;
20
21 /** @var array<int, mixed> */
22 public $last_prepared_args = array();
23
24 /** @var string|null */
25 public $last_get_results_sql = null;
26
27 /** @var array<int, array<string, mixed>> */
28 public $next_results = array();
29
30 /**
31 * @param string $sql
32 * @param mixed ...$args
33 * @return string
34 */
35 public function esc_like($text)
36 {
37 return addcslashes((string) $text, '_%\\');
38 }
39
40 public function prepare($sql, ...$args)
41 {
42 $this->last_prepared_sql = $sql;
43 $this->last_prepared_args = $args;
44 // We don't need a real interpolation — the production code reads the
45 // returned string and immediately hands it to get_results, which we
46 // also intercept. Returning the raw template is enough for the
47 // behavioral assertions in this suite.
48 return $sql;
49 }
50
51 /**
52 * @param string $sql
53 * @param string $output_type
54 * @return array<int, array<string, mixed>>
55 */
56 public function get_results($sql, $output_type = 'OBJECT')
57 {
58 $this->last_get_results_sql = $sql;
59 return $this->next_results;
60 }
61 }
62