Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed May 8, 2024
1 parent 974aa12 commit 8cb9a97
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace BcEditorTemplate\Test\TestCase\Controller\Admin;

use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\Test\Factory\SiteConfigFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
Expand Down Expand Up @@ -120,22 +121,22 @@ public function testAdmin_add()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
//サービスクラス
$siteConfigsService = $this->getService(SiteConfigsServiceInterface::class);
//のバリューをリセットする
$siteConfigsService->resetValue('editor');
//set data
$data = ['name' => 'test', 'description' => 'test description'];
$this->post('/baser/admin/bc-editor-template/editor_templates/add', $data);
//check status code

SiteConfigFactory::make(['name' => 'editor', 'value' => 'BaserCore.BcCkeditor'])->persist();

//正常系実行
$this->post('/baser/admin/bc-editor-template/editor_templates/add', ['name' => 'test', 'description' => 'test description']);
$this->assertResponseCode(302);
//check message
$this->assertFlashMessage('テンプレート「test」を追加しました');
//check redirect
$this->assertRedirect(['action' => 'index']);
//check message error

//異常系実行
$this->post('/baser/admin/bc-editor-template/editor_templates/add', ['name' => '']);
$this->assertFlashMessage('入力エラーです。内容を修正してください。');
$this->assertResponseCode(200);

//エラーメッセージを確認
$vars = $this->_controller->viewBuilder()->getVars();
$this->assertEquals(['name' => ['_empty' => "テンプレート名を入力してください。"]], $vars['editorTemplate']->getErrors());
}

/**
Expand Down

0 comments on commit 8cb9a97

Please sign in to comment.