From f8f2cf507861a136d8549ce9fb6e7b6b10ae734f Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Mon, 23 Dec 2024 12:06:57 +0900 Subject: [PATCH 1/2] =?UTF-8?q?InstallationsController::step2()=20?= =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Controller/Admin/InstallationsController.php | 1 + .../Controller/Admin/InstallationsControllerTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/src/Controller/Admin/InstallationsController.php b/plugins/bc-installer/src/Controller/Admin/InstallationsController.php index 59c5c9402f..79b0f2ac0f 100644 --- a/plugins/bc-installer/src/Controller/Admin/InstallationsController.php +++ b/plugins/bc-installer/src/Controller/Admin/InstallationsController.php @@ -79,6 +79,7 @@ public function index() * @return void * @noTodo * @checked + * @unitTest */ public function step2(InstallationsAdminServiceInterface $service) { diff --git a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php index 15c6f3af42..b0849ce830 100644 --- a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php +++ b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php @@ -12,6 +12,7 @@ namespace BcInstaller\Test\TestCase\Controller\Admin; use BaserCore\TestSuite\BcTestCase; use BcInstaller\Controller\Admin\InstallationsController; +use Cake\Core\Configure; use Cake\Event\Event; /** @@ -65,7 +66,12 @@ public function testIndex() */ public function testStep2() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + Configure::write("BcEnv.isInstalled", false); + + $this->get('/baser/admin/bc-installer/installations/step2'); + $this->assertResponseCode(200); + + Configure::write("BcEnv.isInstalled", true); } /** From 10abca6af3a18b5d1f3d0a887b386c1a734f66cb Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Thu, 26 Dec 2024 13:34:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?InstallationsController::step2()=20?= =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Admin/InstallationsControllerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php index b0849ce830..5ede67e6f7 100644 --- a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php +++ b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php @@ -10,10 +10,12 @@ */ namespace BcInstaller\Test\TestCase\Controller\Admin; +use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; use BcInstaller\Controller\Admin\InstallationsController; use Cake\Core\Configure; use Cake\Event\Event; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** * Class InstallationsControllerTest @@ -22,6 +24,7 @@ */ class InstallationsControllerTest extends BcTestCase { + use ScenarioAwareTrait; /** /** @@ -30,6 +33,8 @@ class InstallationsControllerTest extends BcTestCase public function setUp(): void { parent::setUp(); + $this->loadFixtureScenario(InitAppScenario::class); + $this->loginAdmin($this->getRequest()); } /** @@ -66,11 +71,17 @@ public function testIndex() */ public function testStep2() { + $this->enableSecurityToken(); + $this->enableCsrfToken(); + Configure::write("BcEnv.isInstalled", false); $this->get('/baser/admin/bc-installer/installations/step2'); $this->assertResponseCode(200); + $this->post('/baser/admin/bc-installer/installations/step2', ['mode'=>'next']); + $this->assertResponseCode(302); + Configure::write("BcEnv.isInstalled", true); }