diff --git a/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php index 5d016aee4e..8b4b6234ef 100644 --- a/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php @@ -13,11 +13,11 @@ use BaserCore\Test\Factory\PluginFactory; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcFile; +use BaserCore\Utility\BcFolder; use BaserCore\Utility\BcUtil; use Cake\Core\Configure; use Cake\Core\Plugin; -use Cake\Filesystem\File; -use Cake\Filesystem\Folder; use Cake\TestSuite\IntegrationTestTrait; use BaserCore\Controller\Admin\PluginsController; use Cake\Event\Event; @@ -179,13 +179,10 @@ public function testDetachAndInstallAndUninstall(): void $from = BcUtil::getPluginPath('BcBlog'); $pluginDir = dirname($from); - $folder = new Folder(); + $folder = new BcFolder($from); + $folder->create(); $to = $pluginDir . DS . 'BcBlogBak'; - $folder->copy($to, [ - 'from' => $from, - 'mode' => 0777 - ]); - $folder->create($from, 0777); + $folder->copy($from, $to); $this->post('/baser/admin/baser-core/plugins/uninstall/BcBlog', $data); $this->assertRedirect([ 'plugin' => 'BaserCore', @@ -194,11 +191,7 @@ public function testDetachAndInstallAndUninstall(): void 'action' => 'index' ]); $this->assertFlashMessage('プラグイン「BcBlog」を削除しました。'); - $folder->move($from, [ - 'from' => $to, - 'mode' => 0777, - 'schema' => Folder::OVERWRITE - ]); + $folder->move($from, $to); $this->put('/baser/admin/baser-core/plugins/install/BcBlog', $data); } @@ -212,9 +205,8 @@ public function testUpdate(): void $this->enableCsrfToken(); $path = Plugin::path('BcPluginSample'); rename($path . 'VERSION.txt', $path . 'VERSION.bak.txt'); - $file = new File($path . 'VERSION.txt'); + $file = new BcFile($path . 'VERSION.txt'); $file->write('0.0.2'); - $file->close(); PluginFactory::make(['name' => 'BcPluginSample', 'version' => '0.0.1'])->persist(); $this->put('/baser/admin/baser-core/plugins/update/BcPluginSample', [ 'connection' => 'test', @@ -244,16 +236,14 @@ public function testUpdateCore(): void copy(ROOT . DS . 'composer.lock', ROOT . DS . 'composer.lock.bak'); // replace を削除 - $file = new File(ROOT . DS . 'composer.json'); + $file = new BcFile(ROOT . DS . 'composer.json'); $data = $file->read(); $regex = '/("replace": {.+?},)/s'; $data = preg_replace($regex, '' , $data); $file->write($data); - $file->close(); - $file = new File(BASER . 'VERSION.txt'); + $file = new BcFile(BASER . 'VERSION.txt'); $file->write('5.0.0'); - $file->close(); $this->put('/baser/admin/baser-core/plugins/update', [ 'connection' => 'test', 'update' => 1, @@ -311,9 +301,9 @@ public function test_add() $path = BASER_PLUGINS . 'BcPluginSample'; $zipSrcPath = TMP . 'zip' . DS; - $folder = new Folder(); - $folder->create($zipSrcPath, 0777); - $folder->copy($zipSrcPath . 'BcPluginSample2', ['from' => $path, 'mode' => 0777]); + $folder = new BcFolder($zipSrcPath. 'BcPluginSample2'); + $folder->create(); + $folder->copy($path, $zipSrcPath . 'BcPluginSample2'); $plugin = 'BcPluginSample2'; $zip = new ZipArchiver(); $testFile = $zipSrcPath . $plugin . '.zip'; @@ -338,8 +328,9 @@ public function test_add() ]); $this->assertFlashMessage('新規プラグイン「' . $plugin . '」を追加しました。'); - $folder = new Folder(); - $folder->delete(BASER_PLUGINS . $plugin); - $folder->delete($zipSrcPath); + $folder = new BcFolder(BASER_PLUGINS . $plugin); + $folder->delete(); + $folder = new BcFolder($zipSrcPath); + $folder->delete(); } } diff --git a/plugins/baser-core/tests/TestCase/Controller/Api/Admin/PluginsControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/Api/Admin/PluginsControllerTest.php index 074da9fc08..d3b7885f4e 100644 --- a/plugins/baser-core/tests/TestCase/Controller/Api/Admin/PluginsControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/Api/Admin/PluginsControllerTest.php @@ -12,6 +12,7 @@ namespace BaserCore\Test\TestCase\Controller\Api\Admin; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcFolder; use Cake\Core\App; use Cake\Core\Configure; use Cake\Core\Configure\Engine\PhpConfig; @@ -122,13 +123,13 @@ public function testInstall($pluginName, $statusCode, $message) 'permission' => "1" ]; $pluginPath = App::path('plugins')[0] . DS . 'BcTest'; - $folder = new Folder($pluginPath); - $folder->create($pluginPath, 0777); + $folder = new BcFolder($pluginPath); + $folder->create(); $this->post('/baser/api/admin/baser-core/plugins/install/' . $pluginName .'.json?token=' . $this->accessToken, $data); $this->assertResponseCode($statusCode); $result = json_decode((string)$this->_response->getBody()); $this->assertEquals($message, $result->message); - $folder->delete($pluginPath); + $folder->delete(); } public function installDataProvider() { @@ -208,9 +209,9 @@ public function test_add() $path = BASER_PLUGINS . 'BcPluginSample'; $zipSrcPath = TMP . 'zip' . DS; - $folder = new Folder(); - $folder->create($zipSrcPath, 0777); - $folder->copy($zipSrcPath . 'BcPluginSample2', ['from' => $path, 'mode' => 0777]); + $folder = new BcFolder($zipSrcPath. 'BcPluginSample2'); + $folder->create(); + $folder->copy($path, $zipSrcPath . 'BcPluginSample2'); $plugin = 'BcPluginSample2'; $zip = new ZipArchiver(); $testFile = $zipSrcPath . $plugin . '.zip'; @@ -222,9 +223,8 @@ public function test_add() $result = json_decode((string)$this->_response->getBody()); $this->assertEquals('新規プラグイン「' . $plugin . '」を追加しました。', $result->message); - $folder = new Folder(); - $folder->delete(BASER_PLUGINS . $plugin); - $folder->delete($zipSrcPath); + $folder = new BcFolder(BASER_PLUGINS . $plugin); + $folder->delete(); } /**