Skip to content

Commit

Permalink
add unitTest_UploaderConfigsController_index
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed May 15, 2024
1 parent 74b7c6f commit 200d0ed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class UploaderConfigsController extends BcAdminAppController
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function index(UploaderConfigsServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace BcUploader\Test\TestCase\Controller\Admin;

use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BcUploader\Controller\Admin\UploaderConfigsController;
use Cake\TestSuite\IntegrationTestTrait;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

class UploaderConfigsControllerTest extends BcTestCase
{
use ScenarioAwareTrait;
use IntegrationTestTrait;

public function setUp(): void
{
parent::setUp();
$this->loadFixtureScenario(InitAppScenario::class);
$this->UploaderConfigsController = new UploaderConfigsController($this->loginAdmin($this->getRequest()));
}

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

/**
* test index
*/
public function test_index()
{
$this->enableSecurityToken();
$this->enableCsrfToken();

//正常系実行
$this->get("/baser/admin/bc-uploader/uploader_configs/index");
$this->assertResponseCode(200);

$this->post("/baser/admin/bc-uploader/uploader_configs/index", ['name_add' => 'value_add']);
$this->assertResponseCode(302);
$this->assertFlashMessage('アップローダー設定を保存しました。');
$this->assertRedirect("/baser/admin/bc-uploader/uploader_configs/index");
}
}

0 comments on commit 200d0ed

Please sign in to comment.