Skip to content

Commit d108efa

Browse files
HungDV2022dovanhungryuring
authored
InstallationsController::step3() ユニットテスト (#4101)
Co-authored-by: HungDV2022 <dovanhungk57@gmail.com> Co-authored-by: ryuring <egashira@catchup.co.jp>
1 parent 00f5392 commit d108efa

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

plugins/bc-installer/src/Controller/Admin/InstallationsController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function step2(InstallationsAdminServiceInterface $service)
100100
* @return void|Response
101101
* @noTodo
102102
* @checked
103+
* @unitTest
103104
*/
104105
public function step3(InstallationsAdminServiceInterface $service)
105106
{

plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
class InstallationsControllerTest extends BcTestCase
2727
{
2828
use ScenarioAwareTrait;
29-
3029
use BcContainerTrait;
3130

31+
3232
/**
3333
* setup
3434
*/
@@ -109,7 +109,41 @@ public function testStep2()
109109
*/
110110
public function testStep3()
111111
{
112-
$this->markTestIncomplete('このテストは、まだ実装されていません。');
112+
$this->enableSecurityToken();
113+
$this->enableCsrfToken();
114+
Configure::write("BcEnv.isInstalled", false);
115+
116+
$this->get('/baser/admin/bc-installer/installations/step3');
117+
$this->assertResponseCode(200);
118+
119+
$config = [
120+
'mode' => 'back',
121+
'dbType' => 'mysql',
122+
'dbHost' => 'localhost',
123+
'dbPrefix' => '',
124+
'dbPort' => '3306',
125+
'dbUsername' => 'dbUsername',
126+
'dbPassword' => 'dbPassword',
127+
'dbSchema' => 'dbSchema',
128+
'dbName' => 'basercms',
129+
'dbEncoding' => 'utf-8',
130+
'dbDataPattern' => 'BcThemeSample.default'
131+
];
132+
133+
$this->post('/baser/admin/bc-installer/installations/step3', $config);
134+
$this->assertResponseCode(302);
135+
$this->assertRedirect('/baser/admin/bc-installer/installations/step2');
136+
137+
$config['mode'] = 'checkDb';
138+
$this->post('/baser/admin/bc-installer/installations/step3', $config);
139+
$this->assertResponseCode(200);
140+
141+
$config['mode'] = 'createDb';
142+
$this->post('/baser/admin/bc-installer/installations/step3', $config);
143+
$this->assertResponseCode(200);
144+
145+
146+
Configure::write("BcEnv.isInstalled", true);
113147
}
114148

115149
/**

0 commit comments

Comments
 (0)