Skip to content

Commit

Permalink
Merge pull request #3950 from HungDV2022/unittest_InstallationsAdminS…
Browse files Browse the repository at this point in the history
…ervice_initDb

InstallationsAdminService::initDb() のユニットテスト
  • Loading branch information
HungDV2022 authored Oct 28, 2024
2 parents 3e526c0 + 15b0ad2 commit 2a264da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ public function login(ServerRequest $request, Response $response): void
* @param ServerRequest $request
* @checked
* @noTodo
* @unitTest
*/
public function initDb(ServerRequest $request): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace BcInstaller\Test\TestCase\Service\Admin;

use BaserCore\Service\PermissionGroupsServiceInterface;
use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Factory\ContentFolderFactory;
use BaserCore\Test\Factory\UserFactory;
Expand All @@ -21,6 +22,7 @@
use BaserCore\Utility\BcFile;
use BcInstaller\Service\Admin\InstallationsAdminService;
use BcInstaller\Service\Admin\InstallationsAdminServiceInterface;
use BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario;
use Cake\Core\Configure;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
Expand Down Expand Up @@ -555,7 +557,22 @@ public function test_login()
*/
public function test_initDb()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
//準備
$PermissionGroupsService = $this->getService(PermissionGroupsServiceInterface::class);
$this->loadFixtureScenario(SearchIndexesServiceScenario::class);
//テスト前、アクセスルールを確認
$this->assertCount(0, $PermissionGroupsService->getList());

//テストを実行
$this->Installations->initDb(new ServerRequest());

// データベースのデータを初期設定に更新できるか確認
$searchIndexesTable = $this->getTableLocator()->get('SearchIndexes');
$this->assertEquals(3, $searchIndexesTable->find()->count());
//テスト後、アクセスルールを確認
$this->assertCount(28, $PermissionGroupsService->getList());
// SITE_URL更新
$this->assertEquals('https://localhost/', env('SITE_URL'));
}

}

0 comments on commit 2a264da

Please sign in to comment.