|
13 | 13 | use RoxyAPI\Plugin; |
14 | 14 | use RoxyAPI\Shortcodes\Registrar; |
15 | 15 |
|
16 | | -class Test_Shortcode_Registrar extends \WP_UnitTestCase { |
| 16 | +class Test_Shortcode_Registrar extends Mock_Http_TestCase { |
17 | 17 |
|
18 | 18 | public function setUp(): void { |
19 | 19 | parent::setUp(); |
| 20 | + // test_hero_wins_on_tag_collision renders the hero for real, so the |
| 21 | + // response has to be canned. Without a key the client still reaches the |
| 22 | + // SaaS over the keyless free-tier path, which made this suite render a |
| 23 | + // live reading on every run. |
| 24 | + $this->mock_responses['astrology/horoscope/aries/daily'] = array( |
| 25 | + 'sign' => 'aries', |
| 26 | + 'overview' => 'A bold day ahead.', |
| 27 | + ); |
20 | 28 | // Re-running do_action('init') would double-register blocks and |
21 | 29 | // bindings sources, which the test framework flags as |
22 | 30 | // _doing_it_wrong. Instead, invoke the registrar's static methods |
@@ -64,13 +72,16 @@ public function test_hero_wins_on_tag_collision(): void { |
64 | 72 | $this->assertIsCallable( $callable ); |
65 | 73 |
|
66 | 74 | // The hero closure has the Horoscope class baked in via `use ($class)`. |
67 | | - // Render with a known sign and check the output contains the hero CSS |
68 | | - // hook (`roxyapi-horoscope`), which the generic renderer never emits. |
69 | | - // Even when the API call fails (no key configured here), the hero |
70 | | - // returns the friendly placeholder string. The generic renderer would |
71 | | - // emit a `<dl class="roxyapi-generic ...">` shell instead. |
| 75 | + // Render with a known sign against the canned response: the hero |
| 76 | + // template emits `roxy-horoscope-card`, which the generic renderer |
| 77 | + // never does. It emits a `<dl class="roxyapi-generic ...">` shell. |
72 | 78 | $out = call_user_func( $callable, array( 'sign' => 'aries' ), '', $tag ); |
73 | 79 | $this->assertIsString( $out ); |
| 80 | + $this->assertStringContainsString( |
| 81 | + 'roxy-horoscope-card', |
| 82 | + $out, |
| 83 | + 'The collided tag must resolve to the hero renderer.' |
| 84 | + ); |
74 | 85 | // Hero output must NOT contain the generic-renderer signature class. |
75 | 86 | $this->assertStringNotContainsString( 'roxyapi-generic', $out ); |
76 | 87 | } |
|
0 commit comments