diff --git a/.gitignore b/.gitignore
index 3adc23e451..be6af7ecbc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -134,5 +134,8 @@ node_modules
# profiler
/profiler/*
# etc
-LOCAL_TODO.md
-LOCAL_Q&A.md
+/LOCAL_TODO.md
+/LOCAL_Q&A.md
+/.cache
+/docker/nginx/*
+/docker/proxy/*
diff --git a/composer.json b/composer.json
index 9e0246e601..3c2235ae59 100644
--- a/composer.json
+++ b/composer.json
@@ -108,23 +108,23 @@
}
},
"replace": {
- "baserproject/baser-core": "5.1.3",
- "baserproject/bc-admin-third": "5.1.3",
- "baserproject/bc-blog": "5.1.3",
- "baserproject/bc-column": "5.1.3",
- "baserproject/bc-content-link": "5.1.3",
- "baserproject/bc-custom-content": "5.1.3",
- "baserproject/bc-editor-template": "5.1.3",
- "baserproject/bc-favorite": "5.1.3",
- "baserproject/bc-front": "5.1.3",
- "baserproject/bc-installer": "5.1.3",
- "baserproject/bc-mail": "5.1.3",
- "baserproject/bc-plugin-sample": "5.1.3",
- "baserproject/bc-search-index": "5.1.3",
- "baserproject/bc-theme-config": "5.1.3",
- "baserproject/bc-theme-file": "5.1.3",
- "baserproject/bc-theme-sample": "5.1.3",
- "baserproject/bc-uploader": "5.1.3",
- "baserproject/bc-widget-area": "5.1.3"
+ "baserproject/baser-core": "5.1.4",
+ "baserproject/bc-admin-third": "5.1.4",
+ "baserproject/bc-blog": "5.1.4",
+ "baserproject/bc-column": "5.1.4",
+ "baserproject/bc-content-link": "5.1.4",
+ "baserproject/bc-custom-content": "5.1.4",
+ "baserproject/bc-editor-template": "5.1.4",
+ "baserproject/bc-favorite": "5.1.4",
+ "baserproject/bc-front": "5.1.4",
+ "baserproject/bc-installer": "5.1.4",
+ "baserproject/bc-mail": "5.1.4",
+ "baserproject/bc-plugin-sample": "5.1.4",
+ "baserproject/bc-search-index": "5.1.4",
+ "baserproject/bc-theme-config": "5.1.4",
+ "baserproject/bc-theme-file": "5.1.4",
+ "baserproject/bc-theme-sample": "5.1.4",
+ "baserproject/bc-uploader": "5.1.4",
+ "baserproject/bc-widget-area": "5.1.4"
}
}
diff --git a/plugins/baser-core/VERSION.txt b/plugins/baser-core/VERSION.txt
index 9aa994355a..06e8578b76 100644
--- a/plugins/baser-core/VERSION.txt
+++ b/plugins/baser-core/VERSION.txt
@@ -14,6 +14,27 @@
CHG: 変更内容 / BUG: バグフィックス / NEW: 機能追加
+[2024-11-28] basercms-5.1.4
+- CHG [BC] パーミッショングループ一覧の「有効」列を非表示に変更
+- CHG [BG] ブログ記事 スラッグ バリデーション追加
+- CHG [BC] プラグイン一覧の並び順を有効なものが上にくるに変更
+- CHG [BC] サイト編集画面にBcFormTableイベントを追加
+- CHG [BC] レイアウトテンプレートの選択欄の取得順序変更
+- BUG [BC] URL形式以外の文字が入力できてしまう問題を改善
+- BUG [BC] 独自プラグインの初期データが復元されない問題を改善
+- BUG [BC] 【テーマプラグイン】テーマ適用時にエラーメッセージが表示されプラグインがインストールされない問題を改善
+- BUG [BC] PagesTable 等の beforeSave や、afterSave が動作しない問題を改善
+- BUG [BC] サイト編集画面にてデバイス・言語のアクセス設定の動作不良を修正
+- BUG [BC] Themeの読み込み順変更。bc_form.phpをsetting.phpで変更できるように。
+- BUG [BC] fileLinkメソッドの動作不良を修正
+- BUG [BC] BcFreezeHelper にて、フリーズした際に、入力欄が表示されてしまう場合がある問題を改善
+- BUG [BC] イベントのオンオフを行う際にグローバルイベントマネージャーを指定した場合に例外を投げるように変更(処理がループしてしまうため)
+- BUG [BC] スキーマ書き出しの際にループしてしまう問題を改善
+- BUG [BC] 【テーマ設定】リンク先URL欄にURL形式以外の文字が入力できてしまう問題を改善
+- BUG [BG] 【blog】一覧表示でブログIDを指定する場合、IDが複数の場合エラーになる問題を解決
+- BUG [CC] カスタムコンテンツで関連フィールドの説明文表示をサニタイズ
+- BUG [ML] mailFormLinkメソッドの動作不良を修正
+
[2024-10-24] basercms-5.1.3
- NEW [BC] さくらのVPSのSSLに対応
- CHG [BC] baserCMS4系で使用していたときのパスワードが引き継げない問題を解決
@@ -32,7 +53,6 @@ CHG: 変更内容 / BUG: バグフィックス / NEW: 機能追加
- BUG [BC] 管理画面テーマの選択の不具合を改善 fix #3884
- BUG [UL] フロント側のログインユーザーに公開期間外のアップロードファイルが表示されてしまう問題を改善
-
[2024-09-26] basercms-5.1.2
- NEW [BC] JWTキー生成コマンド追加
- BUG [BC] BcUploadで作成したフォルダの権限が書き込み可能になっていない問題を改善
diff --git a/plugins/baser-core/composer.json b/plugins/baser-core/composer.json
index 7d9afd3715..23b42a022e 100644
--- a/plugins/baser-core/composer.json
+++ b/plugins/baser-core/composer.json
@@ -15,20 +15,20 @@
"firebase/php-jwt": "6.1.0",
"mobiledetect/mobiledetectlib": "^3.74",
"ext-json": "*",
- "baserproject/bc-admin-third": "5.1.x-dev",
- "baserproject/bc-blog": "5.1.x-dev",
- "baserproject/bc-content-link": "5.1.x-dev",
- "baserproject/bc-custom-content": "5.1.x-dev",
- "baserproject/bc-editor-template": "5.1.x-dev",
- "baserproject/bc-favorite": "5.1.x-dev",
- "baserproject/bc-front": "5.1.x-dev",
- "baserproject/bc-installer": "5.1.x-dev",
- "baserproject/bc-mail": "5.1.x-dev",
- "baserproject/bc-search-index": "5.1.x-dev",
- "baserproject/bc-theme-config": "5.1.x-dev",
- "baserproject/bc-theme-file": "5.1.x-dev",
- "baserproject/bc-uploader": "5.1.x-dev",
- "baserproject/bc-widget-area": "5.1.x-dev",
+ "baserproject/bc-admin-third": "5.1.4",
+ "baserproject/bc-blog": "5.1.4",
+ "baserproject/bc-content-link": "5.1.4",
+ "baserproject/bc-custom-content": "5.1.4",
+ "baserproject/bc-editor-template": "5.1.4",
+ "baserproject/bc-favorite": "5.1.4",
+ "baserproject/bc-front": "5.1.4",
+ "baserproject/bc-installer": "5.1.4",
+ "baserproject/bc-mail": "5.1.4",
+ "baserproject/bc-search-index": "5.1.4",
+ "baserproject/bc-theme-config": "5.1.4",
+ "baserproject/bc-theme-file": "5.1.4",
+ "baserproject/bc-uploader": "5.1.4",
+ "baserproject/bc-widget-area": "5.1.4",
"ext-mbstring": "*",
"ext-zip": "*",
"ext-gd": "*"
diff --git a/plugins/baser-core/config/setting.php b/plugins/baser-core/config/setting.php
index 857c6cd3d2..1ff0108ae9 100644
--- a/plugins/baser-core/config/setting.php
+++ b/plugins/baser-core/config/setting.php
@@ -417,6 +417,16 @@
*/
'enableRootRoutes' => false,
+ /**
+ * bc_formのテンプレートを指定
+ * config/bc_form.phpを差し替える
+ * プラグイン記法 (プラグイン名.テンプレート名)
+ */
+ //basercms/plugins/baser-core/src/View/AppView.php
+ 'AppFormTemplate' => 'BaserCore.bc_form',
+ //basercms/plugins/baser-core/src/View/BcAdminAppView.php
+ 'AdminFormTemplate' => 'BaserCore.bc_form',
+
/**
* システムナビ
*
diff --git a/plugins/baser-core/src/BaserCorePlugin.php b/plugins/baser-core/src/BaserCorePlugin.php
index 703f272e07..a5848d8901 100644
--- a/plugins/baser-core/src/BaserCorePlugin.php
+++ b/plugins/baser-core/src/BaserCorePlugin.php
@@ -151,7 +151,7 @@ public function bootstrap(PluginApplicationInterface $app): void
}
/**
- * プラグインロード
+ * テーマ・プラグインロード
*/
if (!filter_var(env('USE_DEBUG_KIT', true), FILTER_VALIDATE_BOOLEAN)) {
// 明示的に指定がない場合、DebugKitは重すぎるのでデバッグモードでも利用しない
@@ -164,19 +164,19 @@ public function bootstrap(PluginApplicationInterface $app): void
}
if (BcUtil::isTest()) $app->addPlugin('CakephpFixtureFactories');
- $app->addPlugin('Authentication');
- $app->addPlugin('Migrations');
- $this->addTheme($app);
-
- $plugins = BcUtil::getEnablePlugins();
- if ($plugins) {
- foreach($plugins as $plugin) {
- if (BcUtil::includePluginClass($plugin->name)) {
- $this->loadPlugin($app, $plugin->name, $plugin->priority);
- }
- }
- }
+ // 利用可能なテーマを取得
+ $themes = $this->getAvailableThemes();
+ // プラグインを追加する前にテーマが保有するプラグインのパスをセット
+ $this->setupThemePlugin($themes);
+ // テーマが保有するプラグインも含めてプラグインを読み込む
+ $this->addPlugin($app);
+ // ======================================================
+ // テーマはプラグインの後に読み込む
+ // テーマもプラグインとして扱う場合があるため、
+ // その場合に、テーマでプラグインの設定等を上書きできるようにする
+ // ======================================================
+ $this->addTheme($app, $themes);
/**
* デフォルトテンプレートを設定する
@@ -194,43 +194,67 @@ public function bootstrap(PluginApplicationInterface $app): void
$event->on(new BcAuthenticationEventListener());
}
+ /**
+ * プラグインを追加する
+ * @param PluginApplicationInterface $app
+ * @return void
+ * @checked
+ * @noTodo
+ */
+ public function addPlugin(PluginApplicationInterface $app): void
+ {
+ $app->addPlugin('Authentication');
+ $app->addPlugin('Migrations');
+
+ $plugins = BcUtil::getEnablePlugins();
+ if(!$plugins) return;
+ foreach($plugins as $plugin) {
+ if (!BcUtil::includePluginClass($plugin->name)) continue;
+ $this->loadPlugin($app, $plugin->name, $plugin->priority);
+ }
+ }
+
/**
* テーマを追加する
*
- * テーマ内のプラグインも追加する
- *
* @param PluginApplicationInterface $application
* @noTodo
* @checked
*/
- public function addTheme(PluginApplicationInterface $application)
+ public function addTheme(PluginApplicationInterface $application, array $themes): void
{
$application->addPlugin(Inflector::camelize(Configure::read('BcApp.coreAdminTheme'), '-'));
$application->addPlugin(Inflector::camelize(Configure::read('BcApp.coreFrontTheme'), '-'));
if (!BcUtil::isInstalled()) return;
- $sitesTable = TableRegistry::getTableLocator()->get('BaserCore.Sites');
- try {
- $sites = $sitesTable->find()->where(['Sites.status' => true]);
- } catch (MissingConnectionException) {
- return;
+
+ foreach($themes as $theme) {
+ if(!BcUtil::includePluginClass($theme)) continue;
+ try {
+ $application->addPlugin($theme);
+ } catch (MissingPluginException $e) {
+ $this->log($e->getMessage());
+ }
}
+ }
+ /**
+ * テーマが保有するプラグインのパスを追加する
+ * @param array $themes
+ * @return void
+ * @checked
+ * @noTodo
+ */
+ public function setupThemePlugin(array $themes): void
+ {
+ if (!BcUtil::isInstalled()) return;
+ if(!$themes) return;
$path = [];
- foreach($sites as $site) {
- if ($site->theme) {
- if(!BcUtil::includePluginClass($site->theme)) continue;
- try {
- $application->addPlugin($site->theme);
- $pluginPath = CorePlugin::path($site->theme) . 'plugins' . DS;
- if (!is_dir($pluginPath)) continue;
- $path[] = $pluginPath;
- } catch (MissingPluginException $e) {
- $this->log($e->getMessage());
- }
- }
+ foreach($themes as $theme) {
+ $pluginsPath = CorePlugin::path($theme) . 'plugins' . DS;
+ if (!is_dir($pluginsPath)) continue;
+ $path[] = $pluginsPath;
}
- // テーマプラグインを追加
- if($path) {
+ if(isset($path) && $path) {
Configure::write('App.paths.plugins', array_merge(
Configure::read('App.paths.plugins'),
$path
@@ -238,6 +262,32 @@ public function addTheme(PluginApplicationInterface $application)
}
}
+ /**
+ * 利用可能なテーマを取得する
+ * @return array
+ * @checked
+ * @noTodo
+ */
+ public function getAvailableThemes(): array
+ {
+ if (!BcUtil::isInstalled()) return [];
+ $sitesTable = TableRegistry::getTableLocator()->get('BaserCore.Sites');
+ try {
+ $sites = $sitesTable->find()->where(['Sites.status' => true]);
+ } catch (MissingConnectionException) {
+ return [];
+ }
+ $themes = [];
+ foreach($sites as $site) {
+ if ($site->theme) {
+ if (!is_dir(CorePlugin::path($site->theme))) continue;
+ if(in_array($site->theme, $themes)) continue;
+ $themes[] = $site->theme;
+ }
+ }
+ return $themes;
+ }
+
/**
* デフォルトテンプレートを設定する
* @checked
diff --git a/plugins/baser-core/src/BcPlugin.php b/plugins/baser-core/src/BcPlugin.php
index 4cdc826ca5..8b5f72b7f1 100644
--- a/plugins/baser-core/src/BcPlugin.php
+++ b/plugins/baser-core/src/BcPlugin.php
@@ -83,6 +83,7 @@ public function initialize(): void
* @param PluginApplicationInterface $app
* @checked
* @noTodo
+ * @unitTest
*/
public function bootstrap(PluginApplicationInterface $app): void
{
@@ -465,6 +466,7 @@ public function routes(RouteBuilder $routes): void
* @return RouteBuilder
* @checked
* @noTodo
+ * @unitTest
*/
public function contentsRoutingForReverse(RouteBuilder $routes, string $plugin)
{
@@ -493,6 +495,7 @@ function(RouteBuilder $routes) {
* @return RouteBuilder
* @checked
* @noTodo
+ * @unitTest
*/
public function frontPageRouting(RouteBuilder $routes, string $plugin)
{
@@ -569,6 +572,7 @@ function(RouteBuilder $routes) use($isApi) {
* @return RouteBuilder
* @checked
* @noTodo
+ * @unitTest
*/
public function siteRouting(RouteBuilder $routes, string $plugin)
{
diff --git a/plugins/baser-core/src/Command/ComposerCommand.php b/plugins/baser-core/src/Command/ComposerCommand.php
index 5fe2637907..6f0775c996 100644
--- a/plugins/baser-core/src/Command/ComposerCommand.php
+++ b/plugins/baser-core/src/Command/ComposerCommand.php
@@ -34,6 +34,7 @@ class ComposerCommand extends Command
* @return \Cake\Console\ConsoleOptionParser
* @checked
* @noTodo
+ * @unitTest
*/
protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): \Cake\Console\ConsoleOptionParser
{
diff --git a/plugins/baser-core/src/Command/CreateReleaseCommand.php b/plugins/baser-core/src/Command/CreateReleaseCommand.php
index 4e2df2a4f8..48560200d0 100644
--- a/plugins/baser-core/src/Command/CreateReleaseCommand.php
+++ b/plugins/baser-core/src/Command/CreateReleaseCommand.php
@@ -59,6 +59,7 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser):
* @return int|void|null
* @checked
* @noTodo
+ * @unitTest
*/
public function execute(Arguments $args, ConsoleIo $io)
{
@@ -109,6 +110,7 @@ public function execute(Arguments $args, ConsoleIo $io)
* @param string $packagePath
* @checked
* @noTodo
+ * @unitTest
*/
public function clonePackage(string $packagePath, string $branch)
{
diff --git a/plugins/baser-core/src/Command/SetupInstallCommand.php b/plugins/baser-core/src/Command/SetupInstallCommand.php
index 412a7fd266..7db47d451f 100644
--- a/plugins/baser-core/src/Command/SetupInstallCommand.php
+++ b/plugins/baser-core/src/Command/SetupInstallCommand.php
@@ -41,6 +41,7 @@ class SetupInstallCommand extends Command
* @return int|void|null
* @checked
* @noTodo
+ * @unitTest
*/
public function execute(Arguments $args, ConsoleIo $io)
{
diff --git a/plugins/baser-core/src/Command/SetupTestCommand.php b/plugins/baser-core/src/Command/SetupTestCommand.php
index a08822660e..4efa255db0 100644
--- a/plugins/baser-core/src/Command/SetupTestCommand.php
+++ b/plugins/baser-core/src/Command/SetupTestCommand.php
@@ -39,6 +39,7 @@ class SetupTestCommand extends Command
* @return int|void|null
* @checked
* @noTodo
+ * @unitTest
*/
public function execute(Arguments $args, ConsoleIo $io)
{
diff --git a/plugins/baser-core/src/Controller/AppController.php b/plugins/baser-core/src/Controller/AppController.php
index 61e7822740..042326c8f9 100644
--- a/plugins/baser-core/src/Controller/AppController.php
+++ b/plugins/baser-core/src/Controller/AppController.php
@@ -195,6 +195,7 @@ public function beforeFilter(EventInterface $event)
* @return bool
* @noTodo
* @checked
+ * @unitTest
*/
private function checkPermission()
{
diff --git a/plugins/baser-core/src/Controller/BcFrontAppController.php b/plugins/baser-core/src/Controller/BcFrontAppController.php
index afa0637b86..f93c9c33bf 100644
--- a/plugins/baser-core/src/Controller/BcFrontAppController.php
+++ b/plugins/baser-core/src/Controller/BcFrontAppController.php
@@ -50,6 +50,7 @@ public function initialize(): void
* @return Response|void
* @checked
* @noTodo
+ * @unitTest
*/
public function beforeFilter(EventInterface $event)
{
@@ -73,6 +74,7 @@ public function beforeFilter(EventInterface $event)
* @param EventInterface $event
* @checked
* @noTodo
+ * @unitTest
*/
public function beforeRender(EventInterface $event): void
{
diff --git a/plugins/baser-core/src/Controller/UploadsController.php b/plugins/baser-core/src/Controller/UploadsController.php
index 532c24c2e2..dec30fed63 100644
--- a/plugins/baser-core/src/Controller/UploadsController.php
+++ b/plugins/baser-core/src/Controller/UploadsController.php
@@ -31,6 +31,7 @@ class UploadsController extends AppController
* @return \Cake\Http\Response
* @checked
* @noTodo
+ * @unitTest
*/
public function tmp()
{
diff --git a/plugins/baser-core/src/Controller/UsersController.php b/plugins/baser-core/src/Controller/UsersController.php
index ecc41e1c41..a7b5b34bc2 100644
--- a/plugins/baser-core/src/Controller/UsersController.php
+++ b/plugins/baser-core/src/Controller/UsersController.php
@@ -33,6 +33,7 @@ class UsersController extends BcFrontAppController
* @return void
* @checked
* @noTodo
+ * @unitTest
*/
public function initialize(): void
{
diff --git a/plugins/baser-core/src/Database/Migration/BcMigration.php b/plugins/baser-core/src/Database/Migration/BcMigration.php
index 14a6a57d5e..6a4e79565e 100644
--- a/plugins/baser-core/src/Database/Migration/BcMigration.php
+++ b/plugins/baser-core/src/Database/Migration/BcMigration.php
@@ -34,6 +34,7 @@ class BcMigration extends AbstractMigration
* @return \Migrations\Table
* @checked
* @noTodo
+ * @unitTest
*/
public function table(string $tableName, array $options = []): Table
{
diff --git a/plugins/baser-core/src/Database/Migration/BcSeed.php b/plugins/baser-core/src/Database/Migration/BcSeed.php
index e355815ade..006ad835f4 100644
--- a/plugins/baser-core/src/Database/Migration/BcSeed.php
+++ b/plugins/baser-core/src/Database/Migration/BcSeed.php
@@ -35,10 +35,17 @@ class BcSeed extends AbstractSeed
* @return Table
* @checked
* @noTodo
+ * @unitTest
*/
public function table(string $tableName, array $options = []): Table
{
- $prefix = ConnectionManager::get($this->input->getOption('connection'))->config()['prefix'];
+ if($this->input->hasParameterOption('connection')) {
+ $connection = $this->input->getParameterOption('connection');
+ } else {
+ $connection = 'default';
+ }
+
+ $prefix = ConnectionManager::get($connection)->config()['prefix'];
return parent::table($prefix . $tableName);
}
diff --git a/plugins/baser-core/src/Event/BcEventDispatcher.php b/plugins/baser-core/src/Event/BcEventDispatcher.php
index a64927fa9a..aaa5124418 100644
--- a/plugins/baser-core/src/Event/BcEventDispatcher.php
+++ b/plugins/baser-core/src/Event/BcEventDispatcher.php
@@ -45,13 +45,14 @@ class BcEventDispatcher
* @return boolean|Event
* @checked
* @noTodo
+ * @unitTest
*/
public static function dispatch($name, $subject, $data = [], $options = [])
{
$options = array_merge([
'layer' => '',
- 'plugin' => method_exists($subject, 'getPlugin')? $subject->getPlugin() : '',
- 'class' => method_exists($subject, 'getName')? $subject->getName() : ''
+ 'plugin' => method_exists($subject, 'getPlugin') ? $subject->getPlugin() : '',
+ 'class' => method_exists($subject, 'getName') ? $subject->getName() : ''
], $options);
$eventName = '';
diff --git a/plugins/baser-core/src/Event/BcEventListener.php b/plugins/baser-core/src/Event/BcEventListener.php
index 355b454a40..7d1c3d7863 100644
--- a/plugins/baser-core/src/Event/BcEventListener.php
+++ b/plugins/baser-core/src/Event/BcEventListener.php
@@ -64,6 +64,7 @@ class BcEventListener implements EventListenerInterface
* コンストラクタ
* @checked
* @noTodo
+ * @unitTest
*/
public function __construct()
{
@@ -78,6 +79,7 @@ public function __construct()
* @return array
* @checked
* @noTodo
+ * @unitTest
*/
public function implementedEvents(): array
{
diff --git a/plugins/baser-core/src/Event/BcShortCodeEventListener.php b/plugins/baser-core/src/Event/BcShortCodeEventListener.php
index 97efbd65e2..8cbd21144c 100644
--- a/plugins/baser-core/src/Event/BcShortCodeEventListener.php
+++ b/plugins/baser-core/src/Event/BcShortCodeEventListener.php
@@ -50,6 +50,7 @@ public function implementedEvents(): array
* @return void
* @checked
* @noTodo
+ * @unitTest
*/
public function afterRender(Event $event)
{
@@ -65,6 +66,7 @@ public function afterRender(Event $event)
* @return void
* @checked
* @noTodo
+ * @unitTest
*/
protected function _execShortCode(View $view)
{
diff --git a/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php b/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php
index 8d2b47d002..8052942f6a 100644
--- a/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php
+++ b/plugins/baser-core/src/Identifier/Resolver/PrefixOrmResolver.php
@@ -34,6 +34,7 @@ class PrefixOrmResolver extends OrmResolver implements ResolverInterface
* @return array|EntityInterface|null
* @checked
* @noTodo
+ * @unitTest
*/
public function find(array $conditions, $type = self::TYPE_AND): \ArrayAccess|array|null
{
diff --git a/plugins/baser-core/src/Mailer/Admin/BcAdminMailer.php b/plugins/baser-core/src/Mailer/Admin/BcAdminMailer.php
index 036692eeaa..db05141eeb 100644
--- a/plugins/baser-core/src/Mailer/Admin/BcAdminMailer.php
+++ b/plugins/baser-core/src/Mailer/Admin/BcAdminMailer.php
@@ -27,6 +27,7 @@ class BcAdminMailer extends BcMailer
* @param null $config
* @checked
* @noTodo
+ * @unitTest
*/
public function __construct($config = null)
{
diff --git a/plugins/baser-core/src/Mailer/Admin/PasswordRequestMailer.php b/plugins/baser-core/src/Mailer/Admin/PasswordRequestMailer.php
index 59b663e59f..d30b18e209 100644
--- a/plugins/baser-core/src/Mailer/Admin/PasswordRequestMailer.php
+++ b/plugins/baser-core/src/Mailer/Admin/PasswordRequestMailer.php
@@ -32,6 +32,7 @@ class PasswordRequestMailer extends BcAdminMailer
* @param PasswordRequest|EntityInterface
* @checked
* @noTodo
+ * @unitTest
*/
public function resetPassword(EntityInterface $user, EntityInterface $passwordRequest)
{
diff --git a/plugins/baser-core/src/Mailer/BcMailer.php b/plugins/baser-core/src/Mailer/BcMailer.php
index 15754f2d73..89672a265b 100644
--- a/plugins/baser-core/src/Mailer/BcMailer.php
+++ b/plugins/baser-core/src/Mailer/BcMailer.php
@@ -48,6 +48,7 @@ class BcMailer extends Mailer
* @param null $config
* @checked
* @noTodo
+ * @unitTest
*/
public function __construct($config = null)
{
@@ -58,9 +59,13 @@ public function __construct($config = null)
if ($site) $this->viewBuilder()
->setTheme($site->theme)
->setClassName('BaserCore.BcFrontEmail');
- $this->setFrom([
- BcSiteConfig::get('email') => BcSiteConfig::get('formal_name')
- ]);
+ $adminMail = BcSiteConfig::get('email');
+ if (strpos($adminMail, ',') !== false) {
+ [$fromAdmin] = explode(',', $adminMail);
+ } else {
+ $fromAdmin = $adminMail;
+ }
+ $this->setFrom($fromAdmin, BcSiteConfig::get('formal_name'));
}
/**
@@ -68,6 +73,7 @@ public function __construct($config = null)
* @return void
* @checked
* @noTodo
+ * @unitTest
*/
public function setEmailTransport()
{
@@ -105,6 +111,7 @@ public function setEmailTransport()
* @return string
* @checked
* @noTodo
+ * @unitTest
*/
public function getPlugin(): ?string
{
@@ -119,6 +126,7 @@ public function getPlugin(): ?string
* @psalm-return array{headers: string, message: string}
* @checked
* @noTodo
+ * @unitTest
*/
public function deliver(string $content = ''): array
{
diff --git a/plugins/baser-core/src/Middleware/BcFrontMiddleware.php b/plugins/baser-core/src/Middleware/BcFrontMiddleware.php
index 3a819f78b9..84b6d5f131 100644
--- a/plugins/baser-core/src/Middleware/BcFrontMiddleware.php
+++ b/plugins/baser-core/src/Middleware/BcFrontMiddleware.php
@@ -36,6 +36,7 @@ class BcFrontMiddleware implements MiddlewareInterface
* @return ResponseInterface
* @checked
* @noTodo
+ * @unitTest
*/
public function process(
ServerRequestInterface $request,
diff --git a/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php b/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php
index d19a462720..b1a8c73e46 100644
--- a/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php
+++ b/plugins/baser-core/src/Middleware/BcRedirectMainSiteMiddleware.php
@@ -42,6 +42,7 @@ class BcRedirectMainSiteMiddleware implements MiddlewareInterface
* @return ResponseInterface
* @checked
* @noTodo
+ * @unitTest
*/
public function process(
ServerRequestInterface $request,
diff --git a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php
index 3adb3220d4..af72b828c8 100644
--- a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php
+++ b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php
@@ -75,6 +75,7 @@ public function initialize(array $config): void
* @return string
* @checked
* @noTodo
+ * @unitTest
*/
public function getType(): string
{
@@ -86,6 +87,7 @@ public function getType(): string
* アソシエーション時に alias を除外する
* @checked
* @noTodo
+ * @unitTest
*/
public function offAlias(): void
{
diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php
index 2b049a09bf..1c760fef5e 100644
--- a/plugins/baser-core/src/Model/Table/ContentsTable.php
+++ b/plugins/baser-core/src/Model/Table/ContentsTable.php
@@ -409,7 +409,7 @@ public function getUniqueName($name, $parentId, $contentId = null)
$query = $this->find()->where(['name LIKE' => $name . '%', 'site_root' => false]);
if (isset($parentId)) $query = $query->andWhere(['parent_id' => $parentId]);
if ($contentId) {
- $query = $query->andWhere(['id <>' => $contentId]);
+ $query = $query->andWhere(['Contents.id <>' => $contentId]);
}
$datas = $query->select('name')->orderBy('name')->all()->toArray();
$datas = Hash::extract($datas, '{n}.name');
diff --git a/plugins/baser-core/src/Model/Table/SiteConfigsTable.php b/plugins/baser-core/src/Model/Table/SiteConfigsTable.php
index 01b5202d74..615fab96fd 100755
--- a/plugins/baser-core/src/Model/Table/SiteConfigsTable.php
+++ b/plugins/baser-core/src/Model/Table/SiteConfigsTable.php
@@ -79,8 +79,12 @@ public function validationKeyValue(Validator $validator): Validator
{
$validator
->scalar('email')
- ->email('email', 255, __d('baser_core', '管理者メールアドレスの形式が不正です。'))
- ->notEmptyString('email', __d('baser_core', '管理者メールアドレスを入力してください。'));
+ ->notEmptyString('email', __d('baser_core', '管理者メールアドレスを入力してください。'))
+ ->add('email', ['emails' => [
+ 'rule' => 'emails',
+ 'provider' => 'bc',
+ 'message' => __d('baser_core', '管理者メールアドレスの形式が不正です。')
+ ]]);
$validator
->scalar('site_url')
->regex('site_url', '/^(http|https):/', __d('baser_core', 'WebサイトURLはURLの形式を入力してください。'))
diff --git a/plugins/baser-core/src/Model/Table/SitesTable.php b/plugins/baser-core/src/Model/Table/SitesTable.php
index 41852631d1..db3ddffbbb 100644
--- a/plugins/baser-core/src/Model/Table/SitesTable.php
+++ b/plugins/baser-core/src/Model/Table/SitesTable.php
@@ -212,7 +212,7 @@ public function pluginExistsByDasherize($value)
*/
public function getPublishedAll(): ResultSetInterface
{
- return $this->find()->where(['status' => true])->all();
+ return $this->find()->where(['Sites.status' => true])->all();
}
/**
@@ -236,7 +236,7 @@ public function getList($mainSiteId = null, $options = [])
$conditions = [];
if (!is_null($options['status'])) {
- $conditions = ['status' => $options['status']];
+ $conditions = ['Sites.status' => $options['status']];
}
if (!is_null($mainSiteId)) {
diff --git a/plugins/baser-core/src/Service/Admin/BcAdminContentsService.php b/plugins/baser-core/src/Service/Admin/BcAdminContentsService.php
index 8513b44ebb..5a632f5fc6 100644
--- a/plugins/baser-core/src/Service/Admin/BcAdminContentsService.php
+++ b/plugins/baser-core/src/Service/Admin/BcAdminContentsService.php
@@ -133,7 +133,7 @@ public function getLayoutTemplates(EntityInterface $content)
if (in_array($parentTemplate, $templates)) {
unset($templates[$parentTemplate]);
}
- $templates = array_merge($templates, ['' => __d('baser_core', '親フォルダの設定に従う') . '(' . $parentTemplate . ')']);
+ $templates = array_merge(['' => __d('baser_core', '親フォルダの設定に従う') . '(' . $parentTemplate . ')'], $templates);
}
return $templates;
}
diff --git a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php
index 6c56864554..2e64bc6248 100644
--- a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php
+++ b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php
@@ -126,6 +126,7 @@ public function getViewVarsForUpdate(EntityInterface $entity): array
* @return mixed|string
* @checked
* @noTodo
+ * @unitTest
*/
public function whichPhp()
{
diff --git a/plugins/baser-core/src/Service/BcDatabaseService.php b/plugins/baser-core/src/Service/BcDatabaseService.php
index 41a36e98af..fedc16963c 100644
--- a/plugins/baser-core/src/Service/BcDatabaseService.php
+++ b/plugins/baser-core/src/Service/BcDatabaseService.php
@@ -324,11 +324,8 @@ public function dropTable(string $tableName)
*/
public function loadDefaultDataPattern(string $theme, string $pattern, string $dbConfigKeyName = 'default'): bool
{
- $plugins = array_merge(
- ['BaserCore'],
- Configure::read('BcApp.corePlugins'),
- BcUtil::getCurrentThemesPlugins()
- );
+ $folderUtility = new BcFolder(Plugin::path($theme) . 'config' . DS . 'data' . DS . $pattern);
+ $plugins = $folderUtility->getFolders();
$db = $this->getDataSource($dbConfigKeyName);
$db->begin();
@@ -1052,7 +1049,7 @@ public function writeSchema($table, $options)
'schema' => $schema
]);
- $eventManager = EventManager::instance();
+ $eventManager = new EventManager();
$beforeRenderListeners = BcUtil::offEvent($eventManager, 'View.beforeRender');
$afterRenderListeners = BcUtil::offEvent($eventManager, 'View.afterRender');
diff --git a/plugins/baser-core/src/Service/PagesService.php b/plugins/baser-core/src/Service/PagesService.php
index db5106b9d8..c211fff261 100644
--- a/plugins/baser-core/src/Service/PagesService.php
+++ b/plugins/baser-core/src/Service/PagesService.php
@@ -226,6 +226,7 @@ public function getIndex(array $queryParams = []): Query
* @return Query
* @checked
* @noTodo
+ * @unitTest
*/
protected function createIndexConditions(Query $query, $options = [])
{
diff --git a/plugins/baser-core/src/Service/PermissionGroupsService.php b/plugins/baser-core/src/Service/PermissionGroupsService.php
index 543befc3ac..44d4294f77 100644
--- a/plugins/baser-core/src/Service/PermissionGroupsService.php
+++ b/plugins/baser-core/src/Service/PermissionGroupsService.php
@@ -246,6 +246,7 @@ public function buildByUserGroup(int $userGroupId)
* @return bool
* @checked
* @noTodo
+ * @unitTest
*/
public function rebuildByUserGroup(int $userGroupId)
{
diff --git a/plugins/baser-core/src/Service/PermissionsService.php b/plugins/baser-core/src/Service/PermissionsService.php
index 613d66975e..be26b3f72f 100644
--- a/plugins/baser-core/src/Service/PermissionsService.php
+++ b/plugins/baser-core/src/Service/PermissionsService.php
@@ -677,6 +677,7 @@ public function getNamesById($ids): array
* @return array
* @checked
* @noTodo
+ * @unitTest
*/
public function getControlSource(string $field, array $options = [])
{
diff --git a/plugins/baser-core/src/Service/PluginsService.php b/plugins/baser-core/src/Service/PluginsService.php
index f5d3a139f4..4d2ca021d5 100644
--- a/plugins/baser-core/src/Service/PluginsService.php
+++ b/plugins/baser-core/src/Service/PluginsService.php
@@ -98,7 +98,10 @@ public function get($id): EntityInterface
public function getIndex(string $sortMode): array
{
$plugins = $this->Plugins->find()
- ->orderBy(['priority'])
+ ->orderBy([
+ 'status' => 'DESC',
+ 'priority' => 'ASC',
+ ])
->all()
->toArray();
if ($sortMode) {
@@ -738,6 +741,7 @@ public function add(array $postData)
* - `versions`: 取得可能なコアのバージョンリスト
* @checked
* @noTodo
+ * @unitTest
*/
public function getAvailableCoreVersionInfo()
{
diff --git a/plugins/baser-core/src/Service/SiteConfigsService.php b/plugins/baser-core/src/Service/SiteConfigsService.php
index b4a861cd32..744d08f6dd 100644
--- a/plugins/baser-core/src/Service/SiteConfigsService.php
+++ b/plugins/baser-core/src/Service/SiteConfigsService.php
@@ -268,6 +268,7 @@ public function clearCache()
* @throws \Throwable
* @checked
* @noTodo
+ * @unitTest
*/
public function sendTestMail(array $postData, string $email, string $subject, string $body)
{
diff --git a/plugins/baser-core/src/Service/ThemesService.php b/plugins/baser-core/src/Service/ThemesService.php
index f08400b68b..e60a5eaeb8 100644
--- a/plugins/baser-core/src/Service/ThemesService.php
+++ b/plugins/baser-core/src/Service/ThemesService.php
@@ -23,6 +23,7 @@
use BaserCore\Annotation\Checked;
use BaserCore\Utility\BcZip;
use BcMail\Service\MailMessagesServiceInterface;
+use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\EntityInterface;
@@ -286,6 +287,12 @@ private function getThemesDefaultDataInfo(string $theme, array $info = [])
*/
public function installThemesPlugins(string $theme)
{
+ $paths = App::path('plugins');
+ $path = BcUtil::getPluginPath($theme) . 'plugins' . DS;
+ if(!is_dir($path)) return;
+ if(!in_array($path, $paths)) {
+ Configure::write('App.paths.plugins', array_merge($paths, [$path]));
+ }
/* @var PluginsService $pluginsService */
$pluginsService = $this->getService(PluginsServiceInterface::class);
$plugins = BcUtil::getThemesPlugins($theme);
diff --git a/plugins/baser-core/src/TestSuite/BcTestCase.php b/plugins/baser-core/src/TestSuite/BcTestCase.php
index 161930b612..7defc2b9b9 100644
--- a/plugins/baser-core/src/TestSuite/BcTestCase.php
+++ b/plugins/baser-core/src/TestSuite/BcTestCase.php
@@ -160,6 +160,7 @@ public function setUp(): void
* クラスメソッド名を取得する
* @checked
* @noTodo
+ * @unitTest テストができないのでスキップ
*/
public function classMethod()
{
diff --git a/plugins/baser-core/src/Utility/BcAbstractDetector.php b/plugins/baser-core/src/Utility/BcAbstractDetector.php
index fb831f875b..d65a4da4d6 100644
--- a/plugins/baser-core/src/Utility/BcAbstractDetector.php
+++ b/plugins/baser-core/src/Utility/BcAbstractDetector.php
@@ -62,6 +62,7 @@ abstract class BcAbstractDetector
* @param array $config 設定の配列
* @checked
* @noTodo
+ * @unitTest
*/
public function __construct($name, array $config)
{
diff --git a/plugins/baser-core/src/Utility/BcUtil.php b/plugins/baser-core/src/Utility/BcUtil.php
index 2aaaf6dae8..8da2c6a2ae 100644
--- a/plugins/baser-core/src/Utility/BcUtil.php
+++ b/plugins/baser-core/src/Utility/BcUtil.php
@@ -11,6 +11,7 @@
namespace BaserCore\Utility;
+use BaserCore\Error\BcException;
use BaserCore\Middleware\BcAdminMiddleware;
use BaserCore\Middleware\BcFrontMiddleware;
use BaserCore\Middleware\BcRequestFilterMiddleware;
@@ -1114,9 +1115,9 @@ public static function getPluginDir(string $pluginName, bool $isUpdateTmp = fals
*/
public static function getContentsItem(): array
{
- $items = Configure::read('BcContents.items');
+ $plugins = Configure::read('BcContents.items');
$createdItems = [];
- foreach($items as $name => $items) {
+ foreach($plugins as $name => $items) {
foreach($items as $type => $item) {
$item['plugin'] = $name;
$item['type'] = $type;
@@ -1641,12 +1642,30 @@ public static function fgetcsvReg(&$handle, $length = null, $d = ',', $e = '"')
*/
public static function offEvent(EventManagerInterface $eventManager, string $eventKey)
{
- $eventListeners = $eventManager->listeners($eventKey);
+ $reflection = new ReflectionClass($eventManager);
+ $property = $reflection->getProperty('_isGlobal');
+ $property->setAccessible(true);
+ if($property->getValue($eventManager)) {
+ throw new BcException(__d('baser_core', 'グローバルイベントマネージャーからはイベントをオフにすることはできません。'));
+ }
+
$globalEventManager = $eventManager->instance();
- if ($eventListeners) {
- foreach($eventListeners as $eventListener) {
- $eventManager->off($eventKey, $eventListener['callable']);
- $globalEventManager->off($eventKey, $eventListener['callable']);
+ $eventListeners = [
+ 'local' => $eventManager->prioritisedListeners($eventKey),
+ 'global' => $globalEventManager->prioritisedListeners($eventKey)
+ ];
+ if ($eventListeners['local']) {
+ foreach($eventListeners['local'] as $listeners) {
+ foreach($listeners as $listener) {
+ $eventManager->off($eventKey, $listener['callable']);
+ }
+ }
+ }
+ if ($eventListeners['global']) {
+ foreach($eventListeners['global'] as $listeners) {
+ foreach($listeners as $listener) {
+ $globalEventManager->off($eventKey, $listener['callable']);
+ }
}
}
return $eventListeners;
@@ -1656,16 +1675,33 @@ public static function offEvent(EventManagerInterface $eventManager, string $eve
* イベントをオンにする
* @param EventManagerInterface $eventManager
* @param string $eventKey
- * @param EventListenerInterface[] $eventListeners
+ * @param array $eventListeners
* @checked
* @noTodo
* @unitTest
*/
public static function onEvent(EventManagerInterface $eventManager, string $eventKey, array $eventListeners)
{
- if ($eventListeners) {
- foreach($eventListeners as $eventListener) {
- $eventManager->on($eventKey, $eventListener['callable']);
+ $reflection = new ReflectionClass($eventManager);
+ $property = $reflection->getProperty('_isGlobal');
+ $property->setAccessible(true);
+ if($property->getValue($eventManager)) {
+ throw new BcException(__d('baser_core', 'グローバルイベントマネージャーからはイベントをオンにすることはできません。'));
+ }
+
+ $globalEventManager = $eventManager->instance();
+ if (!empty($eventListeners['local'])) {
+ foreach($eventListeners['local'] as $priority => $listeners) {
+ foreach($listeners as $listener) {
+ $eventManager->on($eventKey, ['priority' => $priority], $listener['callable']);
+ }
+ }
+ }
+ if (!empty($eventListeners['global'])) {
+ foreach($eventListeners['global'] as $priority => $listeners) {
+ foreach($listeners as $listener) {
+ $globalEventManager->on($eventKey, ['priority' => $priority], $listener['callable']);
+ }
}
}
}
diff --git a/plugins/baser-core/src/View/AppView.php b/plugins/baser-core/src/View/AppView.php
index 5be106520a..3160f2134e 100644
--- a/plugins/baser-core/src/View/AppView.php
+++ b/plugins/baser-core/src/View/AppView.php
@@ -16,6 +16,7 @@
use BaserCore\View\Helper\BcToolbarHelper;
use BaserCore\View\Helper\BcUploadHelper;
use Cake\View\View;
+use Cake\Core\Configure;
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\UnitTest;
@@ -53,7 +54,7 @@ public function initialize(): void
{
parent::initialize();
$this->addHelper('BaserCore.BcTime');
- $this->addHelper('BaserCore.BcForm', ['templates' => 'BaserCore.bc_form']);
+ $this->addHelper('BaserCore.BcForm', ['templates' => Configure::read('BcApp.AppFormTemplate')]);
$this->addHelper('BaserCore.BcAdmin');
$this->addHelper('BaserCore.BcContents');
$this->addHelper('BaserCore.BcPage');
diff --git a/plugins/baser-core/src/View/BcAdminAppView.php b/plugins/baser-core/src/View/BcAdminAppView.php
index ab89a0fa3a..8b586067b8 100644
--- a/plugins/baser-core/src/View/BcAdminAppView.php
+++ b/plugins/baser-core/src/View/BcAdminAppView.php
@@ -56,7 +56,7 @@ class BcAdminAppView extends AppView
public function initialize(): void
{
parent::initialize();
- $this->addHelper('BaserCore.BcAdminForm', ['templates' => 'BaserCore.bc_form']);
+ $this->addHelper('BaserCore.BcAdminForm', ['templates' => Configure::read('BcApp.AdminFormTemplate')]);
$this->addHelper('BaserCore.BcAuth');
$this->addHelper('BaserCore.BcText');
$this->addHelper('BaserCore.BcContents');
diff --git a/plugins/baser-core/src/View/Helper/BcUploadHelper.php b/plugins/baser-core/src/View/Helper/BcUploadHelper.php
index 446b363fa3..20753d44ec 100755
--- a/plugins/baser-core/src/View/Helper/BcUploadHelper.php
+++ b/plugins/baser-core/src/View/Helper/BcUploadHelper.php
@@ -26,6 +26,7 @@
use BaserCore\Event\BcEventDispatcherTrait;
use BaserCore\Service\SiteConfigsServiceInterface;
use Cake\View\Helper\HtmlHelper;
+use Laminas\Diactoros\UploadedFile;
use Throwable;
/**
@@ -159,7 +160,7 @@ public function fileLink($fieldName, $entity, $options = [])
$basePath = '/baser-core/uploads/tmp/';
}
- if (is_array($value)) {
+ if (is_array($value) || $value instanceof UploadedFile) {
return false;
}
diff --git a/plugins/baser-core/tests/TestCase/PluginTest.php b/plugins/baser-core/tests/TestCase/BaserCorePluginTest.php
similarity index 99%
rename from plugins/baser-core/tests/TestCase/PluginTest.php
rename to plugins/baser-core/tests/TestCase/BaserCorePluginTest.php
index 346438ad39..3098125ef8 100644
--- a/plugins/baser-core/tests/TestCase/PluginTest.php
+++ b/plugins/baser-core/tests/TestCase/BaserCorePluginTest.php
@@ -42,7 +42,7 @@
* Class PluginTest
* @property BaserCorePlugin $Plugin
*/
-class PluginTest extends BcTestCase
+class BaserCorePluginTest extends BcTestCase
{
use ScenarioAwareTrait;
@@ -108,6 +108,7 @@ public function testBootStrap(): void
$pathsPluginsExpected = [
'/var/www/html/plugins/',
'/var/www/html/vendor/baserproject/',
+ '/var/www/html/plugins/bc-custom-content/plugins/',
];
$this->assertEquals($pathsPluginsExpected, Configure::read('App.paths.plugins'));
diff --git a/plugins/baser-core/tests/TestCase/BcPluginTest.php b/plugins/baser-core/tests/TestCase/BcPluginTest.php
index 9d80842121..0c53bc8ce8 100644
--- a/plugins/baser-core/tests/TestCase/BcPluginTest.php
+++ b/plugins/baser-core/tests/TestCase/BcPluginTest.php
@@ -11,28 +11,24 @@
namespace BaserCore\Test\TestCase;
+use App\Application;
use BaserCore\BcPlugin;
use BaserCore\Service\SitesService;
+use BaserCore\Test\Factory\ContentFactory;
+use BaserCore\Test\Factory\ContentFolderFactory;
use BaserCore\Test\Factory\PermissionFactory;
use BaserCore\Test\Factory\PluginFactory;
+use BaserCore\Test\Factory\SiteFactory;
use BaserCore\Test\Factory\UserFactory;
-use BaserCore\Test\Scenario\ContentFoldersScenario;
-use BaserCore\Test\Scenario\ContentsScenario;
-use BaserCore\Test\Scenario\PluginsScenario;
-use BaserCore\Test\Scenario\SiteConfigsScenario;
-use BaserCore\Test\Scenario\SitesScenario;
-use BaserCore\Test\Scenario\UserGroupsScenario;
-use BaserCore\Test\Scenario\UserScenario;
-use BaserCore\Test\Scenario\UsersUserGroupsScenario;
+use BaserCore\Test\Scenario\InitAppScenario;
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\Datasource\ConnectionManager;
-use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
-use Cake\TestSuite\IntegrationTestTrait;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
/**
@@ -56,14 +52,6 @@ class BcPluginTest extends BcTestCase
public function setUp(): void
{
parent::setUp();
- $this->loadFixtureScenario(UserScenario::class);
- $this->loadFixtureScenario(UserGroupsScenario::class);
- $this->loadFixtureScenario(UsersUserGroupsScenario::class);
- $this->loadFixtureScenario(ContentsScenario::class);
- $this->loadFixtureScenario(SitesScenario::class);
- $this->loadFixtureScenario(SiteConfigsScenario::class);
- $this->loadFixtureScenario(ContentFoldersScenario::class);
- $this->loadFixtureScenario(PluginsScenario::class);
$this->BcPlugin = new BcPlugin(['name' => 'BcBlog']);
}
@@ -86,6 +74,16 @@ public function testInitialize()
$this->assertNotEmpty($this->BcPlugin->migrations);
}
+ /**
+ * test bootstrap
+ */
+ public function testBootstrap()
+ {
+ $app = new Application(CONFIG);
+ $this->BcPlugin->bootstrap($app);
+ $this->assertTrue(Configure::isConfigured('baser'));
+ }
+
/**
* testInstall
*/
@@ -137,6 +135,10 @@ public function testRollback()
*/
public function testRoutes()
{
+ SiteFactory::make(['id' => '1', 'main_site_id' => null])->persist();
+ SiteFactory::make(['id' => '2', 'main_site_id' => 1, 'alias' => 's'])->persist();
+ ContentFactory::make( ['plugin' => 'BcBlog', 'type' => 'BlogContent', 'entity_id' => 31, 'url' => '/news/', 'site_id' => 1])->persist();
+ $this->BcPlugin = new BcPlugin(['name' => 'BcBlog']);
$routes = Router::createRouteBuilder('/');
$this->BcPlugin->routes($routes);
@@ -546,6 +548,22 @@ public function test_execUpdater()
*/
public function test_applyAsTheme()
{
+ SiteFactory::make(['id' => '1', 'theme' => 'BcFront', 'main_site_id' => null])->persist();
+ ContentFactory::make([
+ 'id' => 1,
+ 'plugin' => 'BaserCore',
+ 'type' => 'ContentFolder',
+ 'entity_id' => 1,
+ 'site_id' => 1,
+ 'parent_id' => 0,
+ 'lft' => 1,
+ 'rght' => 2,
+ 'level' => 0,
+ 'status' => true,
+ 'site_root' => true,
+ ])->persist();
+ ContentFolderFactory::make(['id' => '1', 'folder_template' => 'baserCMSサンプル'])->persist();
+
$targetId = 1;
$currentTheme = 'BcFront';
$SiteService = new SitesService();
@@ -558,11 +576,41 @@ public function test_applyAsTheme()
$this->assertEquals($updateTheme, $site->theme);
}
+ /**
+ * test frontPageRouting
+ */
+ public function testFrontPageRouting()
+ {
+ // 管理画面のプラグイン用ルーティング
+ $result = Router::parseRequest($this->getRequest('/baser/admin/bc-blog/blog_contents/index'));
+ $this->assertEquals('BlogContents', $result['controller']);
+ $result = Router::parseRequest($this->getRequest('/baser/admin/bc-blog/blog_contents/edit/1'));
+ $this->assertEquals('BlogContents', $result['controller']);
+
+ // フロントエンドのプラグイン用ルーティング
+ $result = Router::parseRequest($this->getRequest('/bc-blog/blog_contents/index'));
+ $this->assertEquals('BlogContents', $result['controller']);
+ $result = Router::parseRequest($this->getRequest('/bc-blog/blog_contents/edit/1'));
+ $this->assertEquals('BlogContents', $result['controller']);
+ }
+
/**
* test Rest API
*/
public function testRestApi()
{
+ $this->loadFixtureScenario(InitAppScenario::class);
+ ContentFactory::make(
+ [
+ 'id' => 1,
+ 'plugin' => 'BaserCore',
+ 'type' => 'ContentFolder',
+ 'site_id' => 1,
+ 'parent_id' => 0,
+ 'lft' => 1,
+ 'rght' => 2,
+ ]
+ )->persist();
Router::resetRoutes();
// 件数確認
PermissionFactory::make()->allowGuest('/baser/api/*')->persist();
@@ -616,4 +664,42 @@ public function testRestApi()
$this->assertEquals(0, count($result->pages));
}
+ /**
+ * test contentsRoutingForReverse
+ */
+ public function testContentsRoutingForReverse()
+ {
+ SiteFactory::make(['id' => '1', 'main_site_id' => null])->persist();
+ SiteFactory::make(['id' => '2', 'main_site_id' => 1, 'alias' => 's'])->persist();
+ ContentFactory::make(['plugin' => 'BcBlog', 'type' => 'BlogContent', 'entity_id' => 31, 'url' => '/news/', 'site_id' => 1])->persist();
+ $this->BcPlugin = new BcPlugin(['name' => 'BcBlog']);
+ $routes = Router::createRouteBuilder('/');
+ $this->BcPlugin->routes($routes);
+ $this->getRequest('/');
+ $this->assertEquals('/news/', Router::url([
+ 'plugin' => 'BcBlog',
+ 'controller' => 'Blog',
+ 'action' => 'index',
+ 'entityId' => 31
+ ]));
+ }
+
+ /**
+ * test siteRouting
+ */
+ public function testSiteRouting()
+ {
+ SiteFactory::make(['id' => '1', 'main_site_id' => null])->persist();
+ SiteFactory::make(['id' => '2', 'main_site_id' => 1, 'alias' => 's'])->persist();
+ ContentFactory::make(['plugin' => 'BcBlog', 'type' => 'BlogContent', 'entity_id' => 31, 'url' => '/news/', 'site_id' => 1])->persist();
+
+ Router::reload();
+ $routes = Router::createRouteBuilder('');
+ $_SERVER['REQUEST_URI'] = '/s/';
+ $this->BcPlugin->clearCurrentSite();
+ $this->BcPlugin->routes($routes);
+ $result = Router::parseRequest($this->getRequest('/s/bc-blog/blog_contents/index'));
+ $this->assertEquals('BlogContents', $result['controller']);
+ }
+
}
diff --git a/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php b/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php
index c1a471b2f7..3a60ff0ac0 100644
--- a/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php
+++ b/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php
@@ -57,7 +57,6 @@ public function testBuildOptionParser()
*/
public function testExecute()
{
- $this->markTestIncomplete('CakePHPのバージョンの問題があるので、baserCMS 5.1.0 をリリースしてから再実装する');
// バージョン指定なし
$this->exec('composer');
$this->assertErrorContains('Missing required argument. The `version` argument is required');
@@ -68,23 +67,16 @@ public function testExecute()
copy(ROOT . DS . 'composer.lock', ROOT . DS . 'composer.lock.bak');
// composer実行(composer.json を配布用にセットアップなし)
- $this->exec('composer 5.0.15');
+ $this->exec('composer 9999.9999.9999');
$this->assertExitError();
$this->assertErrorContains('Composer によるアップデートが失敗しました。update ログを確認してください。');
// composer実行(composer.json を配布用にセットアップ)
BcComposer::setup('', ROOT . DS);
- BcComposer::setupComposerForDistribution('5.0.15');
- $this->exec('composer 5.0.15');
+ $this->exec('composer 5.1.4.0');
$this->assertExitCode(Command::CODE_SUCCESS);
$this->assertOutputContains('Composer によるアップデートが完了しました。');
- // バージョンを確認
- $file = new BcFile(ROOT . DS . 'vendor' . DS . 'baserproject' . DS . 'baser-core' . DS . 'VERSION.txt');
- $versionData = $file->read();
- $aryVersionData = explode("\n", $versionData);
- $this->assertEquals('5.0.15', $aryVersionData[0]);
-
// バックアップをリストア
rename(ROOT . DS . 'composer.json.bak', ROOT . DS . 'composer.json');
rename(ROOT . DS . 'composer.lock.bak', ROOT . DS . 'composer.lock');
diff --git a/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php b/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php
index d2d730c943..8f1eac3588 100644
--- a/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php
+++ b/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php
@@ -4,12 +4,19 @@
use BaserCore\Command\CreateReleaseCommand;
use BaserCore\TestSuite\BcTestCase;
+use Cake\Command\Command;
use Cake\Console\ConsoleOptionParser;
use BaserCore\Utility\BcFolder;
use Cake\Core\Configure;
+use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
class CreateReleaseCommandTest extends BcTestCase
{
+ /**
+ * Trait
+ */
+ use ConsoleIntegrationTestTrait;
+
private $packagePath;
private $zipFile;
public function setUp(): void
@@ -68,6 +75,22 @@ public function testBuildOptionParser()
$this->assertEquals('master', $options['branch']->defaultValue());
}
+ /**
+ * test execute
+ */
+ public function testExecute()
+ {
+ //異常テスト
+ $this->exec('create release');
+ $this->assertExitCode(Command::CODE_ERROR);
+
+ //正常テスト
+ $this->exec('create release 5.1.1');
+ $this->assertExitCode(Command::CODE_SUCCESS);
+ $this->assertOutputContains('リリースパッケージの作成が完了しました。/tmp/basercms.zip を確認してください。');
+ $this->assertTrue(file_exists(TMP . 'basercms-5.1.1.zip'));
+ unlink(TMP . 'basercms-5.1.1.zip');
+ }
/**
* Test deleteExcludeFiles
@@ -146,4 +169,20 @@ public function test_deletePlugins()
//clean up
$folder->delete($pluginsPath);
}
+
+ /**
+ * test clonePackage
+ */
+ public function testClonePackage()
+ {
+ //テストを実行
+ $this->CreateReleaseCommand->clonePackage('/var/www/html/tmp/basercms/', 'master');
+
+ //パッケージを GitHub よりクローンできるか確認
+ $this->assertTrue(is_dir(TMP . 'basercms'));
+ $this->assertTrue(file_exists(TMP . 'basercms'));
+
+ //不要フォルダを削除
+ (new BcFolder(TMP . 'basercms'))->delete();
+ }
}
diff --git a/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php b/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php
new file mode 100644
index 0000000000..e63f04b1c3
--- /dev/null
+++ b/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php
@@ -0,0 +1,51 @@
+exec('setup install');
+ $this->assertExitCode(Command::CODE_SUCCESS);
+ $this->assertOutputContains('インストールの準備ができました。');
+
+ //backup
+ rename(ROOT . DS . 'config' . DS . 'install.php.bak', ROOT . DS . 'config' . DS . 'install.php');
+ }
+}
diff --git a/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php b/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php
new file mode 100644
index 0000000000..7f3cea1fc0
--- /dev/null
+++ b/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php
@@ -0,0 +1,39 @@
+exec('setup test');
+ $this->assertExitCode(Command::CODE_SUCCESS);
+ $this->assertOutputContains('ユニットテストの準備ができました。');
+ $this->assertEquals('true', env('DEBUG'));
+ $this->assertEquals('true' ,env('USE_CORE_API'));
+ $this->assertEquals('true' ,env('USE_CORE_ADMIN_API'));
+ }
+}
diff --git a/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php
index dc11139e95..14c27cb706 100644
--- a/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php
+++ b/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php
@@ -11,6 +11,7 @@
namespace BaserCore\Test\TestCase\Controller;
+use BaserCore\Service\PermissionsServiceInterface;
use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\Test\Scenario\ContentsScenario;
use BaserCore\Test\Scenario\InitAppScenario;
@@ -147,6 +148,28 @@ public function test_beforeRender()
$this->assertEquals('BcAdminThird', $this->AppController->viewBuilder()->getVars()['currentAdminTheme']);
}
+ /**
+ * test checkPermission
+ */
+ public function testCheckPermission()
+ {
+ //準備
+ $permissionsService = $this->getService(PermissionsServiceInterface::class);
+ $permissionsService->addCheck("/fuga", false);
+ $permissionsService->addCheck("/piyo", true);
+
+ Configure::write('BcApp.adminGroupId', 2);
+ $this->loginAdmin($this->getRequest('/'));
+
+ //result = false test
+ $this->AppController->setRequest($this->getRequest('/fuga'));
+ $this->assertFalse($this->execPrivateMethod($this->AppController, 'checkPermission', []));
+
+ //result = true test
+ $this->AppController->setRequest($this->getRequest('/piyo'));
+ $this->assertTrue($this->execPrivateMethod($this->AppController, 'checkPermission', []));
+ }
+
/**
* Test setupFrontView
*/
diff --git a/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php
index ae24866337..3dd4f271f3 100644
--- a/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php
+++ b/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php
@@ -12,11 +12,14 @@
namespace BaserCore\Test\TestCase\Controller;
use BaserCore\Controller\BcFrontAppController;
+use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Factory\PluginFactory;
+use BaserCore\Test\Factory\SiteFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainer;
-use Cake\Core\Configure;
+use Cake\Event\Event;
+use Cake\I18n\I18n;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
/**
@@ -87,7 +90,14 @@ public function testNotFound()
*/
public function testBeforeFilter()
{
- $this->markTestIncomplete('このテストはまだ実装されていません。');
+ //準備
+ ContentFactory::make(['url' => '/', 'site_id' => 2])->persist();
+ SiteFactory::make(['id' => 2, 'lang' => 'english'])->persist();
+ $this->BcFrontAppController->setRequest($this->loginAdmin($this->getRequest('/')));
+ //テスト
+ $this->BcFrontAppController->beforeFilter(new Event('Controller.beforeFilter', $this->BcFrontAppController));
+ //language check
+ $this->assertEquals('en', I18n::getLocale());
}
/**
@@ -95,14 +105,11 @@ public function testBeforeFilter()
*/
public function testBeforeRender()
{
- $this->markTestIncomplete('このテストはまだ実装されていません。');
- // TODO ucmitz 本体側の実装要
- /* >>>
- $this->BcFrontAppController->setRequest($this->getRequest('/en/サイトID3の固定ページ'));
+ $this->BcFrontAppController->setRequest($this->getRequest());
$this->BcFrontAppController->beforeRender(new Event('beforeRender'));
- $this->assertEquals('en', $this->BcFrontAppController->viewBuilder()->getLayoutPath());
- $this->assertEquals('en', $this->BcFrontAppController->viewBuilder()->getTemplatePath());
- <<< */
+ $viewBuilder = $this->BcFrontAppController->viewBuilder();
+ $this->assertEquals('BaserCore.BcFrontApp', $viewBuilder->getClassName());
+ $this->assertEquals('BcFront', $viewBuilder->getTheme());
}
}
diff --git a/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php
index e11edad2ad..5e5782f645 100644
--- a/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php
+++ b/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php
@@ -48,8 +48,22 @@ public function tearDown(): void
*/
public function testTmp()
{
- $this->markTestIncomplete('このテストは、まだ実装されていません。');
- $this->get('/baser/baser-core/uploads/tmp/medium/00000001_eyecatch_png');
+ mkdir(TMP . 'uploads');
+ touch(TMP . 'uploads/test.gif');
+ copy(ROOT . '/plugins/bc-admin-third/webroot/img/baser.power.gif', TMP . 'uploads/test.gif');
+
+ $this->session([
+ 'Upload.test_gif.data' => base64_encode(file_get_contents(TMP . 'uploads/test.gif')),
+ 'Upload.test_gif.type' => 'image/gif',
+ 'Upload.test_gif.imagecopy.medium' => ['width' => 100, 'height' => 100],
+ ]);
+
+ $this->get('/baser-core/uploads/tmp/thumb/test.gif');
+ $this->assertResponseSuccess();
+ $this->assertNotEmpty($this->_controller->getResponse()->getBody());
+
+ @unlink(TMP . 'uploads/test.gif');
+ rmdir(TMP . 'uploads');
}
/**
* セッションに保存した一時ファイルを出力する
diff --git a/plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php
new file mode 100644
index 0000000000..870d035a30
--- /dev/null
+++ b/plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php
@@ -0,0 +1,72 @@
+
+ * Copyright (c) NPO baser foundation