Skip to content

Commit

Permalink
Merge pull request #3952 from thangnnmd/unitTest_BcThemeConfigControl…
Browse files Browse the repository at this point in the history
…lerEventListener_baserCoreThemesAfterApply

BcThemeConfigControllerEventListener::baserCoreThemesAfte…
  • Loading branch information
HungDV2022 authored Nov 6, 2024
2 parents c1d5935 + 543fe84 commit 03626b3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class BcThemeConfigControllerEventListener extends BcControllerEventListener
* テーマ適用後イベント
* @param Event $event
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function baserCoreThemesAfterApply(Event $event)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace BcThemeConfig\Test\TestCase\Event;

use BaserCore\TestSuite\BcTestCase;
use BcThemeConfig\Event\BcThemeConfigControllerEventListener;
use Cake\Event\Event;

class BcThemeConfigControllerEventListenerTest extends BcTestCase
{
public function setUp(): void
{
parent::setUp();
$this->BcThemeConfigControllerEventListener = new BcThemeConfigControllerEventListener();
}

public function tearDown(): void
{
parent::tearDown();
}

/**
* Test baserCoreThemesAfterApply
*/
public function test_baserCoreThemesAfterApply()
{
$path = WWW_ROOT . 'files' . DS . 'theme_configs' . DS . 'config.css';

if (!is_dir(dirname($path))) {
mkdir(dirname($path), 0777, true);
}
file_put_contents($path, 'test content');
$this->assertFileExists($path);

$event = new Event('BaserCore.Themes.afterApply');
$this->BcThemeConfigControllerEventListener->baserCoreThemesAfterApply($event);

$this->assertFileDoesNotExist($path);
}
}

0 comments on commit 03626b3

Please sign in to comment.