feat(wpmc S3): ShortcodeDmr::render resolves text by current town
This commit is contained in:
@@ -27,4 +27,29 @@ final class ShortcodeDmrTest extends TestCase
|
||||
|
||||
self::assertTrue(true);
|
||||
}
|
||||
|
||||
public function test_render_returns_text_when_row_matches_current_town(): void
|
||||
{
|
||||
$_SERVER['REQUEST_URI'] = '/tyumen/';
|
||||
\Brain\Monkey\Functions\when('get_terms')->justReturn([10 => 'spb', 11 => 'tyumen']);
|
||||
|
||||
$term = new \WP_Term();
|
||||
$term->term_id = 11;
|
||||
$term->slug = 'tyumen';
|
||||
\Brain\Monkey\Functions\when('get_term_by')->alias(function ($field, $slug, $tax) use ($term) {
|
||||
return ($field === 'slug' && $slug === 'tyumen' && $tax === 'town') ? $term : false;
|
||||
});
|
||||
|
||||
\Brain\Monkey\Functions\expect('get_field')
|
||||
->once()
|
||||
->with('list_shortcode', 42)
|
||||
->andReturn([
|
||||
['town' => 10, 'text' => 'СПб-текст'],
|
||||
['town' => 11, 'text' => 'Тюмень-текст'],
|
||||
]);
|
||||
|
||||
$result = ShortcodeDmr::render(['id' => 42]);
|
||||
|
||||
self::assertSame('Тюмень-текст', $result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user