diff --git a/plugins/bc-installer/src/Controller/Admin/InstallationsController.php b/plugins/bc-installer/src/Controller/Admin/InstallationsController.php index 59c5c9402f..6d8ee4de1a 100644 --- a/plugins/bc-installer/src/Controller/Admin/InstallationsController.php +++ b/plugins/bc-installer/src/Controller/Admin/InstallationsController.php @@ -98,6 +98,7 @@ public function step2(InstallationsAdminServiceInterface $service) * @return void|Response * @noTodo * @checked + * @unitTest */ public function step3(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..3c36ff1598 100644 --- a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php +++ b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php @@ -10,9 +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 @@ -21,6 +24,7 @@ */ class InstallationsControllerTest extends BcTestCase { + use ScenarioAwareTrait; /** /** @@ -29,6 +33,8 @@ class InstallationsControllerTest extends BcTestCase public function setUp(): void { parent::setUp(); + $this->loadFixtureScenario(InitAppScenario::class); + $this->loginAdmin($this->getRequest()); } /** @@ -73,7 +79,41 @@ public function testStep2() */ public function testStep3() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->enableSecurityToken(); + $this->enableCsrfToken(); + Configure::write("BcEnv.isInstalled", false); + + $this->get('/baser/admin/bc-installer/installations/step3'); + $this->assertResponseCode(200); + + $config = [ + 'mode' => 'back', + 'dbType' => 'mysql', + 'dbHost' => 'localhost', + 'dbPrefix' => '', + 'dbPort' => '3306', + 'dbUsername' => 'dbUsername', + 'dbPassword' => 'dbPassword', + 'dbSchema' => 'dbSchema', + 'dbName' => 'basercms', + 'dbEncoding' => 'utf-8', + 'dbDataPattern' => 'BcThemeSample.default' + ]; + + $this->post('/baser/admin/bc-installer/installations/step3', $config); + $this->assertResponseCode(302); + $this->assertRedirect('/baser/admin/bc-installer/installations/step2'); + + $config['mode'] = 'checkDb'; + $this->post('/baser/admin/bc-installer/installations/step3', $config); + $this->assertResponseCode(200); + + $config['mode'] = 'createDb'; + $this->post('/baser/admin/bc-installer/installations/step3', $config); + $this->assertResponseCode(200); + + + Configure::write("BcEnv.isInstalled", true); } /**