Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstallationsController::step3() ユニットテスト #4101

Open
wants to merge 1 commit into
base: 5.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function step2(InstallationsAdminServiceInterface $service)
* @return void|Response
* @noTodo
* @checked
* @unitTest
*/
public function step3(InstallationsAdminServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,6 +24,7 @@
*/
class InstallationsControllerTest extends BcTestCase
{
use ScenarioAwareTrait;

/**
/**
Expand All @@ -29,6 +33,8 @@ class InstallationsControllerTest extends BcTestCase
public function setUp(): void
{
parent::setUp();
$this->loadFixtureScenario(InitAppScenario::class);
$this->loginAdmin($this->getRequest());
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down