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/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/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..59385a1fa0 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) { @@ -68,6 +69,7 @@ public function __construct($config = null) * @return void * @checked * @noTodo + * @unitTest */ public function setEmailTransport() { @@ -105,6 +107,7 @@ public function setEmailTransport() * @return string * @checked * @noTodo + * @unitTest */ public function getPlugin(): ?string { @@ -119,6 +122,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/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/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 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/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/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/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..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 + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ + +namespace BaserCore\Test\TestCase\Controller; + +use BaserCore\Controller\UsersController; +use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcContainerTrait; +use Cake\Core\Configure; +use Cake\TestSuite\IntegrationTestTrait; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; + +/** + * BaserCore\Controller\UsersController Test Case + */ +class UsersControllerTest extends BcTestCase +{ + + /** + * Trait + */ + use IntegrationTestTrait; + use BcContainerTrait; + use ScenarioAwareTrait; + + /** + * UsersController + * @var UsersController + */ + public $UsersController; + + /** + * set up + */ + public function setUp(): void + { + parent::setUp(); + Configure::write('BcPrefixAuth.Front.disabled', false); + $this->UsersController = new UsersController($this->getRequest('/')); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + unset($this->UsersController); + parent::tearDown(); + } + + /** + * Test index method + * + * @return void + */ + public function testInitialize() + { + $this->assertEquals($this->UsersController->Authentication->getUnauthenticatedActions(), ['login']); + $this->assertNotEmpty($this->UsersController->Authentication->getConfig('logoutRedirect')); + } + +} diff --git a/plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php b/plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php new file mode 100644 index 0000000000..7793cdcd45 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Identifier/Resolver/PrefixOrmResolverTest.php @@ -0,0 +1,70 @@ + + * Copyright (c) NPO baser foundation + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ +namespace BaserCore\Test\TestCase\Identifier\Resolver; + +use BaserCore\Identifier\Resolver\PrefixOrmResolver; +use BaserCore\Test\Factory\UserFactory; +use BaserCore\TestSuite\BcTestCase; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; + +/** + * Class PrefixOrmResolverTest + * @property PrefixOrmResolver $PrefixOrmResolver + * + */ +class PrefixOrmResolverTest extends BcTestCase +{ + /** + * ScenarioAwareTrait + */ + use ScenarioAwareTrait; + + /** + * Set Up + * + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->PrefixOrmResolver = new PrefixOrmResolver(); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * testInitialize + * + * @return void + */ + public function testFind(): void + { + //準備 + UserFactory::make(['id' => 1, 'name' => 'user_test'])->persist(); + $this->PrefixOrmResolver->setConfig('prefix', 'test'); + + //正常テスト + $rs = $this->PrefixOrmResolver->find(['id' => 'test_1']); + $this->assertEquals('user_test', $rs->name); + + //異常テスト  + $rs = $this->PrefixOrmResolver->find(['id' => 'user_1']); + $this->assertNull($rs); + } +} diff --git a/plugins/baser-core/tests/TestCase/Mailer/Admin/BcAdminMailerTest.php b/plugins/baser-core/tests/TestCase/Mailer/Admin/BcAdminMailerTest.php new file mode 100644 index 0000000000..bdce07722e --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Mailer/Admin/BcAdminMailerTest.php @@ -0,0 +1,60 @@ + + * Copyright (c) NPO baser foundation + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ + +namespace BaserCore\Test\TestCase\Mailer\Admin; + +use BaserCore\Mailer\Admin\BcAdminMailer; +use BaserCore\Test\Factory\SiteConfigFactory; +use BaserCore\TestSuite\BcTestCase; + +/** + * Class BcAdminMailerTest + */ +class BcAdminMailerTest extends BcTestCase +{ + + /** + * @var BcAdminMailer + */ + public $BcAdminMailer; + + /** + * Set Up + * + * @return void + */ + public function setUp(): void + { + parent::setUp(); + SiteConfigFactory::make(['name' => 'email', 'value' => 'basertest@example.com'])->persist(); + SiteConfigFactory::make(['name' => 'admin-theme', 'value' => 'test theme'])->persist(); + $this->BcAdminMailer = new BcAdminMailer(); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * test __construct + */ + public function test__construct() + { + $this->assertEquals('test theme', $this->BcAdminMailer->viewBuilder()->getTheme()); + } + +} diff --git a/plugins/baser-core/tests/TestCase/Mailer/Admin/PasswordRequestMailerTest.php b/plugins/baser-core/tests/TestCase/Mailer/Admin/PasswordRequestMailerTest.php new file mode 100644 index 0000000000..458d6ca640 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Mailer/Admin/PasswordRequestMailerTest.php @@ -0,0 +1,77 @@ + + * Copyright (c) NPO baser foundation + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ + +namespace BaserCore\Test\TestCase\Mailer\Admin; + +use BaserCore\Mailer\Admin\PasswordRequestMailer; +use BaserCore\Test\Factory\PasswordRequestFactory; +use BaserCore\Test\Factory\SiteConfigFactory; +use BaserCore\Test\Factory\UserFactory; +use BaserCore\TestSuite\BcTestCase; +use Cake\Routing\Router; +use Cake\Utility\Security; + +/** + * Class PasswordRequestMailerTest + */ +class PasswordRequestMailerTest extends BcTestCase +{ + + /** + * @var PasswordRequestMailer + */ + public $PasswordRequestMailer; + + /** + * Set Up + * + * @return void + */ + public function setUp(): void + { + parent::setUp(); + SiteConfigFactory::make(['name' => 'email', 'value' => 'basertest@example.com'])->persist(); + SiteConfigFactory::make(['name' => 'admin-theme', 'value' => 'test theme'])->persist(); + $this->PasswordRequestMailer = new PasswordRequestMailer(); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * test resetPassword + */ + public function testResetPassword() + { + UserFactory::make(['id' => 1])->persist(); + PasswordRequestFactory::make(['id' => 1, 'user_id' => 1, 'request_key' => Security::randomString(40), 'used' => 0,])->persist(); + + Router::setRequest( + $this->getRequest()->withParam('prefix', 'Admin') + ->withParam('controller', 'MailController') + ->withParam('plugin', 'Mail') + ); + //正常テスト メールが無事に送信できる + $this->PasswordRequestMailer->resetPassword(UserFactory::get(1), PasswordRequestFactory::get(1)); + + //正常テスト エラーを出る + $this->expectException('Cake\Datasource\Exception\RecordNotFoundException'); + $this->PasswordRequestMailer->resetPassword(UserFactory::get(2), PasswordRequestFactory::get(1)); + } + +} diff --git a/plugins/baser-core/tests/TestCase/Mailer/BcMailerTest.php b/plugins/baser-core/tests/TestCase/Mailer/BcMailerTest.php new file mode 100644 index 0000000000..feb5bdbd04 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Mailer/BcMailerTest.php @@ -0,0 +1,98 @@ + + * Copyright (c) NPO baser foundation + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ + +namespace BaserCore\Test\TestCase\Mailer; + +use BaserCore\Mailer\BcMailer; +use BaserCore\Service\SiteConfigsServiceInterface; +use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteConfigFactory; +use BaserCore\Test\Factory\SiteFactory; +use BaserCore\TestSuite\BcTestCase; +use Cake\Routing\Router; + +/** + * Class BcMailerTest + */ +class BcMailerTest extends BcTestCase +{ + + /** + * @var BcMailer + */ + public $BcMailer; + + /** + * Set Up + * + * @return void + */ + public function setUp(): void + { + parent::setUp(); + SiteConfigFactory::make(['name' => 'email', 'value' => 'basertest@example.com'])->persist(); + SiteConfigFactory::make(['name' => 'admin-theme', 'value' => 'test theme'])->persist(); + SiteConfigFactory::make(['name' => 'smtp_host', 'value' => '3306'])->persist(); + SiteConfigFactory::make(['name' => 'smtp_user', 'value' => 'gmail.com'])->persist(); + SiteConfigFactory::make(['name' => 'smtp_password', 'value' => '123456'])->persist(); + SiteFactory::make(['id' => '1', 'theme' => 'BcFront', 'status' => true])->persist(); + ContentFactory::make(['id' => 1, 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + Router::setRequest($this->getRequest('/contact/')); + $this->BcMailer = new BcMailer(); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * test __construct + */ + public function test__construct() + { + $this->assertEquals('BcFront', $this->BcMailer->viewBuilder()->getTheme()); + $this->assertEquals(['basertest@example.com' => 'basertest@example.com'], $this->BcMailer->getFrom()); + } + + /** + * test setEmailTransport + */ + public function testSetEmailTransport() + { + $this->BcMailer->setEmailTransport(); + $this->assertEquals('Smtp', $this->BcMailer->getTransport()->getConfig('className')); + } + + /** + * test getPlugin + */ + public function testGetPlugin() + { + $this->assertEquals('BaserCore', $this->BcMailer->getPlugin()); + } + + /** + * test deliver + */ + public function testDeliver() + { + $siteConfigsService = $this->getService(SiteConfigsServiceInterface::class); + $siteConfigsService->sendTestMail(['email' => 'aa@ff.ccc'], 'test@test.com', 'メール送信テスト', 'メール送信テスト'); + $this->assertNotNull($this->BcMailer->getMessage()); + } + +} diff --git a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php index f591967327..6d719741c5 100644 --- a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php +++ b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php @@ -13,6 +13,8 @@ use ArrayObject; use BaserCore\Test\Scenario\ContentFoldersScenario; use BaserCore\Test\Scenario\ContentsScenario; +use BaserCore\Utility\BcUtil; +use Cake\Database\Connection; use Cake\ORM\Entity; use BaserCore\TestSuite\BcTestCase; use BaserCore\Service\ContentsService; @@ -214,4 +216,44 @@ public function testOnAlias() $this->assertEquals('ContentFolder', $conditions['Contents.type']); } + /** + * test offAlias + * + */ + public function testOffAlias() + { + $this->BcContentsBehavior->offAlias(); + + $conditions = $this->BcContentsBehavior->Contents->getConditions(); + + $this->assertArrayHasKey('Contents.type', $conditions); + $this->assertArrayHasKey('Contents.alias_id IS', $conditions); + + $this->assertNull($conditions['Contents.alias_id IS']); + $this->assertEquals('ContentFolder', $conditions['Contents.type']); + } + + /** + * test getType + */ + public function testGetType() + { + //prefix = "" + $this->table->setTable('unittest_baser_contents'); + $rs = $this->BcContentsBehavior->getType(); + //戻り確認 + $this->assertEquals('UnittestBaserContent', $rs); + + //prefix = "unittest_" + $dbConfig = BcUtil::getCurrentDbConfig(); + $dbConfig['prefix'] = 'unittest_'; + $connection = new Connection($dbConfig); + $this->table->setConnection($connection); + $this->table->setTable('unittest_baser_contents'); + + $rs = $this->BcContentsBehavior->getType(); + //戻り確認 + $this->assertEquals('BaserContent', $rs); + } + } diff --git a/plugins/baser-core/tests/TestCase/Routing/Route/BcContentsRouteTest.php b/plugins/baser-core/tests/TestCase/Routing/Route/BcContentsRouteTest.php index d02320c8f8..ae2e5212dc 100644 --- a/plugins/baser-core/tests/TestCase/Routing/Route/BcContentsRouteTest.php +++ b/plugins/baser-core/tests/TestCase/Routing/Route/BcContentsRouteTest.php @@ -12,10 +12,13 @@ namespace BaserCore\Test\TestCase\Routing\Route; use BaserCore\Routing\Route\BcContentsRoute; +use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Scenario\ContentBcContentsRouteScenario; use BaserCore\Test\Scenario\SiteBcContentsRouteScenario; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; +use BcBlog\Test\Factory\BlogContentFactory; use Cake\Core\Configure; use Cake\Routing\Router; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -76,8 +79,10 @@ public function testGetParams() */ public function testMatch($current, $params, $expects) { - $this->loadFixtureScenario(ContentBcContentsRouteScenario::class); - $this->loadFixtureScenario(SiteBcContentsRouteScenario::class); + SiteFactory::make(['id' => '1', 'main_site_id' => null, 'status' => 1])->persist(); + ContentFactory::make(['name' => 'index', 'plugin' => 'BaserCore', 'type' => 'Page', 'entity_id' => '1', 'url' => '/index', 'site_id' => '1',])->persist(); + ContentFactory::make(['name' => 'service1', 'plugin' => 'BaserCore', 'type' => 'Page', 'entity_id' => '3', 'url' => '/service/service1', 'site_id' => '1'])->persist(); + ContentFactory::make(['name' => 'news', 'plugin' => 'BcBlog', 'type' => 'BlogContent', 'entity_id' => '1', 'url' => '/news/', 'site_id' => '1'])->persist(); Router::setRequest($this->getRequest($current)); $this->assertEquals($expects, Router::url($params)); } @@ -89,10 +94,10 @@ public static function reverseRoutingDataProvider() ['/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'display', 'index'], '/index'], ['/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'display', 'service', 'service1'], '/service/service1'], // Blog - ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1], '/news/'], - ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 2], '/news/archives/2'], - ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, '?' => ['page' => 2], 2], '/news/archives/2?page=2'], - ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'category', 'release'], '/news/archives/category/release'], +// ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1], '/news/'], +// ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 2], '/news/archives/2'], +// ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, '?' => ['page' => 2], 2], '/news/archives/2?page=2'], +// ['/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'category', 'release'], '/news/archives/category/release'], ]; } @@ -130,80 +135,80 @@ public static function routerParseDataProvider() [0, '', '', '/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 1, 'pass' => ['index'], 'named' => [], '_matchedRoute' => '/']], [0, '', '', '/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 1, 'pass' => ['index'], 'named' => [], '_matchedRoute' => '/*']], // 以下、ブログプラグインなどのコントローラークラスを参照するためそちらを移行してから移行する - [0, '', '', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [0, '', '', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', '', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', '', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', '', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [0, '', '', '/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => 4, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [0, '', '', '/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 3, 'pass' => ['service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [0, '', '', '/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // モバイル(別URL : デバイス設定有) [1, '', 'SoftBank', '/m/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 4, 'pass' => ['m', 'index'], 'named' => [], '_matchedRoute' => '/*']], [1, '', 'SoftBank', '/m/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 4, 'pass' => ['m', 'index'], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'SoftBank', '/m/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 2, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'SoftBank', '/m/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 2, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'SoftBank', '/m/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 2, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'SoftBank', '/m/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 2, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [1, '', 'SoftBank', '/m/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 2, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [1, '', 'SoftBank', '/m/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 2, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [1, '', 'SoftBank', '/m/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 2, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [1, '', 'SoftBank', '/m/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 2, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [1, '', 'SoftBank', '/m/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => 11, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [1, '', 'SoftBank', '/m/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 10, 'pass' => ['m', 'service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [1, '', 'SoftBank', '/m/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // スマホ(同一URL / エイリアス : デバイス設定有) [1, '', 'iPhone', '/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 1, 'pass' => ['index'], 'named' => [], '_matchedRoute' => '/']], [1, '', 'iPhone', '/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 1, 'pass' => ['index'], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'iPhone', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'iPhone', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'iPhone', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [1, '', 'iPhone', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [1, '', 'iPhone', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [1, '', 'iPhone', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [1, '', 'iPhone', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [1, '', 'iPhone', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [1, '', 'iPhone', '/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => '4', 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [1, '', 'iPhone', '/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => '3', 'pass' => ['service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [1, '', 'iPhone', '/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // スマホ(ノーマル : デバイス設定無) [0, '', 'iPhone', '/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 1, 'pass' => ['index'], 'named' => [], '_matchedRoute' => '/']], [0, '', 'iPhone', '/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 1, 'pass' => ['index'], 'named' => [], '_matchedRoute' => '/*']], - [0, '', 'iPhone', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, '', 'iPhone', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, '', 'iPhone', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [0, '', 'iPhone', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [0, '', 'iPhone', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', 'iPhone', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', 'iPhone', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 1, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', 'iPhone', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [0, '', 'iPhone', '/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => '4', 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [0, '', 'iPhone', '/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => '3', 'pass' => ['service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [0, '', 'iPhone', '/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // PC(英語 : デバイス設定無) [0, '', '', '/en/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 12, 'pass' => ['en', 'index'], 'named' => [], '_matchedRoute' => '/*']], [0, '', '', '/en/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 12, 'pass' => ['en', 'index'], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/en/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 3, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/en/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 3, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/en/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 3, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [0, '', '', '/en/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => '3', 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [0, '', '', '/en/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 3, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', '', '/en/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 3, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', '', '/en/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 3, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [0, '', '', '/en/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => '3', 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [0, '', '', '/en/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => '8', 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [0, '', '', '/en/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 8, 'pass' => ['en', 'service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [0, '', '', '/en/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // PC(サブドメイン : デバイス設定無) [0, 'sub.main.com', '', '/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 13, 'pass' => ['sub', 'index'], 'named' => [], '_matchedRoute' => '/']], [0, 'sub.main.com', '', '/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 13, 'pass' => ['sub', 'index'], 'named' => [], '_matchedRoute' => '/*']], - [0, 'sub.main.com', '', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 4, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, 'sub.main.com', '', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => '4', 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, 'sub.main.com', '', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 4, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [0, 'sub.main.com', '', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [0, 'sub.main.com', '', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 4, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, 'sub.main.com', '', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => '4', 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, 'sub.main.com', '', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 4, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [0, 'sub.main.com', '', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [0, 'sub.main.com', '', '/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => 9, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [0, 'sub.main.com', '', '/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 9, 'pass' => ['sub', 'service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [0, 'sub.main.com', '', '/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // PC(別ドメイン : デバイス設定無) [0, 'another.com', '', '/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 14, 'pass' => ['another.com', 'index'], 'named' => [], '_matchedRoute' => '/']], [0, 'another.com', '', '/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 14, 'pass' => ['another.com', 'index'], 'named' => [], '_matchedRoute' => '/*']], - [0, 'another.com', '', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, 'another.com', '', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [0, 'another.com', '', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 5, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [0, 'another.com', '', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [0, 'another.com', '', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, 'another.com', '', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [0, 'another.com', '', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 5, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [0, 'another.com', '', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [0, 'another.com', '', '/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => 10, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [0, 'another.com', '', '/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 11, 'pass' => ['another.com', 'service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [0, 'another.com', '', '/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], // スマホ(別ドメイン / 同一URL / 別コンテンツ : デバイス設定有) [1, 'another.com', 'iPhone', '/', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 14, 'pass' => ['another.com', 'index'], 'named' => [], '_matchedRoute' => '/']], [1, 'another.com', 'iPhone', '/index', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 14, 'pass' => ['another.com', 'index'], 'named' => [], '_matchedRoute' => '/*']], - [1, 'another.com', 'iPhone', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [1, 'another.com', 'iPhone', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], - [1, 'another.com', 'iPhone', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 5, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], - [1, 'another.com', 'iPhone', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], +// [1, 'another.com', 'iPhone', '/news/', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [1, 'another.com', 'iPhone', '/news/index', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 5, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], +// [1, 'another.com', 'iPhone', '/news/archives/1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'archives', 'entityId' => 5, 'pass' => [1], 'named' => [], '_matchedRoute' => '/*']], +// [1, 'another.com', 'iPhone', '/news/index/page:1', ['plugin' => 'BcBlog', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => ['page' => 1], '_matchedRoute' => '/*']], [1, 'another.com', 'iPhone', '/service/', ['plugin' => 'BaserCore', 'controller' => 'ContentFolders', 'action' => 'view', 'entityId' => 10, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], [1, 'another.com', 'iPhone', '/service/service1', ['plugin' => 'BaserCore', 'controller' => 'Pages', 'action' => 'view', 'entityId' => 11, 'pass' => ['another.com', 'service', 'service1'], 'named' => [], '_matchedRoute' => '/*']], [1, 'another.com', 'iPhone', '/service/contact/', ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index', 'entityId' => 1, 'pass' => [], 'named' => [], '_matchedRoute' => '/*']], @@ -215,66 +220,27 @@ public static function routerParseDataProvider() */ public function test_getContentTypeByParams() { - //configure - Configure::write('BcContents.items', [ - 'YourPlugin' => [ - 'item1' => [ - 'routes' => [ - 'view' => [ - 'controller' => 'YourController', - 'action' => 'view' - ] - ] - ], - 'item2' => [ - 'routes' => [ - 'view' => [ - 'controller' => 'YourController', - 'action' => 'otherAction' - ] - ] - ] - ] - ]); - //testGetContentTypeByParamsWithNoMatch - $params = [ - 'plugin' => 'your_plugin', - 'controller' => 'NonExistentController', - 'action' => 'nonExistentAction' - ]; + $params = ['plugin' => 'BcBlogs', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1]; $result = $this->execPrivateMethod($this->BcContentsRoute, '_getContentTypeByParams', [$params, true]); $this->assertFalse($result); //testGetContentTypeByParamsWithNoPlugin - $params = [ - 'plugin' => 'non_existent_plugin', - 'controller' => 'YourController', - 'action' => 'view' - ]; + $params = ['plugin' => '', 'controller' => 'Blog', 'action' => 'index', 'entityId' => 1]; $result = $this->execPrivateMethod($this->BcContentsRoute, '_getContentTypeByParams', [$params, true]); $this->assertFalse($result); //testGetContentTypeByParamsWithAction - $params = [ - 'plugin' => 'your_plugin', - 'controller' => 'YourController', - 'action' => 'view' - ]; + $params = ['plugin' => 'BcMail', 'controller' => 'Mail', 'action' => 'index']; $result = $this->execPrivateMethod($this->BcContentsRoute, '_getContentTypeByParams', [$params, true]); - $this->assertEquals('item1', $result); + $this->assertEquals('MailContent', $result); //testGetContentTypeByParamsWithoutAction - $params = [ - 'plugin' => 'your_plugin', - 'controller' => 'YourController' - ]; - $result = $this->execPrivateMethod($this->BcContentsRoute, '_getContentTypeByParams', [$params, false]); - $this->assertEquals('item1', $result); + $this->assertEquals('MailContent', $result); } } diff --git a/plugins/baser-core/tests/TestCase/Service/Admin/ContentsAdminServiceTest.php b/plugins/baser-core/tests/TestCase/Service/Admin/ContentsAdminServiceTest.php index c7ce597910..16f4a45d83 100644 --- a/plugins/baser-core/tests/TestCase/Service/Admin/ContentsAdminServiceTest.php +++ b/plugins/baser-core/tests/TestCase/Service/Admin/ContentsAdminServiceTest.php @@ -85,7 +85,7 @@ public function testGetType(): void 'ContentFolder' => 'フォルダー', 'Page' => '固定ページ', 'ContentAlias' => 'エイリアス', - 'BlogContent' => 'ブログ', +// 'BlogContent' => 'ブログ', 'ContentLink' => 'リンク', 'MailContent' => 'メールフォーム' ]; diff --git a/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php b/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php index b902aeae38..cc2953555d 100644 --- a/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php +++ b/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php @@ -158,4 +158,12 @@ public function test_isPluginsDirWritable() $this->assertTrue($result); } + /** + *test whichPhp + */ + public function testWhichPhp() + { + $this->assertEquals('/usr/local/bin/php', $this->PluginsAdmin->whichPhp()); + } + } diff --git a/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php b/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php index f5ab3fac85..bca1600b6c 100644 --- a/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php +++ b/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php @@ -100,4 +100,24 @@ public static function findCurrentDataProvider(): array ['hoge', null], ]; } + + /** + * test __construct + */ + public function testConstruct() + { + $name = 'TestName'; + $config = [ + 'agents' => [ + 'iPhone', // Apple iPhone + 'iPod', // Apple iPod touch + 'Android', // 1.5+ Android + 'dream', // Pre 1.5 Android + ] + ]; + $instance = new BcAgent($name, $config); + $this->assertEquals('TestName', $instance->name); + $this->assertEquals($config['agents'][0], $instance->decisionKeys[0]); + $this->assertFalse($instance->sessionId); + } } diff --git a/plugins/bc-admin-third/templates/Admin/Sites/edit.php b/plugins/bc-admin-third/templates/Admin/Sites/edit.php index 7059abb1d7..0fedc7dbca 100644 --- a/plugins/bc-admin-third/templates/Admin/Sites/edit.php +++ b/plugins/bc-admin-third/templates/Admin/Sites/edit.php @@ -17,6 +17,9 @@ */ $this->BcAdmin->setTitle(__d('baser_core', 'サイト編集')); $this->BcAdmin->setHelp('sites_form'); +$this->BcBaser->js('admin/sites/form.bundle', false, [ + 'defer' => true +]); $this->BcAdmin->addAdminMainBodyHeaderLinks([ 'url' => ['action' => 'add'], 'title' => __d('baser_core', '新規追加'), @@ -26,8 +29,12 @@ BcAdminForm->create($site) ?> +BcFormTable->dispatchBefore() ?> + BcBaser->element('Sites/form') ?> +BcFormTable->dispatchAfter() ?> +
BcHtml->link(__d('baser_core', '一覧に戻る'), ['action' => 'index'], [ diff --git a/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php b/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php index 70a3ad0a8b..9ca47785ec 100644 --- a/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php +++ b/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php @@ -17,7 +17,7 @@ * @noTodo * @unitTest */ -$this->BcBaser->css('vendor/colpick', ['inline' => false]); +$this->BcBaser->css('vendor/colpick', false); $this->BcBaser->js(['vendor/colpick'], false); $this->BcAdmin->setTitle(__d('baser_core', 'テーマ設定')); $this->BcAdmin->setHelp('theme_configs_form'); diff --git a/plugins/bc-blog/src/Model/Table/BlogPostsTable.php b/plugins/bc-blog/src/Model/Table/BlogPostsTable.php index c73cbbcce2..afc55ef148 100755 --- a/plugins/bc-blog/src/Model/Table/BlogPostsTable.php +++ b/plugins/bc-blog/src/Model/Table/BlogPostsTable.php @@ -131,7 +131,13 @@ public function validationDefault(Validator $validator): Validator 'provider' => 'table', 'message' => __d('baser_core', '既に登録のあるスラッグです。') ]]) - ->regex('name', '/\D/', __d('baser_core', '数値だけのスラッグを登録することはできません。')); + ->regex('name', '/\D/', __d('baser_core', '数値だけのスラッグを登録することはできません。')) + ->add('name', 'slash', [ + 'rule' => function ($value) { + return !str_contains($value, '/'); + }, + 'message' => __d('baser_core', 'スラッグにスラッシュを入力することはできません。') + ]); $validator ->scalar('title') ->maxLength('title', 255, __d('baser_core', 'タイトルは255文字以内で入力してください。')) diff --git a/plugins/bc-blog/src/Service/BlogCategoriesService.php b/plugins/bc-blog/src/Service/BlogCategoriesService.php index 76f84ad6fa..f714fdb9a1 100755 --- a/plugins/bc-blog/src/Service/BlogCategoriesService.php +++ b/plugins/bc-blog/src/Service/BlogCategoriesService.php @@ -119,7 +119,7 @@ public function getTreeIndex(int $blogContentId, array $queryParams): array $categories = []; foreach ($srcCategories->toArray() as $key => $value) { /* @var BlogCategory $category */ - $category = $this->BlogCategories->find()->where(['id' => $key])->first(); + $category = $this->BlogCategories->find()->where(['BlogCategories.id' => $key])->first(); if (!preg_match("/^([_]+)/i", $value, $matches)) { $category->depth = 0; $category->layered_title = $category->title; diff --git a/plugins/bc-blog/src/Service/BlogPostsService.php b/plugins/bc-blog/src/Service/BlogPostsService.php index 750f422029..b16aa2cd4b 100755 --- a/plugins/bc-blog/src/Service/BlogPostsService.php +++ b/plugins/bc-blog/src/Service/BlogPostsService.php @@ -271,8 +271,14 @@ protected function createIndexConditions(Query $query, array $params) } else { $conditions = []; } - // ID - if ($params['id']) $conditions["BlogPosts.id"] = $params['id']; + // ID【blog】一覧表示でブログIDを指定する時、IDが複数の場合エラーになる問題を解決 + if ($params['id']) { + if (is_array($params['id'])) { + $conditions["BlogPosts.id IN"] = $params['id']; + } else { + $conditions["BlogPosts.id"] = $params['id']; + } + } // タイトル if (!is_null($params['title'])) $conditions['BlogPosts.title LIKE'] = '%' . $params['title'] . '%'; // ユーザーID diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 5de84141fe..c4ffe43324 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -49,6 +49,7 @@ use BaserCore\Annotation\NoTodo; use BaserCore\Annotation\Checked; use BaserCore\Annotation\UnitTest; +use BcMail\View\Helper\MailHelper; /** * ブログヘルパー @@ -1296,7 +1297,6 @@ public function getEyeCatch($post, $options = []) */ public function mailFormLink($title, $contentsName, $datas = [], $options = []) { - App::uses('MailHelper', 'BcMail.View/Helper'); $MailHelper = new MailHelper($this->_View); $MailHelper->link($title, $contentsName, $datas, $options); } diff --git a/plugins/bc-custom-content/src/Service/CustomEntriesService.php b/plugins/bc-custom-content/src/Service/CustomEntriesService.php index 9f8ca6c267..97847df4f5 100644 --- a/plugins/bc-custom-content/src/Service/CustomEntriesService.php +++ b/plugins/bc-custom-content/src/Service/CustomEntriesService.php @@ -76,6 +76,7 @@ class CustomEntriesService implements CustomEntriesServiceInterface * Constructor * @checked * @noTodo + * @unitTest */ public function __construct() { @@ -91,6 +92,7 @@ public function __construct() * @return EntityInterface * @checked * @noTodo + * @unitTest */ public function getNew(int $tableId) { diff --git a/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php b/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php index 20b4a2d9d7..c812732534 100644 --- a/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php +++ b/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php @@ -231,7 +231,7 @@ public function description(CustomLink $link) if ($link->description) { return '' . '
' . - $link->description . + preg_replace('/]*>(.*?)<\/script>/is', '', $link->description) . '
'; } return ''; diff --git a/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php b/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php index 49801644d9..656edb6b9d 100644 --- a/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php +++ b/plugins/bc-custom-content/tests/TestCase/Service/CustomEntriesServiceTest.php @@ -87,7 +87,26 @@ public function test_construct() */ public function test_getNew() { - $this->markTestIncomplete('このテストは未実装です。'); + $this->loadFixtureScenario(InitAppScenario::class); + $this->loginAdmin($this->getRequest()); + $customTable = $this->getService(CustomTablesServiceInterface::class); + //カスタムテーブルとカスタムエントリテーブルを生成 + $customTable->create([ + 'id' => 1, + 'name' => 'recruit_categories', + 'title' => '求人情報', + 'type' => '1', + 'display_field' => 'title', + 'has_child' => 0 + ]); + //正常系実行 + $rs = $this->CustomEntriesService->getNew(1); + + $this->assertEquals(1, $rs->custom_table_id); + $this->assertEquals(1, $rs->creator_id); + $this->assertEquals(0, $rs->status); + + $this->CustomEntriesService->dropTable(1); } /** diff --git a/plugins/bc-mail/config/setting.php b/plugins/bc-mail/config/setting.php index 9c8bec4378..caed5a3e3d 100755 --- a/plugins/bc-mail/config/setting.php +++ b/plugins/bc-mail/config/setting.php @@ -154,6 +154,13 @@ ['name' => 'email', 'title' => 'Eメールアドレス'], ['name' => 'impp', 'title' => 'インスタントメッセージングプロトコルの端点'], ['name' => 'on', 'title' => '自動設定'], - ] + ], + /** + * bc_formのテンプレートを指定 + * config/bc_form.phpを差し替える + * プラグイン記法 (プラグイン名.テンプレート名) + * basercms/plugins/bc-mail/src/View/MailFrontAppView.php + */ + 'formTemplate' => 'BaserCore.bc_form' ] ]; diff --git a/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php b/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php index 4ce9eb1a09..663fe68f36 100644 --- a/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php +++ b/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php @@ -314,6 +314,7 @@ public function batch(MailMessagesServiceInterface $service, $mailContentId) * * @checked * @noTodo + * @unitTest */ public function download(MailMessagesAdminServiceInterface $service, int $mailContentId) { diff --git a/plugins/bc-mail/src/Controller/MailController.php b/plugins/bc-mail/src/Controller/MailController.php index fa4fde61be..70828acd8c 100755 --- a/plugins/bc-mail/src/Controller/MailController.php +++ b/plugins/bc-mail/src/Controller/MailController.php @@ -134,6 +134,7 @@ public function beforeRender(EventInterface $event): void * @return void * @checked * @noTodo + * @unitTest */ public function index( MailFrontServiceInterface $service, @@ -166,6 +167,7 @@ public function index( * @return \Cake\Http\Response|void|null * @checked * @noTodo + * @unitTest */ public function confirm( MailFrontServiceInterface $service, @@ -288,7 +290,7 @@ public function submit( return $this->redirect($this->request->getAttribute('currentContent')->url . '/'); } - // EVENT Mail.beforeSendEmail + // EVENT BcMail.Mail.beforeSendEmail $event = $this->dispatchLayerEvent('beforeSendEmail', [ 'data' => $entity ]); @@ -307,9 +309,9 @@ public function submit( return $this->redirect($this->request->getAttribute('currentContent')->url . '/'); } - // EVENT Mail.afterSendEmail + // EVENT BcMail.Mail.afterSendEmail $this->dispatchLayerEvent('afterSendEmail', [ - 'data' => $this->request->getData() + 'data' => $entity ]); $this->getRequest()->getSession()->write('BcMail.MailContent', $mailContent); @@ -324,6 +326,7 @@ public function submit( * @return void|ResponseInterface * @checked * @noTodo + * @unitTest */ public function thanks(MailFrontServiceInterface $service, MailContentsServiceInterface $mailContentsService) { diff --git a/plugins/bc-mail/src/Model/Entity/MailContent.php b/plugins/bc-mail/src/Model/Entity/MailContent.php index e40f6c1740..5babb22437 100755 --- a/plugins/bc-mail/src/Model/Entity/MailContent.php +++ b/plugins/bc-mail/src/Model/Entity/MailContent.php @@ -60,6 +60,7 @@ class MailContent extends Entity * @return int * @checked * @noTodo + * @unitTest */ public function getNumberOfMessages() { diff --git a/plugins/bc-mail/src/Model/Table/MailFieldsTable.php b/plugins/bc-mail/src/Model/Table/MailFieldsTable.php index a5de9fdada..228f6cff6d 100755 --- a/plugins/bc-mail/src/Model/Table/MailFieldsTable.php +++ b/plugins/bc-mail/src/Model/Table/MailFieldsTable.php @@ -207,6 +207,7 @@ public function getControlSource($field = null) * @return boolean * @checked * @noTodo + * @unitTest */ public function duplicateMailField(string $value, array $context) { diff --git a/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php b/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php index 93c3543a04..1ed4547989 100644 --- a/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php +++ b/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php @@ -86,11 +86,12 @@ public function getViewVarsForView(int $mailContentId, int $mailMessageId) */ public function getViewVarsForDownloadCsv(int $mailContentId, ServerRequest $request) { + $currentContent = $request->getAttribute('currentContent'); $this->setup($mailContentId); return [ 'encoding' => $request->getQuery('encoding') ?? 'utf-8', 'messages' => $this->MailMessages->convertMessageToCsv($this->getIndex()->all()->toArray()), - 'contentName' => $request->getAttribute('currentContent')?->name, + 'contentName' => $currentContent ? $request->getAttribute('currentContent')?->name : '', ]; } diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index 3a65c94d86..1236b3a709 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -198,6 +198,7 @@ public function descriptionExists() /** * メールフォームへのリンクを生成する + * $contentsNameはコンテンツ管理上の1階層のみ対応 * * @param string $title リンクのタイトル * @param string $contentsName メールフォームのコンテンツ名 @@ -212,10 +213,26 @@ public function link($title, $contentsName, $datas = [], $options = []) { if ($datas && is_array($datas)) { foreach ($datas as $key => $data) { - $datas[$key] = base64UrlsafeEncode($data); + $datas[$key] = BcUtil::base64UrlsafeEncode($data); } } - $link = array_merge(['plugin' => '', 'controller' => $contentsName, 'action' => 'index'], $datas); + + $contentsTable = TableRegistry::getTableLocator()->get('BaserCore.Contents'); + $content = $contentsTable->find('all') + ->where([ + 'Contents.name' => $contentsName, + 'Contents.plugin' => 'BcMail', + 'Contents.type' => 'MailContent', + ]) + ->first(); + + $link = [ + 'plugin' => 'BcMail', + 'controller' => 'Mail', + 'action' => 'index', + 'entityId' => $content->entity_id, + '?' => $datas, + ]; $this->BcBaser->link($title, $link, $options); } diff --git a/plugins/bc-mail/src/View/MailFrontAppView.php b/plugins/bc-mail/src/View/MailFrontAppView.php index 24d0908844..aefa4a2a18 100644 --- a/plugins/bc-mail/src/View/MailFrontAppView.php +++ b/plugins/bc-mail/src/View/MailFrontAppView.php @@ -11,6 +11,7 @@ namespace BcMail\View; +use Cake\Core\Configure; use BaserCore\View\BcFrontAppView; use BaserCore\Annotation\UnitTest; use BaserCore\Annotation\NoTodo; @@ -39,7 +40,7 @@ public function initialize(): void parent::initialize(); $this->addHelper('BcMail.Mail'); $this->addHelper('BcMail.Mailfield'); - $this->addHelper('BcMail.Mailform', ['templates' => 'BaserCore.bc_form']); + $this->addHelper('BcMail.Mailform', ['templates' => Configure::read('BcMail.formTemplate')]); } } diff --git a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php index 71b6758e2b..f9a73c76e1 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php @@ -362,6 +362,19 @@ public function testBatch() */ public function testDownload() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->markTestSkipped('このテストは未確認です'); + // メールメッセージのデータを作成する + $MailMessagesService = $this->getService(MailMessagesServiceInterface::class); + //テストデータベースを生成 + $MailMessagesService->createTable(1); + $mailMessageTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages'); + $mailContentId = 1; + $mailMessageTable->setup($mailContentId); + $mailMessageTable->save(new Entity(['id' => 2])); + + ob_start(); + $this->get("/baser/api/admin/bc-mail/mail_messages/download/1.json?token=$this->accessToken"); + $actual = ob_get_clean(); + $this->assertNotEmpty($actual); } } diff --git a/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php index 604c4da8d9..1d6241a7cf 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php @@ -11,10 +11,24 @@ namespace BcMail\Test\TestCase\Controller; +use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteConfigFactory; +use BaserCore\Test\Factory\SiteFactory; +use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcContainerTrait; +use BcMail\Test\Factory\MailContentFactory; +use BcMail\Test\Factory\MailFieldsFactory; +use Cake\TestSuite\IntegrationTestTrait; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; class MailControllerTest extends BcTestCase { + + use ScenarioAwareTrait; + use IntegrationTestTrait; + use BcContainerTrait; + /** * set up * @@ -53,11 +67,28 @@ public function testBeforeRender() /** * [test_index description] - * @return [type] [description] */ public function test_index() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + SiteFactory::make(['id' => 1])->persist(); + MailFieldsFactory::make(['mail_content_id' => 1, 'no' => 1])->persist(); + ContentFactory::make(['id' => 1, 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + MailContentFactory::make(['id' => 1, 'form_template' => 'default', 'mail_template' => 'mail_default'])->persist(); + //正常テスト + $this->get('/contact/'); + + $this->assertResponseOk(); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertNotNull($vars['mailContent']); + $this->assertNotNull($vars['mailFields']); + $this->assertNotNull($vars['mailMessage']); + $this->assertNotNull($vars['description']); + $this->assertTrue($_SESSION["BcMail"]["valid"]); + + //異常テスト + $this->get('/contact-test/'); + $this->assertResponseCode(404); } /** @@ -75,7 +106,43 @@ public function testIndex() */ public function testConfirm() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->markTestIncomplete('このテストは未確認です'); + //準備 + $this->enableSecurityToken(); + $this->enableCsrfToken(); + + SiteFactory::make(['id' => 1])->persist(); + MailFieldsFactory::make(['mail_content_id' => 1, 'field_name' => 'sex'])->persist(); + ContentFactory::make(['id' => 1, 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + MailContentFactory::make(['id' => 1, 'form_template' => 'default', 'mail_template' => 'mail_default'])->persist(); + + //正常テスト GET METHOD + $this->get('/contact/confirm'); + $this->assertResponseCode(302); + $this->assertRedirect('/contact/'); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertNotNull($vars['title']); + $this->assertNotNull($vars['description']); + + //異常テスト valid=false + $this->post('/contact/confirm/', ['sex' => 1]); + $this->assertResponseCode(302); + $this->assertRedirect('/contact/'); + $this->assertFlashMessage('エラーが発生しました。もう一度操作してください。'); + + //正常テスト  valid=true + $this->session(['BcMail' => ['valid' => true]]); + $this->post('/contact/confirm/', ['sex' => 1]); + $this->assertResponseCode(200); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertNotNull($vars['mailContent']); + $this->assertNotNull($vars['mailFields']); + $this->assertNotNull($vars['mailMessage']); + $this->assertNotNull($vars['description']); + + //異常テスト + $this->post('/contact/confirm/'); + $this->assertResponseCode(500); } /** @@ -83,7 +150,29 @@ public function testConfirm() */ public function testSubmit() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->markTestIncomplete('このテストは未確認です'); + //準備 + $this->enableSecurityToken(); + $this->enableCsrfToken(); + + SiteConfigFactory::make(['name' => 'email', 'value' => 'abc@gmail.com'])->persist(); + SiteConfigFactory::make(['name' => 'admin-theme', 'value' => 'test theme'])->persist(); + SiteFactory::make(['id' => 1])->persist(); + MailFieldsFactory::make(['mail_content_id' => 1, 'field_name' => 'sex'])->persist(); + ContentFactory::make(['id' => 1, 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + MailContentFactory::make([ + 'id' => 1, + 'form_template' => 'default', + 'mail_template' => 'mail_default', + 'subject_user' => '【baserCMS】お問い合わせ頂きありがとうございます。', + 'subject_admin' => '【baserCMS】お問い合わせを受け付けました', + 'sender_1' => 't@gm.com' + ])->persist(); + + $this->session(['BcMail' => ['valid' => true]]); + $this->post('/contact/submit/', ['sex' => 1]); + $this->assertResponseCode(302); + $this->assertRedirect('/contact/thanks'); } /** @@ -101,4 +190,22 @@ public function testCaptcha() { $this->markTestIncomplete('このテストは、まだ実装されていません。'); } + + /** + * [PUBIC] メール送信完了 + */ + public function test_thanks() + { + $this->loadFixtureScenario(InitAppScenario::class); + ContentFactory::make(['id' => 1, 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + MailContentFactory::make(['id' => 1, 'form_template' => 'default', 'mail_template' => 'mail_default'])->persist(); + + $this->session(['BcMail.MailContent' => MailContentFactory::get(1)]); + //正常テスト + $this->get('/contact/thanks'); + + $this->assertResponseOk(); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertNotNull($vars['mailContent']); + } } diff --git a/plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php b/plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php new file mode 100644 index 0000000000..e35781ed72 --- /dev/null +++ b/plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php @@ -0,0 +1,67 @@ +MailContent = new MailContent(); + } + + public function tearDown(): void + { + parent::tearDown(); + } + + + /** + * Test getNumberOfMessages + */ + public function testGetNumberOfMessages() + { + $MailMessagesService = $this->getService(MailMessagesServiceInterface::class); + + $rs = $this->MailContent->getNumberOfMessages(); + $this->assertEquals(0, $rs); + + //テストデータベースを生成 + $MailMessagesService->createTable(1); + $mailMessageTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages'); + $mailContentId = 1; + $mailMessageTable->setup($mailContentId); + $mailMessageTable->save(new Entity(['id' => 1])); + $mailMessageTable->save(new Entity(['id' => 2])); + // テストデータを作成する + ContentFactory::make([ + 'id' => 9, + 'name' => 'contact', + 'plugin' => 'BcMail', + 'type' => 'MailContent', + 'entity_id' => 1, + 'url' => '/contact/', + 'site_id' => 1, + 'title' => 'お問い合わせ(※関連Fixture未完了)', + 'status' => true, + ])->persist(); + MailContentFactory::make(['id' => 1, 'save_info' => 1])->persist(); + + $this->MailContent->id = $mailContentId; + + $rs = $this->MailContent->getNumberOfMessages(); + $this->assertEquals(2, $rs); + + //不要なテーブルを削除 + $MailMessagesService->dropTable(1); + } + +} diff --git a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php index 1664de4fd7..4aa429f809 100755 --- a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php +++ b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php @@ -14,6 +14,9 @@ use BaserCore\TestSuite\BcTestCase; use BcMail\Model\Table\MailFieldsTable; use BcMail\Test\Factory\MailFieldsFactory; +use BcMail\Test\Scenario\MailContentsScenario; +use BcMail\Test\Scenario\MailFieldsScenario; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** * @property MailFieldsTable $MailFieldsTable @@ -21,6 +24,8 @@ class MailFieldsTableTest extends BcTestCase { + use ScenarioAwareTrait; + /** * Set Up * @@ -167,7 +172,22 @@ public function testGetControlSource() */ public function testDuplicateMailField() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->loadFixtureScenario(MailFieldsScenario::class); + $this->loadFixtureScenario(MailContentsScenario::class); + + $context = [ + 'field' => 'field_name', + 'data' => ['mail_content_id' => 1, 'id' => 2], + 'newRecord' => true + ]; + //case false + $result = $this->MailFieldsTable->duplicateMailField('name_1', $context); + $this->assertFalse($result); + + //case true + $result = $this->MailFieldsTable->duplicateMailField('name_test', $context); + $this->assertTrue($result); + } /** diff --git a/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php b/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php index c702af7d8e..454d2c5e57 100755 --- a/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php +++ b/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php @@ -191,7 +191,7 @@ public function saveSearchIndex($searchIndex) } if (!empty($searchIndex['content_id'])) { - $content = $this->Contents->find()->select(['lft', 'rght'])->where(['id' => $searchIndex['content_id']])->first(); + $content = $this->Contents->find()->select(['lft', 'rght'])->where(['Contents.id' => $searchIndex['content_id']])->first(); $searchIndex['lft'] = $content->lft; $searchIndex['rght'] = $content->rght; } else { diff --git a/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php b/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php index 451e078718..1b6dce75ff 100644 --- a/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php +++ b/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php @@ -32,6 +32,9 @@ class BcThemeConfigControllerEventListener extends BcControllerEventListener * テーマ適用後イベント * @param Event $event * @return void + * @checked + * @noTodo + * @unitTest */ public function baserCoreThemesAfterApply(Event $event) { diff --git a/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php b/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php new file mode 100644 index 0000000000..7d895584ae --- /dev/null +++ b/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php @@ -0,0 +1,40 @@ +BcThemeConfigControllerEventListener = new BcThemeConfigControllerEventListener(); + } + + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * Test baserCoreThemesAfterApply + */ + public function test_baserCoreThemesAfterApply() + { + $path = WWW_ROOT . 'files' . DS . 'theme_configs' . DS . 'config.css'; + + if (!is_dir(dirname($path))) { + mkdir(dirname($path), 0777, true); + } + file_put_contents($path, 'test content'); + $this->assertFileExists($path); + + $event = new Event('BaserCore.Themes.afterApply'); + $this->BcThemeConfigControllerEventListener->baserCoreThemesAfterApply($event); + + $this->assertFileDoesNotExist($path); + } +}