diff --git a/.travis.yml b/.travis.yml index 2a79997d2f5..ec1a5a62c81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,51 +102,259 @@ jobs: - <<: *e2e_test env: GROUP=front APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 - <<: *e2e_test - env: APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 + env: APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 script: - *package_api_setup - | psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installFromLocal + ./codeception.sh EA10PluginCest:test_install_enable_disable_remove_store - | ./codeception.sh --reset psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installFromStore + ./codeception.sh EA10PluginCest:test_install_enable_disable_remove_local - | ./codeception.sh --reset psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installLocalPluginWithAssets + ./codeception.sh EA10PluginCest:test_install_enable_disable_enable_disable_remove_store - | ./codeception.sh --reset psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installStorePluginWithAssets + ./codeception.sh EA10PluginCest:test_install_enable_disable_enable_disable_remove_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_remove_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_remove_store + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_update_remove_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_update_remove_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_update_enable_disable_remove_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_update_enable_disable_remove_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_update_disable_remove_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_update_disable_remove_local + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_update_enable_disable_remove_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_update_enable_disable_remove_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_enable + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_disable_disable + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_assets_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_assets_store + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_disabled_remove_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_disabled_remove_local + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_crossed_store + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_crossed_local + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=postgres://postgres:password@localhost/eccube_db DATABASE_SERVER_VERSION=9 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_dependency_each_install_plugin + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_dependency_plugin_install + - | + ./codeception.sh --reset + psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_dependency_plugin_update - | ./codeception.sh --reset psql eccube_db -h 127.0.0.1 -U postgres -c "update dtb_base_info set authentication_key='test', php_path = '$(which php)';" - ./codeception.sh EA10PluginCest:installFromStore + ./codeception.sh EA10PluginCest:install_enable_disable_enable_disable_remove_store + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=mysql://root:@localhost/eccube_db DATABASE_SERVER_VERSION=5 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_remove_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_enable_disable_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_enable_disable_remove_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_remove_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_remove_store - <<: *e2e_test - env: APP_ENV=codeception DATABASE_URL=mysql://root:@localhost/eccube_db DATABASE_SERVER_VERSION=5 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 + env: APP_ENV=codeception DATABASE_URL=mysql://root:@localhost/eccube_db DATABASE_SERVER_VERSION=5 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 script: - *package_api_setup - | mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installFromLocal + ./codeception.sh EA10PluginCest:test_install_update_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_update_remove_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_disable_update_enable_disable_remove_local - | ./codeception.sh --reset mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installFromStore + ./codeception.sh EA10PluginCest:test_install_enable_disable_update_enable_disable_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_update_disable_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_update_disable_remove_local + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=mysql://root:@localhost/eccube_db DATABASE_SERVER_VERSION=5 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_update_enable_disable_remove_local - | ./codeception.sh --reset mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installLocalPluginWithAssets + ./codeception.sh EA10PluginCest:test_install_update_enable_disable_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_enable_enable + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_disable_disable + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_assets_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_install_assets_store + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=mysql://root:@localhost/eccube_db DATABASE_SERVER_VERSION=5 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_disabled_remove_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_disabled_remove_local + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_crossed_store + - | + ./codeception.sh --reset + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_extend_same_table_crossed_local + - <<: *e2e_test + env: APP_ENV=codeception DATABASE_URL=mysql://root:@localhost/eccube_db DATABASE_SERVER_VERSION=5 MAILER_URL=smtp://localhost:1025 ECCUBE_PACKAGE_API_URL=http://localhost:8080 NO_FIXTURES=1 + script: + - *package_api_setup + - | + mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" + ./codeception.sh EA10PluginCest:test_dependency_each_install_plugin - | ./codeception.sh --reset mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" - ./codeception.sh EA10PluginCest:installStorePluginWithAssets + ./codeception.sh EA10PluginCest:test_dependency_plugin_install +# - | +# ./codeception.sh --reset +# mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test';" +# ./codeception.sh EA10PluginCest:test_dependency_plugin_update - | ./codeception.sh --reset mysql -h 127.0.0.1 -u root eccube_db -e "update dtb_base_info set authentication_key='test', php_path = '$(which php)';" - ./codeception.sh EA10PluginCest:installFromStore + ./codeception.sh EA10PluginCest:install_enable_disable_enable_disable_remove_store # - stage: Code Coverage # if: type != pull_request diff --git a/codeception/_data/plugins/Boomerang-1.0.0.tgz b/codeception/_data/plugins/Boomerang-1.0.0.tgz new file mode 100644 index 00000000000..3cf4c13d550 Binary files /dev/null and b/codeception/_data/plugins/Boomerang-1.0.0.tgz differ diff --git a/codeception/_data/plugins/Emperor-1.0.0.tgz b/codeception/_data/plugins/Emperor-1.0.0.tgz index c7350ded360..57ef98da373 100644 Binary files a/codeception/_data/plugins/Emperor-1.0.0.tgz and b/codeception/_data/plugins/Emperor-1.0.0.tgz differ diff --git a/codeception/_data/plugins/Emperor-1.0.1.tgz b/codeception/_data/plugins/Emperor-1.0.1.tgz index 51bed3bec37..39a55a2de68 100644 Binary files a/codeception/_data/plugins/Emperor-1.0.1.tgz and b/codeception/_data/plugins/Emperor-1.0.1.tgz differ diff --git a/codeception/_data/plugins/Horizon-1.0.0.tgz b/codeception/_data/plugins/Horizon-1.0.0.tgz index 39dc2eb4f81..29275ef70a0 100644 Binary files a/codeception/_data/plugins/Horizon-1.0.0.tgz and b/codeception/_data/plugins/Horizon-1.0.0.tgz differ diff --git a/codeception/_data/plugins/Horizon-1.0.1.tgz b/codeception/_data/plugins/Horizon-1.0.1.tgz new file mode 100644 index 00000000000..0633c80942d Binary files /dev/null and b/codeception/_data/plugins/Horizon-1.0.1.tgz differ diff --git a/codeception/_support/Page/Admin/PluginManagePage.php b/codeception/_support/Page/Admin/PluginManagePage.php index b639c11b1a8..4f0e1d91e5a 100644 --- a/codeception/_support/Page/Admin/PluginManagePage.php +++ b/codeception/_support/Page/Admin/PluginManagePage.php @@ -15,7 +15,7 @@ class PluginManagePage extends AbstractAdminPageStyleGuide { - const 完了メーッセージ = '#page_admin_store_plugin > div.c-container > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span'; + const 完了メーッセージ = '#page_admin_store_plugin > div.c-container > div.c-contentsArea > div.alert.alert-dismissible.fade.show.m-3 > span'; public function __construct(\AcceptanceTester $I) { @@ -32,42 +32,44 @@ public static function at($I) /** * @param $pluginCode * + * @param string $message * @return PluginManagePage */ - public function ストアプラグイン_有効化($pluginCode) + public function ストアプラグイン_有効化($pluginCode, $message = '有効にしました。') { $this->ストアプラグイン_ボタンクリック($pluginCode, '有効化'); - $this->tester->see('有効にしました。', self::完了メーッセージ); - + $this->tester->see($message, self::完了メーッセージ); return $this; } /** * @param $pluginCode * + * @param string $message * @return PluginManagePage */ - public function ストアプラグイン_無効化($pluginCode) + public function ストアプラグイン_無効化($pluginCode, $message = '無効にしました。') { $this->ストアプラグイン_ボタンクリック($pluginCode, '無効化'); - $this->tester->see('無効にしました。', self::完了メーッセージ); - + $this->tester->see($message, self::完了メーッセージ); return $this; } /** * @param $pluginCode + * @param string $message * * @return PluginManagePage * * @throws \Exception */ - public function ストアプラグイン_削除($pluginCode) + public function ストアプラグイン_削除($pluginCode, $message = '削除が完了しました。') { $this->ストアプラグイン_ボタンクリック($pluginCode, '削除'); $this->tester->waitForElementVisible(['id' => 'officialPluginDeleteButton']); $this->tester->click(['id' => 'officialPluginDeleteButton']); $this->tester->waitForElementVisible(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)'], 30); + $this->tester->see($message, ['css' => '#officialPluginDeleteModal > div > div > div.modal-body.text-left > p']); $this->tester->click(['css' => '#officialPluginDeleteModal > div > div > div.modal-footer > button:nth-child(3)']); return $this; @@ -75,13 +77,12 @@ public function ストアプラグイン_削除($pluginCode) /** * @param $pluginCode - * * @return PluginStoreUpgradePage */ public function ストアプラグイン_アップデート($pluginCode) { + echo $this->tester->grabTextFrom(['xpath' => '//*[@id="page_admin_store_plugin"]']); $this->tester->click(['xpath' => $this->ストアプラグイン_セレクタ($pluginCode).'/../../td[5]/a']); - return PluginStoreUpgradePage::at($this->tester); } @@ -93,7 +94,7 @@ private function ストアプラグイン_ボタンクリック($pluginCode, $la return $this; } - private function ストアプラグイン_セレクタ($pluginCode) + public function ストアプラグイン_セレクタ($pluginCode) { return '//*[@id="page_admin_store_plugin"]//div/h5[contains(text(), "オーナーズストアのプラグイン")]/../..//table/tbody//td[3]/p[contains(text(), "'.$pluginCode.'")]'; } @@ -102,7 +103,6 @@ public function 独自プラグイン_有効化($pluginCode) { $this->独自プラグイン_ボタンクリック($pluginCode, '有効化'); $this->tester->see('有効にしました。', self::完了メーッセージ); - return $this; } @@ -110,7 +110,6 @@ public function 独自プラグイン_無効化($pluginCode) { $this->独自プラグイン_ボタンクリック($pluginCode, '無効化'); $this->tester->see('無効にしました。', self::完了メーッセージ); - return $this; } @@ -128,7 +127,6 @@ public function 独自プラグイン_アップデート($pluginCode, $fileName) $this->tester->attachFile(['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[5]//input[@type="file"]'], $fileName); $this->tester->click(['xpath' => $this->独自プラグイン_セレクタ($pluginCode).'/../td[5]//button']); $this->tester->see('アップデートしました。', self::完了メーッセージ); - return $this; } diff --git a/codeception/_support/Page/Admin/PluginSearchPage.php b/codeception/_support/Page/Admin/PluginSearchPage.php index 93238b6e4c5..a51ec3bc28a 100644 --- a/codeception/_support/Page/Admin/PluginSearchPage.php +++ b/codeception/_support/Page/Admin/PluginSearchPage.php @@ -34,7 +34,7 @@ public static function go($I) */ public function 入手する($pluginCode) { - $this->tester->click(['xpath' => '//*[@id="plugin-list"]//a[@data-code="'.$pluginCode.'"]/parent::node()/parent::node()/div[3]/form/a[contains(text(), "入手する")]']); + $this->tester->click(['xpath' => '//*[@id="plugin-list"]//a[@data-code="'.$pluginCode.'"]/../../div[3]/form/a[contains(text(), "入手する")]']); return PluginStoreInstallPage::at($this->tester); } diff --git a/codeception/_support/Page/Admin/PluginStoreInstallPage.php b/codeception/_support/Page/Admin/PluginStoreInstallPage.php index 3146f68f8ea..bfabd41450e 100644 --- a/codeception/_support/Page/Admin/PluginStoreInstallPage.php +++ b/codeception/_support/Page/Admin/PluginStoreInstallPage.php @@ -37,7 +37,8 @@ public function インストール() $this->tester->click(['css' => '#plugin-list > div.card-body > div:nth-child(2) > div > button.btn.btn-primary']); $this->tester->waitForElementVisible(['id' => 'installBtn']); $this->tester->click(['id' => 'installBtn']); - $this->tester->waitForElementVisible(['css' => '#installModal > div > div > div.modal-footer > a'], 30); + $this->tester->waitForElementVisible(['css' => '#installModal > div > div > div.modal-footer > a'], 60); + $this->tester->see('インストールが完了しました。', ['css' => '#installModal > div > div > div.modal-body > p']); $this->tester->click(['css' => '#installModal > div > div > div.modal-footer > a']); return PluginManagePage::at($this->tester); diff --git a/codeception/_support/Page/Admin/PluginStoreUpgradePage.php b/codeception/_support/Page/Admin/PluginStoreUpgradePage.php index 3402a3f7d87..db334d2f568 100644 --- a/codeception/_support/Page/Admin/PluginStoreUpgradePage.php +++ b/codeception/_support/Page/Admin/PluginStoreUpgradePage.php @@ -37,7 +37,8 @@ public function アップデート() $this->tester->click(['css' => '#plugin-list > div.card-body > div:nth-child(2) > div > button.btn.btn-primary']); $this->tester->waitForElementVisible(['id' => 'installBtn']); $this->tester->click(['id' => 'installBtn']); - $this->tester->waitForElementVisible(['css' => '#installModal > div > div > div.modal-footer > a'], 30); + $this->tester->waitForElementVisible(['css' => '#installModal > div > div > div.modal-footer > a'], 60); + $this->tester->see('インストールが完了しました。', ['css' => '#installModal > div > div > div.modal-body > p']); $this->tester->click(['css' => '#installModal > div > div > div.modal-footer > a']); return PluginManagePage::at($this->tester); diff --git a/codeception/acceptance/EA10PluginCest.php b/codeception/acceptance/EA10PluginCest.php index 722a659487e..cfead83e8b7 100644 --- a/codeception/acceptance/EA10PluginCest.php +++ b/codeception/acceptance/EA10PluginCest.php @@ -46,165 +46,164 @@ public function _before(\AcceptanceTester $I) FileSystem::doEmptyDir('repos'); } - public function installFromStore(\AcceptanceTester $I) + public function test_install_enable_disable_remove_store(\AcceptanceTester $I) { - $this->publishPlugin('Horizon-1.0.0.tgz'); - /* - * インストール - */ - $ManagePage = PluginSearchPage::go($I) - ->入手する('Horizon') - ->インストール(); - - $I->assertFalse($this->tableExists('dtb_dash')); - $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon')); - - $Plugin = $this->pluginRepository->findByCode('Horizon'); - $I->assertFalse($Plugin->isInitialized(), '初期化されていない'); - $I->assertFalse($Plugin->isEnabled(), '有効化されていない'); - - /* - * 有効化 - */ - $ManagePage->ストアプラグイン_有効化('Horizon'); - - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); - - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertTrue($Plugin->isEnabled(), '有効化されている'); - - /* - * 無効化 - */ - $ManagePage->ストアプラグイン_無効化('Horizon'); - - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); - - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertFalse($Plugin->isEnabled(), '無効化されている'); - - /* - * 再度有効化 - */ - $ManagePage->ストアプラグイン_有効化('Horizon'); - - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); - - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertTrue($Plugin->isEnabled(), '有効化されている'); - - /* - * 再度無効化 - */ - $ManagePage->ストアプラグイン_無効化('Horizon'); - - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); - - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertFalse($Plugin->isEnabled(), '無効化されている'); - - /* - * 削除 - */ - $ManagePage->ストアプラグイン_削除('Horizon'); - - $I->assertFalse($this->tableExists('dtb_dash')); - $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon')); - - $this->em->refresh($Plugin); - $Plugin = $this->pluginRepository->findByCode('Horizon'); - $I->assertNull($Plugin); + Horizon_Store::start($I) + ->インストール() + ->有効化() + ->無効化() + ->削除(); } - public function installFromLocal(\AcceptanceTester $I) + public function test_install_enable_disable_remove_local(\AcceptanceTester $I) { - /* - * インストール - */ - $ManagePage = PluginLocalInstallPage::go($I) - ->アップロード('plugins/Horizon-1.0.0.tgz'); - - $I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ); - - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); - - $Plugin = $this->pluginRepository->findByCode('Horizon'); - $I->assertTrue($Plugin->isInitialized(), '初期化されていない'); - $I->assertFalse($Plugin->isEnabled(), '有効化されていない'); + Horizon_Store::start($I) + ->インストール() + ->有効化() + ->無効化() + ->削除(); + } - /* - * 有効化 - */ - $ManagePage->独自プラグイン_有効化('Horizon'); + public function test_install_enable_disable_enable_disable_remove_store(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->有効化() + ->無効化() + ->有効化() + ->無効化() + ->削除(); + } - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); + public function test_install_enable_disable_enable_disable_remove_local(\AcceptanceTester $I) + { + Horizon_Local::start($I) + ->インストール() + ->有効化() + ->無効化() + ->有効化() + ->無効化() + ->削除(); + } - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertTrue($Plugin->isEnabled(), '有効化されている'); + public function test_install_remove_local(\AcceptanceTester $I) + { + Horizon_Local::start($I) + ->インストール() + ->削除(); + } - /* - * 無効化 - */ - $ManagePage->独自プラグイン_無効化('Horizon'); + public function test_install_remove_store(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->削除(); + } - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); + public function test_install_update_remove_store(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->アップデート() + ->削除(); + } - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertFalse($Plugin->isEnabled(), '無効化されている'); - /* - * 再度有効化 - */ - $ManagePage->独自プラグイン_有効化('Horizon'); - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); + public function test_install_update_remove_local(\AcceptanceTester $I) + { + Horizon_Local::start($I) + ->インストール() + ->アップデート() + ->削除(); + } - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertTrue($Plugin->isEnabled(), '有効化されている'); + public function test_install_enable_disable_update_enable_disable_remove_local(\AcceptanceTester $I) + { + Horizon_Local::start($I) + ->インストール() + ->有効化() + ->無効化() + ->アップデート() + ->有効化() + ->無効化() + ->削除(); + } - /* - * 再度無効化 - */ - $ManagePage->独自プラグイン_無効化('Horizon'); + public function test_install_enable_disable_update_enable_disable_remove_store(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->有効化() + ->無効化() + ->アップデート() + ->有効化() + ->無効化() + ->削除(); + } - $I->assertTrue($this->tableExists('dtb_dash')); - $I->assertTrue($this->columnExists('dtb_cart', 'is_horizon')); + public function test_install_enable_update_disable_remove_store(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->有効化() + ->アップデート() + ->無効化() + ->削除(); + } - $this->em->refresh($Plugin); - $I->assertTrue($Plugin->isInitialized(), '初期化されている'); - $I->assertFalse($Plugin->isEnabled(), '無効化されている'); + public function test_install_enable_update_disable_remove_local(\AcceptanceTester $I) + { + Horizon_Local::start($I) + ->インストール() + ->有効化() + ->アップデート() + ->無効化() + ->削除(); + } - /* - * 削除 - */ - $ManagePage->独自プラグイン_削除('Horizon'); + public function test_install_update_enable_disable_remove_local(\AcceptanceTester $I) + { + Horizon_Local::start($I) + ->インストール() + ->アップデート() + ->有効化() + ->無効化() + ->削除(); + } - $I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ); + public function test_install_update_enable_disable_remove_store(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->アップデート() + ->有効化() + ->無効化() + ->削除(); + } - $I->assertFalse($this->tableExists('dtb_dash')); - $I->assertFalse($this->columnExists('dtb_cart', 'is_horizon')); + public function test_install_enable_enable(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->新しいタブで開く() + ->有効化() + ->前のタブに戻る() + ->既に有効なものを有効化(); + } - $this->em->refresh($Plugin); - $Plugin = $this->pluginRepository->findByCode('Horizon'); - $I->assertNull($Plugin); + public function test_install_disable_disable(\AcceptanceTester $I) + { + Horizon_Store::start($I) + ->インストール() + ->有効化() + ->新しいタブで開く() + ->無効化() + ->前のタブに戻る() + ->既に無効なものを無効化(); } - public function installLocalPluginWithAssets(\AcceptanceTester $I) + public function test_install_assets_local(\AcceptanceTester $I) { $this->publishPlugin('Assets-1.0.0.tgz'); @@ -235,7 +234,7 @@ public function installLocalPluginWithAssets(\AcceptanceTester $I) $I->assertFileNotExists($updatedPath); } - public function installStorePluginWithAssets(\AcceptanceTester $I) + public function test_install_assets_store(\AcceptanceTester $I) { // 最初のバージョンを作成 $this->publishPlugin('Assets-1.0.0.tgz'); @@ -267,27 +266,637 @@ public function installStorePluginWithAssets(\AcceptanceTester $I) $I->assertFileExists($assetsPath); $I->assertFileExists($updatedPath); - $ManagePage->ストアプラグイン_無効化('Assets'); - $I->assertFileExists($assetsPath); - $I->assertFileExists($updatedPath); - $ManagePage->ストアプラグイン_削除('Assets'); $I->assertFileNotExists($assetsPath); $I->assertFileNotExists($updatedPath); } + public function test_extend_same_table_store(\AcceptanceTester $I) + { + $Horizon = Horizon_Store::start($I); + $Boomerang = Boomerang_Store::start($I); + + $Horizon->インストール()->有効化(); + $Boomerang->インストール()->有効化(); + + $Horizon->検証()->無効化()->削除(); + $Boomerang->検証()->無効化()->削除(); + } + + public function test_extend_same_table_disabled_remove_store(\AcceptanceTester $I) + { + $Horizon = Horizon_Store::start($I); + $Boomerang = Boomerang_Store::start($I); + + $Horizon->インストール()->有効化()->無効化(); + $Boomerang->インストール()->有効化()->無効化(); + + $Horizon->検証()->削除(); + $Boomerang->検証()->削除(); + } + + public function test_extend_same_table_local(\AcceptanceTester $I) + { + $Horizon = Horizon_Local::start($I); + $Boomerang = Boomerang_Local::start($I); + + $Horizon->インストール()->有効化(); + $Boomerang->インストール()->有効化(); + + $Horizon->検証()->無効化()->削除(); + $Boomerang->検証()->無効化()->削除(); + } + + public function test_extend_same_table_disabled_remove_local(\AcceptanceTester $I) + { + $Horizon = Horizon_Local::start($I); + $Boomerang = Boomerang_Local::start($I); + + $Horizon->インストール()->有効化()->無効化(); + $Boomerang->インストール()->有効化()->無効化(); + + $Horizon->検証()->削除(); + $Boomerang->検証()->削除(); + } + + public function test_extend_same_table_crossed_store(\AcceptanceTester $I) + { + $Horizon = Horizon_Store::start($I); + $Boomerang = Boomerang_Store::start($I); + + $Horizon->インストール()->有効化()->無効化(); + $Boomerang->インストール()->有効化(); + + $Horizon->検証()->削除(); + $Boomerang->検証()->無効化()->削除(); + } + + public function test_extend_same_table_crossed_local(\AcceptanceTester $I) + { + $Horizon = Horizon_Local::start($I); + $Boomerang = Boomerang_Local::start($I); + + $Horizon->インストール()->有効化()->無効化(); + $Boomerang->インストール()->有効化(); + + $Horizon->検証()->削除(); + $Boomerang->検証()->無効化()->削除(); + } + + public function test_dependency_each_install_plugin(\AcceptanceTester $I) + { + $Horizon = Horizon_Store::start($I); + $Emperor = Emperor_Store::start($I); + + $Horizon->インストール()->有効化(); + $Emperor->インストール()->有効化(); + } + + public function test_dependency_plugin_install(\AcceptanceTester $I) + { + $Horizon = Horizon_Store::start($I); + $Emperor = Emperor_Store::start($I, $Horizon); + + $Emperor->インストール() + ->依存より先に有効化(); + + $Horizon->有効化(); + + $Emperor->有効化(); + + $Horizon->依存されているのが有効なのに無効化(); + $Emperor->無効化(); + $Horizon->無効化(); + + $Horizon->依存されているのが削除されていないのに削除(); + $Emperor->削除(); + $Horizon->削除(); + } + + public function test_dependency_plugin_update(\AcceptanceTester $I) + { + $Horizon = Horizon_Store::start($I); + $Emperor = Emperor_Store::start($I, $Horizon); + + $Emperor->インストール(); + + $Horizon->検証() + ->有効化(); + + $Emperor + ->有効化() + ->無効化() + ->アップデート(); + + $Horizon->検証(); + } + private function publishPlugin($fileName) { copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName); } +} + +abstract class Abstract_Plugin +{ + /** @var AcceptanceTester */ + protected $I; + + /** @var EntityManager */ + protected $em; + + /** @var \Doctrine\DBAL\Connection */ + protected $conn; + + /** @var PluginRepository */ + protected $pluginRepository; + + /** @var EccubeConfig */ + protected $config; + + protected $initialized = false; + + protected $enabled = false; + + protected $removed = false; + + protected $tables = []; + + protected $columns = []; + + protected $traits = []; + + public function __construct(\AcceptanceTester $I) + { + $this->I = $I; + $this->em = Fixtures::get('entityManager'); + $this->conn = $this->em->getConnection(); + $this->pluginRepository = $this->em->getRepository(Plugin::class); + $this->config = Fixtures::get('config'); + } + + public function tableExists() + { + foreach ($this->tables as $table) { + $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0; + $this->I->assertTrue($exists, 'テーブルがあるはず '.$table); + } + } - private function tableExists($tableName) + public function tableNotExists() { - return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}';")->fetch()['count'] > 0; + foreach ($this->tables as $table) { + $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '".$table."';")->fetch()['count'] > 0; + $this->I->assertFalse($exists, 'テーブルがないはず '.$table); + } } - private function columnExists($tableName, $columnName) + public function columnExists() { - return $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; + foreach ($this->columns as $column) { + list($tableName, $columnName) = explode('.', $column); + $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; + $this->I->assertTrue($exists, 'カラムがあるはず '.$column); + } } + + public function columnNotExists() + { + foreach ($this->columns as $column) { + list($tableName, $columnName) = explode('.', $column); + $exists = $this->conn->executeQuery("SELECT count(*) AS count FROM information_schema.columns WHERE table_name = '${tableName}' AND column_name = '${columnName}';")->fetch()['count'] == 1; + $this->I->assertFalse($exists, 'カラムがないはず '.$column); + } + } + + public function traitExists() + { + foreach ($this->traits as $trait => $target) { + $this->I->assertContains($trait, file_get_contents($this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'), 'Traitがあるはず '.$trait); + } + } + + public function traitNotExists() + { + foreach ($this->traits as $trait => $target) { + $file = $this->config['kernel.project_dir'].'/app/proxy/entity/'.$target.'.php'; + if (file_exists($file)) { + $this->I->assertNotContains($trait, file_get_contents($file), 'Traitがないはず '.$trait); + } else { + $this->I->assertTrue(true, 'Traitがないはず'); + } + } + } + + public function 新しいタブで開く() + { + $this->I->executeJS("window.open(location.href, 'other')"); + $this->I->switchToWindow('other'); + return $this; + } + + public function 前のタブに戻る() + { + $this->I->switchToPreviousTab(); + return $this; + } + + public function 検証() + { + if ($this->initialized) { + $this->tableExists(); + $this->columnExists(); + } else { + $this->tableNotExists(); + $this->columnNotExists(); + } + + if ($this->enabled) { + $this->traitExists(); + } else { + $this->traitNotExists(); + } + + return $this; + } +} + +class Store_Plugin extends Abstract_Plugin +{ + /** @var PluginManagePage */ + protected $ManagePage; + + /** @var Plugin */ + protected $Plugin; + + protected $code; + + /** @var Store_Plugin */ + protected $dependency; + + public function __construct(AcceptanceTester $I, $code, Store_Plugin $dependency = null) + { + parent::__construct($I); + $this->code = $code; + $this->publishPlugin($this->code.'-1.0.0.tgz'); + if ($dependency) { + $this->dependency = $dependency; + $this->ManagePage = $dependency->ManagePage; + $this->Plugin = $this->pluginRepository->findByCode($code); + } + } + + public function インストール() + { + /* + * インストール + */ + $this->ManagePage = PluginSearchPage::go($this->I) + ->入手する($this->code) + ->インストール(); + + $this->検証(); + + $this->Plugin = $this->pluginRepository->findByCode($this->code); + $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていない'); + $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない'); + + if ($this->dependency) { + $this->dependency->ManagePage = $this->ManagePage; + $this->dependency->Plugin = $this->pluginRepository->findByCode($this->dependency->code); + } + + return $this; + } + + public function 有効化() + { + $this->ManagePage->ストアプラグイン_有効化($this->code); + + $this->initialized = true; + $this->enabled = true; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている'); + + return $this; + } + + public function 既に有効なものを有効化() + { + $this->ManagePage->ストアプラグイン_有効化($this->code, '既に有効です。'); + + $this->initialized = true; + $this->enabled = true; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている'); + + + return $this; + } + + public function 無効化() + { + $this->ManagePage->ストアプラグイン_無効化($this->code); + + $this->enabled = false; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている'); + + return $this; + } + + public function 既に無効なものを無効化() + { + $this->ManagePage->ストアプラグイン_無効化($this->code, '既に無効です。'); + + $this->enabled = false; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている'); + + return $this; + } + + public function 削除() + { + $this->ManagePage->ストアプラグイン_削除($this->code); + + $this->initialized = false; + $this->enabled = false; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->Plugin = $this->pluginRepository->findByCode($this->code); + $this->I->assertNull($this->Plugin, '削除されている'); + + return $this; + } + + public function アップデート() + { + $this->publishPlugin($this->code.'-1.0.1.tgz'); + + $this->I->reloadPage(); + $this->ManagePage->ストアプラグイン_アップデート($this->code)->アップデート(); + + $this->initialized = true; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertEquals($this->initialized, $this->Plugin->isInitialized(), '初期化'); + $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効'); + + return $this; + } + + protected function publishPlugin($fileName) + { + $published = copy(codecept_data_dir().'/'.'plugins/'.$fileName, codecept_root_dir().'/repos/'.$fileName); + $this->I->assertTrue($published, "公開できた ${fileName}"); + } +} + +class Local_Plugin extends Abstract_Plugin +{ + /** @var PluginManagePage */ + private $ManagePage; + + /** @var Plugin */ + private $Plugin; + + /** @var string */ + private $code; + + public function __construct(AcceptanceTester $I, $code) + { + parent::__construct($I); + $this->code = $code; + } + + public function インストール() + { + $this->ManagePage = PluginLocalInstallPage::go($this->I) + ->アップロード('plugins/'.$this->code.'-1.0.0.tgz'); + + $this->initialized = true; + + $this->I->see('プラグインをインストールしました。', PluginManagePage::完了メーッセージ); + + $this->検証(); + + $this->Plugin = $this->pluginRepository->findByCode($this->code); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されていない'); + $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていない'); + + return $this; + } + + public function 有効化() + { + $this->ManagePage->独自プラグイン_有効化($this->code); + + $this->enabled = true; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されている'); + return $this; + } + + public function 無効化() + { + $this->ManagePage->独自プラグイン_無効化($this->code); + + $this->enabled = false; + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertFalse($this->Plugin->isEnabled(), '無効化されている'); + + return $this; + } + + public function 削除() + { + $this->ManagePage->独自プラグイン_削除($this->code); + + $this->initialized = false; + $this->enabled = false; + + $this->I->see('プラグインを削除しました。', PluginManagePage::完了メーッセージ); + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->Plugin = $this->pluginRepository->findByCode($this->code); + $this->I->assertNull($this->Plugin, '削除されている'); + + return $this; + } + + public function アップデート() + { + $this->ManagePage->独自プラグイン_アップデート($this->code, 'plugins/'.$this->code.'-1.0.1.tgz'); + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されている'); + $this->I->assertEquals($this->enabled, $this->Plugin->isEnabled(), '有効/無効'); + + return $this; + } +} + +class Horizon_Local extends Local_Plugin +{ + public function __construct(AcceptanceTester $I) + { + parent::__construct($I, 'Horizon'); + $this->tables[] = 'dtb_dash'; + $this->columns[] = 'dtb_cart.is_horizon'; + $this->columns[] = 'dtb_cart.dash_id'; + $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'Cart'; + } + + public static function start(AcceptanceTester $I) + { + return new self($I); + } +} + +class Horizon_Store extends Store_Plugin +{ + public function __construct(AcceptanceTester $I) + { + parent::__construct($I, 'Horizon'); + $this->tables[] = 'dtb_dash'; + $this->columns[] = 'dtb_cart.is_horizon'; + $this->columns[] = 'dtb_cart.dash_id'; + $this->traits['\Plugin\Horizon\Entity\CartTrait'] = 'Cart'; + } + + public static function start(AcceptanceTester $I) + { + $result = new self($I); + return $result; + } + + public function 依存されているのが有効なのに無効化() + { + $this->ManagePage->ストアプラグイン_無効化($this->code, '「ホライゾン」を無効にする前に、「エンペラー」を無効にしてください。'); + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertTrue($this->Plugin->isInitialized(), '初期化されているはず'); + $this->I->assertTrue($this->Plugin->isEnabled(), '有効化されているはず'); + return $this; + } + + public function 依存されているのが削除されていないのに削除() + { + $this->ManagePage->ストアプラグイン_削除($this->code, '「エンペラー」が「ホライゾン」に依存しているため削除できません。'); + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->Plugin = $this->pluginRepository->findByCode($this->code); + $this->I->assertNotNull($this->Plugin, '削除されていない'); + + return $this; + } + } + +class Emperor_Store extends Store_Plugin +{ + public function __construct(AcceptanceTester $I, Store_Plugin $dependency = null) + { + parent::__construct($I, 'Emperor', $dependency); + $this->publishPlugin('Horizon-1.0.0.tgz'); + $this->tables[] = 'dtb_foo'; + $this->columns[] = 'dtb_cart.foo_id'; + $this->traits['\Plugin\Emperor\Entity\CartTrait'] = 'Cart'; + } + + public static function start(AcceptanceTester $I, Store_Plugin $dependency = null) + { + return new self($I, $dependency); + } + + public function アップデート() + { + $this->tables = ['dtb_bar']; + $this->columns = ['dtb_cart.bar_id']; + $this->traits['\Plugin\Emperor\Entity\Cart2Trait'] = 'Cart'; + return parent::アップデート(); + } + + + public function 依存より先に有効化() + { + $this->ManagePage->ストアプラグイン_有効化($this->code, '「ホライゾン」を先に有効化してください。'); + + $this->検証(); + + $this->em->refresh($this->Plugin); + $this->I->assertFalse($this->Plugin->isInitialized(), '初期化されていないはず'); + $this->I->assertFalse($this->Plugin->isEnabled(), '有効化されていないはず'); + return $this; + } +} + +class Boomerang_Store extends Store_Plugin +{ + public function __construct(AcceptanceTester $I) + { + parent::__construct($I, 'Boomerang'); + $this->tables[] = 'dtb_bar'; + $this->columns[] = 'dtb_cart.is_boomerang'; + $this->columns[] = 'dtb_cart.bar_id'; + $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'Cart'; + } + + public static function start(AcceptanceTester $I) + { + return new self($I); + } +} + +class Boomerang_Local extends Local_Plugin +{ + public function __construct(AcceptanceTester $I) + { + parent::__construct($I, 'Boomerang'); + $this->tables[] = 'dtb_bar'; + $this->columns[] = 'dtb_cart.is_boomerang'; + $this->traits['\Plugin\Boomerang\Entity\CartTrait'] = 'Cart'; + } + + public static function start(AcceptanceTester $I) + { + return new self($I); + } +} \ No newline at end of file diff --git a/codeception/acceptance/_bootstrap.php b/codeception/acceptance/_bootstrap.php index f27b9b65d2d..711b7552d9f 100644 --- a/codeception/acceptance/_bootstrap.php +++ b/codeception/acceptance/_bootstrap.php @@ -61,81 +61,87 @@ }; })(); -$num = $entityManager->getRepository('Eccube\Entity\Customer') - ->createQueryBuilder('o') - ->select('count(o.id)') - ->getQuery() - ->getSingleScalarResult(); -if ($num < $config['fixture_customer_num']) { - $num = $config['fixture_customer_num'] - $num; - for ($i = 0; $i < $num; $i++) { - $email = microtime(true).'.'.$faker->safeEmail; + +if (!getenv('NO_FIXTURES')) { + + $num = $entityManager->getRepository('Eccube\Entity\Customer') + ->createQueryBuilder('o') + ->select('count(o.id)') + ->getQuery() + ->getSingleScalarResult(); + + if ($num < $config['fixture_customer_num']) { + $num = $config['fixture_customer_num'] - $num; + for ($i = 0; $i < $num; $i++) { + $email = microtime(true).'.'.$faker->safeEmail; + $progress('Generating Customers'); + $customer = createCustomer($container, $email); + } $progress('Generating Customers'); - $customer = createCustomer($container, $email); + createCustomer($container, null, false); // non-active member } - $progress('Generating Customers'); - createCustomer($container, null, false); // non-active member -} -$num = $entityManager->getRepository('Eccube\Entity\Product') - ->createQueryBuilder('o') - ->select('count(o.id)') - ->getQuery() - ->getSingleScalarResult(); -// 受注生成件数 + 初期データの商品が生成されているはず -if ($num < ($config['fixture_product_num'] + 2)) { - // 規格なしも含め $config['fixture_product_num'] の分だけ生成する - for ($i = 0; $i < $config['fixture_product_num'] - 1; $i++) { + $num = $entityManager->getRepository('Eccube\Entity\Product') + ->createQueryBuilder('o') + ->select('count(o.id)') + ->getQuery() + ->getSingleScalarResult(); + // 受注生成件数 + 初期データの商品が生成されているはず + if ($num < ($config['fixture_product_num'] + 2)) { + // 規格なしも含め $config['fixture_product_num'] の分だけ生成する + for ($i = 0; $i < $config['fixture_product_num'] - 1; $i++) { + $progress('Generating Products'); + createProduct($container); + } $progress('Generating Products'); - createProduct($container); + createProduct($container, '規格なし商品', 0); } - $progress('Generating Products'); - createProduct($container, '規格なし商品', 0); -} -$Customers = $entityManager->getRepository('Eccube\Entity\Customer')->findAll(); -$Products = $entityManager->getRepository('Eccube\Entity\Product')->findAll(); -$Deliveries = $entityManager->getRepository('Eccube\Entity\Delivery')->findAll(); + $Customers = $entityManager->getRepository('Eccube\Entity\Customer')->findAll(); + $Products = $entityManager->getRepository('Eccube\Entity\Product')->findAll(); + $Deliveries = $entityManager->getRepository('Eccube\Entity\Delivery')->findAll(); -$allOrderCount = $entityManager->getRepository('Eccube\Entity\Order') - ->createQueryBuilder('o') - ->select('count(o.id)') - ->getQuery() - ->getSingleScalarResult(); - -if ($allOrderCount < $config['fixture_order_num']) { - foreach ($Customers as $Customer) { - $Delivery = $Deliveries[$faker->numberBetween(0, count($Deliveries) - 1)]; - $Product = $Products[$faker->numberBetween(0, count($Products) - 1)]; - $charge = $faker->randomNumber(4); - $discount = $faker->numberBetween(0, $charge); - - $orderCountPerCustomer = $entityManager->getRepository('Eccube\Entity\Order') - ->createQueryBuilder('o') - ->select('count(o.id)') - ->where('o.Customer = :Customer') - ->setParameter('Customer', $Customer) - ->getQuery() - ->getSingleScalarResult(); - $randomOrderStatus = [ - OrderStatus::NEW, - OrderStatus::CANCEL, - OrderStatus::IN_PROGRESS, - OrderStatus::DELIVERED, - OrderStatus::PAID, - OrderStatus::PENDING, - OrderStatus::PROCESSING, - OrderStatus::RETURNED, - ]; - for ($i = $orderCountPerCustomer; $i < $config['fixture_order_num'] / count($Customers); $i++) { - $Status = $entityManager->getRepository('Eccube\Entity\Master\OrderStatus')->find($faker->randomElement($randomOrderStatus)); - $OrderDate = $faker->dateTimeThisYear(); - $progress('Generating Orders'); - createOrder($container, $Customer, $Product->getProductClasses()->toArray(), $Delivery, $charge, $discount, $Status, $OrderDate); + $allOrderCount = $entityManager->getRepository('Eccube\Entity\Order') + ->createQueryBuilder('o') + ->select('count(o.id)') + ->getQuery() + ->getSingleScalarResult(); + + if ($allOrderCount < $config['fixture_order_num']) { + foreach ($Customers as $Customer) { + $Delivery = $Deliveries[$faker->numberBetween(0, count($Deliveries) - 1)]; + $Product = $Products[$faker->numberBetween(0, count($Products) - 1)]; + $charge = $faker->randomNumber(4); + $discount = $faker->numberBetween(0, $charge); + + $orderCountPerCustomer = $entityManager->getRepository('Eccube\Entity\Order') + ->createQueryBuilder('o') + ->select('count(o.id)') + ->where('o.Customer = :Customer') + ->setParameter('Customer', $Customer) + ->getQuery() + ->getSingleScalarResult(); + $randomOrderStatus = [ + OrderStatus::NEW, + OrderStatus::CANCEL, + OrderStatus::IN_PROGRESS, + OrderStatus::DELIVERED, + OrderStatus::PAID, + OrderStatus::PENDING, + OrderStatus::PROCESSING, + OrderStatus::RETURNED, + ]; + for ($i = $orderCountPerCustomer; $i < $config['fixture_order_num'] / count($Customers); $i++) { + $Status = $entityManager->getRepository('Eccube\Entity\Master\OrderStatus')->find($faker->randomElement($randomOrderStatus)); + $OrderDate = $faker->dateTimeThisYear(); + $progress('Generating Orders'); + createOrder($container, $Customer, $Product->getProductClasses()->toArray(), $Delivery, $charge, $discount, $Status, $OrderDate); + } } } } + function createCustomer($container, $email = null, $active = true) { $entityManager = $container->get('doctrine')->getManager(); diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index 42c1a8c9902..eacc2838eea 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -26,6 +26,7 @@ use Eccube\Service\PluginApiService; use Eccube\Service\PluginService; use Eccube\Service\SystemService; +use Eccube\Util\CacheUtil; use Eccube\Util\FormUtil; use Knp\Component\Pager\Paginator; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; @@ -68,6 +69,9 @@ class OwnerStoreController extends AbstractController /** @var BaseInfo */ private $BaseInfo; + /** @var CacheUtil */ + private $cacheUtil; + /** * OwnerStoreController constructor. * @@ -78,6 +82,7 @@ class OwnerStoreController extends AbstractController * @param SystemService $systemService * @param PluginApiService $pluginApiService * @param BaseInfoRepository $baseInfoRepository + * @param CacheUtil $cacheUtil * * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException @@ -89,13 +94,15 @@ public function __construct( ComposerServiceInterface $composerService, SystemService $systemService, PluginApiService $pluginApiService, - BaseInfoRepository $baseInfoRepository + BaseInfoRepository $baseInfoRepository, + CacheUtil $cacheUtil ) { $this->pluginRepository = $pluginRepository; $this->pluginService = $pluginService; $this->systemService = $systemService; $this->pluginApiService = $pluginApiService; $this->BaseInfo = $baseInfoRepository->get(); + $this->cacheUtil = $cacheUtil; // TODO: Check the flow of the composer service below $memoryLimit = $this->systemService->getMemoryLimit(); @@ -235,7 +242,7 @@ public function doConfirm(Request $request, $id) return [ 'item' => $item, 'requires' => $requires, - 'is_update' => $request->get('is_update', false), + 'is_update' => false, ]; } catch (PluginApiException $e) { $this->addError($e->getMessage(), 'admin'); @@ -257,6 +264,8 @@ public function apiInstall(Request $request) { $this->isTokenValid(); + $this->cacheUtil->clearCache(); + $pluginCode = $request->get('pluginCode'); $log = null; @@ -285,6 +294,8 @@ public function apiUninstall(Plugin $Plugin) { $this->isTokenValid(); + $this->cacheUtil->clearCache(); + if ($Plugin->isEnabled()) { return $this->json(['success' => false, 'message' => trans('admin.plugin.uninstall.error.not_disable')], 400); } @@ -305,6 +316,7 @@ public function apiUninstall(Plugin $Plugin) $pluginCode = $Plugin->getCode(); $packageName = self::$vendorName.'/'.$pluginCode; + try { $log = $this->composerService->execRemove($packageName); @@ -329,13 +341,14 @@ public function apiUpgrade(Request $request) { $this->isTokenValid(); + $this->cacheUtil->clearCache(); + $pluginCode = $request->get('pluginCode'); $version = $request->get('version'); $log = null; try { $log = $this->composerService->execRequire('ec-cube/'.$pluginCode.':'.$version); - return $this->json(['success' => true, 'log' => $log]); } catch (\Exception $e) { $log = $e->getMessage(); @@ -358,6 +371,8 @@ public function apiSchemaUpdate(Request $request) { $this->isTokenValid(); + $this->cacheUtil->clearCache(); + $pluginCode = $request->get('pluginCode'); try { @@ -371,6 +386,15 @@ public function apiSchemaUpdate(Request $request) ob_start(); $this->pluginService->generateProxyAndUpdateSchema($Plugin, $config); + + // 初期化されていなければインストール処理を実行する + if (!$Plugin->isInitialized()) { + $this->pluginService->callPluginManagerMethod($config, 'install'); + $Plugin->setInitialized(true); + $this->entityManager->persist($Plugin); + $this->entityManager->flush(); + } + $log = ob_get_clean(); ob_end_flush(); @@ -396,6 +420,8 @@ public function apiUpdate(Request $request) { $this->isTokenValid(); + $this->cacheUtil->clearCache(); + $pluginCode = $request->get('pluginCode'); $log = null; diff --git a/src/Eccube/Controller/Admin/Store/PluginController.php b/src/Eccube/Controller/Admin/Store/PluginController.php index 3393386cb4a..400a61b4efa 100644 --- a/src/Eccube/Controller/Admin/Store/PluginController.php +++ b/src/Eccube/Controller/Admin/Store/PluginController.php @@ -258,13 +258,16 @@ public function enable(Plugin $Plugin, CacheUtil $cacheUtil, Request $request) { $this->isTokenValid(); + $cacheUtil->clearCache(); + $log = null; if ($Plugin->isEnabled()) { if ($request->isXmlHttpRequest()) { return $this->json(['success' => true]); } else { - $this->addError('admin.plugin.already.enable', 'admin'); + $this->addError(trans('admin.store.plugin.already.enabled', ['%plugin_name%' => $Plugin->getName()]), 'admin'); + return $this->redirectToRoute('admin_store_plugin'); } } else { // ストアからインストールしたプラグインは依存プラグインが有効化されているかを確認 @@ -293,18 +296,20 @@ public function enable(Plugin $Plugin, CacheUtil $cacheUtil, Request $request) } } - ob_start(); - if (!$Plugin->isInitialized()) { - $this->pluginService->installWithCode($Plugin->getCode()); - } + try { + ob_start(); - $this->pluginService->enable($Plugin); - $log = ob_get_clean(); - ob_end_flush(); - } + if (!$Plugin->isInitialized()) { + $this->pluginService->installWithCode($Plugin->getCode()); + } - $cacheUtil->clearCache(); + $this->pluginService->enable($Plugin); + } finally { + $log = ob_get_clean(); + ob_end_flush(); + } + } if ($request->isXmlHttpRequest()) { return $this->json(['success' => true, 'log' => $log]); @@ -330,6 +335,8 @@ public function disable(Request $request, Plugin $Plugin, CacheUtil $cacheUtil) { $this->isTokenValid(); + $cacheUtil->clearCache(); + $log = null; if ($Plugin->isEnabled()) { $dependents = $this->pluginService->findDependentPluginNeedDisable($Plugin->getCode()); @@ -350,22 +357,23 @@ public function disable(Request $request, Plugin $Plugin, CacheUtil $cacheUtil) } } - ob_start(); - $this->pluginService->disable($Plugin); - $log = ob_get_clean(); - ob_end_flush(); + try { + ob_start(); + $this->pluginService->disable($Plugin); + } finally { + $log = ob_get_clean(); + ob_end_flush(); + } } else { if ($request->isXmlHttpRequest()) { return $this->json(['success' => true, 'log' => $log]); } else { - $this->addError('admin.plugin.already.disable', 'admin'); + $this->addError(trans('admin.store.plugin.already.disabled', ['%plugin_name%' => $Plugin->getName()]), 'admin'); return $this->redirectToRoute('admin_store_plugin'); } } - $cacheUtil->clearCache(); - if ($request->isXmlHttpRequest()) { return $this->json(['success' => true, 'log' => $log]); } else { @@ -489,8 +497,9 @@ public function install(Request $request) * * @return array */ - public function authenticationSetting(Request $request) + public function authenticationSetting(Request $request, CacheUtil $cacheUtil) { + $builder = $this->formFactory ->createBuilder(AuthenticationType::class, $this->BaseInfo); @@ -505,8 +514,10 @@ public function authenticationSetting(Request $request) // composerの認証を更新 $this->composerService->configureRepository($this->BaseInfo); - $this->addSuccess('admin.common.save_complete', 'admin'); + $cacheUtil->clearCache(); + + return $this->redirectToRoute('admin_store_authentication_setting'); } return [ diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index cc11ea6b2fc..ac5fed7554a 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -1252,7 +1252,9 @@ admin.store.plugin.update: アップデート admin.store.plugin.install.complete: プラグインをインストールしました。 admin.store.plugin.install.failed: プラグインのインストールに失敗しました。 admin.store.plugin.enable.complete: 「%plugin_name%」を有効にしました。 +admin.store.plugin.already.enabled: 「%plugin_name%」は既に有効です。 admin.store.plugin.disable.complete: 「%plugin_name%」を無効にしました。 +admin.store.plugin.already.disabled: 「%plugin_name%」は既に無効です。 admin.store.plugin.uninstall.complete: プラグインを削除しました。 admin.store.plugin.update.complete: 「%plugin_name%」をアップデートしました。 admin.store.plugin.update.failed: 「%plugin_name%」のアップデートに失敗しました。 diff --git a/src/Eccube/Resource/template/admin/Store/authentication_setting.twig b/src/Eccube/Resource/template/admin/Store/authentication_setting.twig index b4605bc2400..a3435993177 100644 --- a/src/Eccube/Resource/template/admin/Store/authentication_setting.twig +++ b/src/Eccube/Resource/template/admin/Store/authentication_setting.twig @@ -34,6 +34,10 @@ file that was distributed with this source code. $('#captcha_image').attr('src', "{{ eccube_config.eccube_package_api_url }}/captcha" + '?' + new Date().getTime()) } + $('#captcha').on('show.bs.modal', function() { + refreshCaptchaImage(); + }); + $('#generate_key').on('click', function() { $.ajax({ type: 'POST', @@ -98,25 +102,6 @@ file that was distributed with this source code. -
-
-
{{'admin.store.setting.php_path_setting'|trans}}
-
-
-
-
-
- {{ form.php_path.vars.label|trans }} - -
-
-
- {{ form_widget(form.php_path) }} -
-
-
-
- @@ -152,7 +137,8 @@ file that was distributed with this source code.
- {{ 'admin.store.plugin_owners_search.modal.contact'|trans }} + {% if item.contact_url %} + {{ 'admin.store.plugin_owners_search.modal.contact'|trans }}{ }} + {% endif %} + {% if item.manual_url %} {{ 'admin.store.plugin_owners_search.modal.manual'|trans }} + {% endif %}
diff --git a/src/Eccube/Resource/template/admin/Store/plugin_table_official.twig b/src/Eccube/Resource/template/admin/Store/plugin_table_official.twig index 205cbe4d7a5..e0c99729b48 100644 --- a/src/Eccube/Resource/template/admin/Store/plugin_table_official.twig +++ b/src/Eccube/Resource/template/admin/Store/plugin_table_official.twig @@ -20,11 +20,7 @@ $(function() { var footer = $('div.modal-footer', modal).hide(); var message = $('div.modal-body p', modal).text('「' + currentPlugin.name + ' (' + currentPlugin.version + ')」を削除中。この処理には数分かかる場合があります。画面をリロードせずにこのままお待ち下さい。') var progress = $('div.progress', modal).show(); - var url = '{{ url('admin_store_plugin_api_uninstall', {id:0}) }}'.replace( - /(.*\/)(0)(\/.*)/, - function(all, pre, id, rest) { return pre + currentPlugin.id + rest } - ); - $.ajax({url: url, type: 'delete'}).then( + $.ajax({url: currentPlugin['deleteUrl'], type: 'delete'}).then( function(data) { message.text('削除が完了しました。'); $('#deleteLog').text(data.log); @@ -115,6 +111,7 @@ $(function() { data-toggle="modal" data-target="#officialPluginDeleteModal" data-id="{{ Plugin.id }}" + data-delete-url="{{ url('admin_store_plugin_api_uninstall', { id: Plugin.id }) }}" data-name="{{ Plugin.name }}" data-version="{{ Plugin.version }}" class="btn btn-ec-actionIcon"> diff --git a/src/Eccube/Service/PluginService.php b/src/Eccube/Service/PluginService.php index 27b2727d56e..5f4d7c8daee 100644 --- a/src/Eccube/Service/PluginService.php +++ b/src/Eccube/Service/PluginService.php @@ -272,7 +272,7 @@ public function postInstall($config, $source) } } - public function generateProxyAndUpdateSchema(Plugin $plugin, $config) + public function generateProxyAndUpdateSchema(Plugin $plugin, $config, $uninstall = false) { if ($plugin->isEnabled()) { $generatedFiles = $this->regenerateProxy($plugin, false); @@ -284,19 +284,21 @@ public function generateProxyAndUpdateSchema(Plugin $plugin, $config) @mkdir($tmpProxyOutputDir); try { - // プラグインmetadata定義を追加 - $entityDir = $this->eccubeConfig['plugin_realdir'].'/'.$plugin->getCode().'/Entity'; - if (file_exists($entityDir)) { - $ormConfig = $this->entityManager->getConfiguration(); - $chain = $ormConfig->getMetadataDriverImpl(); - $driver = $ormConfig->newDefaultAnnotationDriver([$entityDir], false); - $namespace = 'Plugin\\'.$config['code'].'\\Entity'; - $chain->addDriver($driver, $namespace); - $ormConfig->addEntityNamespace($plugin->getCode(), $namespace); + if (!$uninstall) { + // プラグインmetadata定義を追加 + $entityDir = $this->eccubeConfig['plugin_realdir'].'/'.$plugin->getCode().'/Entity'; + if (file_exists($entityDir)) { + $ormConfig = $this->entityManager->getConfiguration(); + $chain = $ormConfig->getMetadataDriverImpl(); + $driver = $ormConfig->newDefaultAnnotationDriver([$entityDir], false); + $namespace = 'Plugin\\'.$config['code'].'\\Entity'; + $chain->addDriver($driver, $namespace); + $ormConfig->addEntityNamespace($plugin->getCode(), $namespace); + } } // 一時的に利用するProxyを生成してからスキーマを更新する - $generatedFiles = $this->regenerateProxy($plugin, true, $tmpProxyOutputDir); + $generatedFiles = $this->regenerateProxy($plugin, true, $tmpProxyOutputDir, $uninstall); $this->schemaService->updateSchema($generatedFiles, $tmpProxyOutputDir); } finally { foreach (glob("${tmpProxyOutputDir}/*") as $f) { @@ -529,12 +531,15 @@ public function uninstall(Plugin $plugin, $force = true) if ($plugin->isEnabled()) { $this->disable($plugin); } - $this->callPluginManagerMethod($config, 'uninstall'); + + // 初期化されていない場合はPluginManager#uninstall()は実行しない + if ($plugin->isInitialized()) { + $this->callPluginManagerMethod($config, 'uninstall'); + } $this->unregisterPlugin($plugin); // スキーマを更新する - //FIXME: Update schema before no affect - $this->schemaService->updateSchema([], $this->projectRoot.'/app/proxy/entity'); + $this->generateProxyAndUpdateSchema($plugin, $config, true); // プラグインのネームスペースに含まれるEntityのテーブルを削除する $namespace = 'Plugin\\'.$plugin->getCode().'\\Entity'; @@ -572,10 +577,11 @@ public function disable(Plugin $plugin) * @param Plugin $plugin プラグイン * @param boolean $temporary プラグインが無効状態でも一時的に生成するかどうか * @param string|null $outputDir 出力先 + * @param bool $uninstall プラグイン削除の場合はtrue * * @return array 生成されたファイルのパス */ - private function regenerateProxy(Plugin $plugin, $temporary, $outputDir = null) + private function regenerateProxy(Plugin $plugin, $temporary, $outputDir = null, $uninstall = false) { if (is_null($outputDir)) { $outputDir = $this->projectRoot.'/app/proxy/entity'; @@ -584,15 +590,15 @@ private function regenerateProxy(Plugin $plugin, $temporary, $outputDir = null) $enabledPluginCodes = array_map( function ($p) { return $p->getCode(); }, - $this->pluginRepository->findAllEnabled() + $temporary ? $this->pluginRepository->findAll() : $this->pluginRepository->findAllEnabled() ); $excludes = []; - if ($temporary || $plugin->isEnabled()) { + if (!$uninstall && ($temporary || $plugin->isEnabled())) { $enabledPluginCodes[] = $plugin->getCode(); } else { $index = array_search($plugin->getCode(), $enabledPluginCodes); - if ($index >= 0) { + if ($index !== false && $index >= 0) { array_splice($enabledPluginCodes, $index, 1); $excludes = [$this->projectRoot.'/app/Plugin/'.$plugin->getCode().'/Entity']; } @@ -712,7 +718,10 @@ public function updatePlugin(Plugin $plugin, $meta) ->setName($meta['name']); $em->persist($plugin); - $this->callPluginManagerMethod($meta, 'update'); + + if ($plugin->isInitialized()) { + $this->callPluginManagerMethod($meta, 'update'); + } $this->copyAssets($plugin->getCode()); $em->flush(); $em->getConnection()->commit(); diff --git a/src/Eccube/Util/CacheUtil.php b/src/Eccube/Util/CacheUtil.php index 386f86e1674..b44cbd293fa 100644 --- a/src/Eccube/Util/CacheUtil.php +++ b/src/Eccube/Util/CacheUtil.php @@ -82,6 +82,19 @@ public function forceClearCache(PostResponseEvent $event) $console->run($input, $output); + if (function_exists('opcache_reset')) { + opcache_reset(); + } + + if (function_exists('apc_clear_cache')) { + apc_clear_cache('user'); + apc_clear_cache(); + } + + if (function_exists('wincache_ucache_clear')) { + wincache_ucache_clear(); + } + return $output->fetch(); } diff --git a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php index 2209470308d..eed36decce0 100644 --- a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php @@ -16,6 +16,9 @@ use Eccube\Repository\BaseInfoRepository; use Eccube\Tests\Web\Admin\AbstractAdminWebTestCase; +/** + * @group cache-clear + */ class PluginControllerTest extends AbstractAdminWebTestCase { public function testRoutingAuthentication()