diff --git a/plugins/baser-core/src/Event/BcShortCodeEventListener.php b/plugins/baser-core/src/Event/BcShortCodeEventListener.php index 97efbd65e2..8cbd21144c 100644 --- a/plugins/baser-core/src/Event/BcShortCodeEventListener.php +++ b/plugins/baser-core/src/Event/BcShortCodeEventListener.php @@ -50,6 +50,7 @@ public function implementedEvents(): array * @return void * @checked * @noTodo + * @unitTest */ public function afterRender(Event $event) { @@ -65,6 +66,7 @@ public function afterRender(Event $event) * @return void * @checked * @noTodo + * @unitTest */ protected function _execShortCode(View $view) { diff --git a/plugins/baser-core/tests/TestCase/Event/BcShortCodeEventListenerTest.php b/plugins/baser-core/tests/TestCase/Event/BcShortCodeEventListenerTest.php index 667183dd9e..4fe21e662e 100644 --- a/plugins/baser-core/tests/TestCase/Event/BcShortCodeEventListenerTest.php +++ b/plugins/baser-core/tests/TestCase/Event/BcShortCodeEventListenerTest.php @@ -4,9 +4,16 @@ use BaserCore\Event\BcShortCodeEventListener; use BaserCore\TestSuite\BcTestCase; +use BaserCore\View\BcFrontAppView; +use Cake\Event\Event; class BcShortCodeEventListenerTest extends BcTestCase { + /** + * @var BcShortCodeEventListener + */ + protected $BcShortCodeEventListener; + public function setUp(): void { parent::setUp(); @@ -26,4 +33,34 @@ public function testImplementedEvents() $this->assertTrue(is_array($this->BcShortCodeEventListener->implementedEvents())); } + /** + * test afterRender + */ + public function testAfterRender() + { + //準備 + $view = new BcFrontAppView($this->getRequest('/')); + $view->loadHelper('BcBaser', ['className' => 'BaserCore.BcBaser']); + $view->assign('content', '[BcBaser.getSitemap]'); + $event = new Event('afterRender', $view); + //テストを実行 + $this->BcShortCodeEventListener->afterRender($event); + //戻り値を確認 + $this->assertTextContains('