diff --git a/tests/ShortcodeDmrTest.php b/tests/ShortcodeDmrTest.php index 49e32bf..25ac489 100644 --- a/tests/ShortcodeDmrTest.php +++ b/tests/ShortcodeDmrTest.php @@ -105,4 +105,25 @@ final class ShortcodeDmrTest extends TestCase self::assertSame('', ShortcodeDmr::render(['id' => 42])); } + + public function test_render_caches_result_per_id_and_town(): void + { + $_SERVER['REQUEST_URI'] = '/tyumen/'; + \Brain\Monkey\Functions\when('get_terms')->justReturn([11 => 'tyumen']); + $term = new \WP_Term(); + $term->term_id = 11; + $term->slug = 'tyumen'; + \Brain\Monkey\Functions\when('get_term_by')->justReturn($term); + + \Brain\Monkey\Functions\expect('get_field') + ->once() + ->with('list_shortcode', 42) + ->andReturn([['town' => 11, 'text' => 'Тюмень-текст']]); + + ShortcodeDmr::render(['id' => 42]); + ShortcodeDmr::render(['id' => 42]); + ShortcodeDmr::render(['id' => 42]); + + self::assertTrue(true); + } }