diff --git a/.gitignore b/.gitignore
index 3fe0c16511..3adc23e451 100644
--- a/.gitignore
+++ b/.gitignore
@@ -131,6 +131,8 @@ node_modules
# db
/db/*
!/db/.gitkeep
+# profiler
+/profiler/*
# etc
LOCAL_TODO.md
LOCAL_Q&A.md
diff --git a/composer.json b/composer.json
index 068053b3f7..9e0246e601 100644
--- a/composer.json
+++ b/composer.json
@@ -108,23 +108,23 @@
}
},
"replace": {
- "baserproject/baser-core": "5.1.2",
- "baserproject/bc-admin-third": "5.1.2",
- "baserproject/bc-blog": "5.1.2",
- "baserproject/bc-column": "5.1.2",
- "baserproject/bc-content-link": "5.1.2",
- "baserproject/bc-custom-content": "5.1.2",
- "baserproject/bc-editor-template": "5.1.2",
- "baserproject/bc-favorite": "5.1.2",
- "baserproject/bc-front": "5.1.2",
- "baserproject/bc-installer": "5.1.2",
- "baserproject/bc-mail": "5.1.2",
- "baserproject/bc-plugin-sample": "5.1.2",
- "baserproject/bc-search-index": "5.1.2",
- "baserproject/bc-theme-config": "5.1.2",
- "baserproject/bc-theme-file": "5.1.2",
- "baserproject/bc-theme-sample": "5.1.2",
- "baserproject/bc-uploader": "5.1.2",
- "baserproject/bc-widget-area": "5.1.2"
+ "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"
}
}
diff --git a/plugins/baser-core/VERSION.txt b/plugins/baser-core/VERSION.txt
index 7c36643021..9aa994355a 100644
--- a/plugins/baser-core/VERSION.txt
+++ b/plugins/baser-core/VERSION.txt
@@ -1,4 +1,4 @@
-5.1.3
+5.1.4
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
@@ -14,6 +14,25 @@
CHG: 変更内容 / BUG: バグフィックス / NEW: 機能追加
+[2024-10-24] basercms-5.1.3
+- NEW [BC] さくらのVPSのSSLに対応
+- CHG [BC] baserCMS4系で使用していたときのパスワードが引き継げない問題を解決
+- BUG [BC] プラグイン一覧に開発者の表記にbrタグが入ってる問題を調整
+- BUG [BC] 初期ユーザー以外のシステム管理ユーザーは自分のユーザー情報を編集しようとすると運営ユーザーしか選択できなくなる問題を解決
+- BUG [BC] 利用可能バージョンの取得処理を調整
+- BUG [BC] サブフォルダ環境でログイン時のリダイレクト先が間違っている問題を改善
+- BUG [BC] 固定ページをエレメントとして読み込めない問題を改善
+- BUG [BC] メインサイトの管理画面からサブサイト記事にアクセスするとURLが正しく生成されない問題を解消
+- BUG [BC] カスタムコンテンツ:エラーメッセージに情報不足な部分がある問題を改善
+- BUG [BC] メインサイトでブログのエイリアスを作成すると、Blog->Posts()で呼び出された記事のURLがすべて1つ目のエイリアスのURLになってしまう問題を改善
+- BUG [BC] SitesTable::findByUrl() の判定を調整
+- BUG [BC] サブサイト(独自ドメイン)で作成したページがエイリアス付きサブサイトと混同される問題を改善
+- BUG [BC] カスタムコンテンツにてファイル項目を含むエントリーをプレビュー時にエラーとなる問題を改善
+- BUG [BC] エディタをなしに設定しても、ブログ記事の編集画面でCKEditorが選択されてしまう問題を改善
+- 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/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..f23deb8969 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,42 +194,66 @@ 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) {
Configure::write('App.paths.plugins', array_merge(
Configure::read('App.paths.plugins'),
@@ -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/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..4939ffcada 100644
--- a/plugins/baser-core/src/Controller/BcFrontAppController.php
+++ b/plugins/baser-core/src/Controller/BcFrontAppController.php
@@ -73,6 +73,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/Model/Behavior/BcContentsBehavior.php b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php
index 8bfe6cb5b0..13d1346b8d 100644
--- a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php
+++ b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php
@@ -86,6 +86,7 @@ public function getType(): string
* アソシエーション時に alias を除外する
* @checked
* @noTodo
+ * @unitTest
*/
public function offAlias(): void
{
@@ -99,6 +100,7 @@ public function offAlias(): void
* アソシエーション時に alias を含める
* @checked
* @noTodo
+ * @unitTest
*/
public function onAlias(): void
{
diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php
index 8968817f53..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');
@@ -1221,7 +1221,7 @@ public function getRelatedSiteContents(int $id, array $options = []): array
['Sites.status' => true]
];
if ($options['excludeIds']) {
- $conditions['Contents.site_id <>'] = $options['excludeIds'];
+ $conditions['Contents.site_id NOT IN'] = $options['excludeIds'];
}
$conditions = array_merge($conditions, $this->getConditionAllowPublish());
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/PluginsAdminService.php b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php
index 4cedbe29c0..6c56864554 100644
--- a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php
+++ b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php
@@ -206,6 +206,7 @@ public function getViewVarsForAdd()
* @return bool
* @checked
* @noTodo
+ * @unitTest
*/
public function isPluginsDirWritable()
{
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/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/BcContentsHelper.php b/plugins/baser-core/src/View/Helper/BcContentsHelper.php
index e7c1a068b7..37425ee5d5 100644
--- a/plugins/baser-core/src/View/Helper/BcContentsHelper.php
+++ b/plugins/baser-core/src/View/Helper/BcContentsHelper.php
@@ -279,6 +279,7 @@ public function getCurrentRelatedSiteUrl($siteName)
* - `siteId` : サイトID
* @checked
* @noTodo
+ * @unitTest
*/
public function getTree(int $id = 1, ?int $level = null, array $options = []): ResultSetDecorator
{
@@ -402,6 +403,9 @@ public function getRelatedSiteContents(?int $id = null, array $options = []): ar
*
* @param int $id
* @return array
+ * @noTodo
+ * @checked
+ * @unitTest
*/
public function getRelatedSiteLinks($id = null, $options = [])
{
diff --git a/plugins/baser-core/src/View/Helper/BcFreezeHelper.php b/plugins/baser-core/src/View/Helper/BcFreezeHelper.php
index 66f1ab46cb..cd2a4f5ef3 100755
--- a/plugins/baser-core/src/View/Helper/BcFreezeHelper.php
+++ b/plugins/baser-core/src/View/Helper/BcFreezeHelper.php
@@ -68,7 +68,7 @@ public function text(string $fieldName, array $options = []): string
$field = $fieldName;
}
if (isset($options)) {
- $options = $options + ['type' => 'hidden'];
+ $options = array_merge($options, ['type' => 'hidden']);
} else {
$options = ['type' => 'hidden'];
}
@@ -349,7 +349,11 @@ public function textarea($fieldName, $options = []): string
} else {
$field = $fieldName;
}
- $options = $options + ['type' => 'hidden'];
+ if (isset($options)) {
+ $options = array_merge($options, ['type' => 'hidden']);
+ } else {
+ $options = ['type' => 'hidden'];
+ }
if (isset($options["value"])) {
$value = $options["value"];
} else {
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..07516be77a 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;
diff --git a/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php b/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php
index c1a471b2f7..1eb5afb4b8 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.3.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..04d3f25028
--- /dev/null
+++ b/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php
@@ -0,0 +1,32 @@
+command = new SetupTestCommand();
+ }
+
+ public function tearDown(): void
+ {
+ parent::tearDown();
+ }
+
+ public function testExecute()
+ {
+ $args = new Arguments([], [], []);
+ $io = new ConsoleIo();
+ $this->command->execute($args, $io);
+ $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..02af962119 100644
--- a/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php
+++ b/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php
@@ -17,6 +17,7 @@
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainer;
use Cake\Core\Configure;
+use Cake\Event\Event;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
/**
@@ -95,14 +96,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