feat(wpmc S3): ShortcodeDmr scaffold + register init hook
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace WPMultiCity;
|
||||||
|
|
||||||
|
final class ShortcodeDmr
|
||||||
|
{
|
||||||
|
public const SHORTCODE = 'shortcode_dmr';
|
||||||
|
|
||||||
|
private static array $render_cache = [];
|
||||||
|
|
||||||
|
public static function reset_cache(): void
|
||||||
|
{
|
||||||
|
self::$render_cache = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function register(): void
|
||||||
|
{
|
||||||
|
\add_action('init', [self::class, 'do_register']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function do_register(): void
|
||||||
|
{
|
||||||
|
\add_shortcode(self::SHORTCODE, [self::class, 'render']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function render($atts = [], $content = null): string
|
||||||
|
{
|
||||||
|
// Implementation in Task 13.
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace WPMultiCity\Tests;
|
||||||
|
|
||||||
|
use WPMultiCity\ShortcodeDmr;
|
||||||
|
|
||||||
|
final class ShortcodeDmrTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_register_attaches_init_action(): void
|
||||||
|
{
|
||||||
|
ShortcodeDmr::register();
|
||||||
|
|
||||||
|
self::assertNotFalse(
|
||||||
|
has_action('init', [ShortcodeDmr::class, 'do_register']),
|
||||||
|
'ShortcodeDmr::register() must hook init'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace WPMultiCity\Tests;
|
|||||||
use Brain\Monkey;
|
use Brain\Monkey;
|
||||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||||
use WPMultiCity\Helpers;
|
use WPMultiCity\Helpers;
|
||||||
|
use WPMultiCity\ShortcodeDmr;
|
||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,7 @@ abstract class TestCase extends BaseTestCase
|
|||||||
Monkey\setUp();
|
Monkey\setUp();
|
||||||
Monkey\Functions\stubTranslationFunctions();
|
Monkey\Functions\stubTranslationFunctions();
|
||||||
Helpers::reset_cache();
|
Helpers::reset_cache();
|
||||||
|
ShortcodeDmr::reset_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
|
|||||||
Reference in New Issue
Block a user