diff --git a/plugins/bc-installer/src/Controller/Admin/InstallationsController.php b/plugins/bc-installer/src/Controller/Admin/InstallationsController.php index 59c5c9402f..1a5da3e31b 100644 --- a/plugins/bc-installer/src/Controller/Admin/InstallationsController.php +++ b/plugins/bc-installer/src/Controller/Admin/InstallationsController.php @@ -64,6 +64,7 @@ public function beforeFilter(EventInterface $event) * @return void * @noTodo * @checked + * @unitTest */ public function index() { diff --git a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php index 15c6f3af42..5d7562154e 100644 --- a/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php +++ b/plugins/bc-installer/tests/TestCase/Controller/Admin/InstallationsControllerTest.php @@ -11,7 +11,9 @@ namespace BcInstaller\Test\TestCase\Controller\Admin; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcContainerTrait; use BcInstaller\Controller\Admin\InstallationsController; +use Cake\Core\Configure; use Cake\Event\Event; /** @@ -22,7 +24,8 @@ class InstallationsControllerTest extends BcTestCase { - /** + use BcContainerTrait; + /** * setup */ @@ -46,6 +49,7 @@ public function tearDown(): void */ public function testBeforeFilter() { + $this->markTestSkipped('このテストは未確認です。'); $this->InstallationsController = new InstallationsController($this->getRequest()); $event = new Event('Controller.beforeFilter', $this->InstallationsController); $this->InstallationsController->beforeFilter($event); @@ -57,7 +61,23 @@ public function testBeforeFilter() */ public function testIndex() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + Configure::write("BcEnv.isInstalled", false); + //backup file + copy(ROOT . DS . 'config' . DS . '.env', ROOT . DS . 'config' . DS . '.env.bak'); + copy(ROOT . DS . 'config' . DS . 'install.php', ROOT . DS . 'config' . DS . 'install.php.bak'); + copy(ROOT . DS . 'vendor' . DS . 'autoload.php', ROOT . DS . 'vendor' . DS . 'autoload.php.bak'); + $this->get('/'); + + //CSRFがあるか確認すること + $_cookies = $this->getPrivateProperty($this->_response, '_cookies'); + $cookies = $this->getPrivateProperty($_cookies, 'cookies'); + $this->assertNotEmpty($cookies['csrfToken;;/']); + + Configure::write("BcEnv.isInstalled", true); + //backup + rename(ROOT . DS . 'config' . DS . '.env.bak', ROOT . DS . 'config' . DS . '.env'); + rename(ROOT . DS . 'config' . DS . 'install.php.bak', ROOT . DS . 'config' . DS . 'install.php'); + rename(ROOT . DS . 'vendor' . DS . 'autoload.php.bak', ROOT . DS . 'vendor' . DS . 'autoload.php'); } /**