diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index d33f803a04..8bbf335481 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -915,8 +915,9 @@ public function hasNextLink($post) * @return array ブログテンプレート一覧 * @checked * @noTodo + * @unitTest */ - public function getBlogTemplates($siteId = 0) + public function getBlogTemplates($siteId = 1) { $templatesPaths = BcUtil::getFrontTemplatePaths($siteId, 'BcBlog'); $_templates = []; diff --git a/plugins/bc-blog/tests/TestCase/Controller/BlogControllerTest.php b/plugins/bc-blog/tests/TestCase/Controller/BlogControllerTest.php index 42ff155dce..8497fa4e71 100755 --- a/plugins/bc-blog/tests/TestCase/Controller/BlogControllerTest.php +++ b/plugins/bc-blog/tests/TestCase/Controller/BlogControllerTest.php @@ -16,6 +16,7 @@ use BaserCore\Test\Factory\SiteConfigFactory; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcFile; +use BaserCore\Utility\BcFolder; use BcBlog\Controller\BlogController; use BcBlog\Service\BlogContentsServiceInterface; use BcBlog\Service\BlogPostsServiceInterface; @@ -96,17 +97,17 @@ public function test_index() 'description' => 'description test 1'])->persist(); BlogPostFactory::make(['id' => '1', 'blog_content_id' => '1', 'title' => 'blog post'])->persist(); ContentFactory::make(['plugin' => 'BcBlog', - 'entity_id' => 1, + 'entity_id' => 1, 'status' => true, 'lft' => 1, 'rght' => 2, 'type' => 'BlogContent']) ->treeNode(1, 1, null, 'test', '/test/', 1, true)->persist(); $fullPath = BASER_PLUGINS . 'bc-front/templates/Blog/Blog/default'; - if (!file_exists($fullPath)){ + if (!file_exists($fullPath)) { mkdir($fullPath, recursive: true); } - $file = new BcFile($fullPath .DS. 'index.php'); + $file = new BcFile($fullPath . DS . 'index.php'); $file->write('html'); //正常系実行 $request = $this->getRequest()->withAttribute('currentContent', ContentFactory::get(1)); @@ -117,8 +118,12 @@ public function test_index() $controller->index($blogFrontService, $blogContentsService, $blogPostsService); $vars = $controller->viewBuilder()->getVars(); - unlink($fullPath.DS.'index.php'); + unlink($fullPath . DS . 'index.php'); $this->assertEquals('description test 1', $vars['blogContent']->description); + + //不要フォルダを削除 + (new BcFolder(BASER_PLUGINS . 'bc-front/templates/Blog'))->delete(); + //異常系実行 $request = $this->getRequest()->withAttribute('currentContent', null); $controller = new BlogController($request); diff --git a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php index 1e378238e1..ecf49a7f5d 100755 --- a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php +++ b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php @@ -12,6 +12,7 @@ namespace BcBlog\Test\TestCase\View\Helper; use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteConfigFactory; use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\Test\Scenario\RootContentScenario; @@ -27,7 +28,6 @@ use BcBlog\Test\Factory\BlogTagFactory; use BcBlog\Test\Scenario\BlogContentScenario; use BcBlog\Test\Scenario\BlogTagsScenario; -use BcBlog\Test\Scenario\MultiBlogPostScenario; use BcBlog\Test\Scenario\MultiSiteBlogPostScenario; use BcBlog\Test\Scenario\MultiSiteBlogScenario; use BcBlog\View\BlogFrontAppView; @@ -703,28 +703,6 @@ public function test_hasNextLink() $this->Blog->hasNextLink(BlogPostFactory::get(111)); } - /** - * ブログテンプレートを取得 - * - * @param string $theme テーマ名 - * @param array $expected 期待値 - * @dataProvider getBlogTemplatesDataProvider - */ - public function testGetBlogTemplates($theme, $expected) - { - $this->markTestIncomplete('こちらのテストはまだ未確認です'); - $this->Blog->BcBaser->siteConfig['theme'] = $theme; - $result = $this->Blog->getBlogTemplates(); - $this->assertEquals($result, $expected, 'ブログテンプレートを正しく取得できません'); - } - - public static function getBlogTemplatesDataProvider() - { - return [ - ['nada-icons', ['default' => 'default']] - ]; - } - /** * 次の記事へのリンクを出力する * @param int $blogContentId ブログコンテンツID @@ -754,6 +732,30 @@ public static function nextLinkDataProvider() ]; } + /** + * ブログテンプレートを取得 + * + * @param string $theme テーマ名 + * @param array $expected 期待値 + * @dataProvider getBlogTemplatesDataProvider + */ + public function testGetBlogTemplates($theme, $expected) + { + SiteFactory::make([ + 'id' => 1, + 'theme' => $theme + ])->persist(); + $result = $this->Blog->getBlogTemplates(); + $this->assertEquals($expected, $result); + } + + public static function getBlogTemplatesDataProvider() + { + return [ + ['BcThemeSample', ['default' => 'default']] + ]; + } + /** * 公開状態を取得する */ diff --git a/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php index 0d1d276420..dd81441c68 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php @@ -75,8 +75,8 @@ public function test_getViewVarsForIndex() ]; //対象メソッドをコール $rs = $this->ThemeFilesAdminService->getViewVarsForIndex($param); - //戻る値を確認 - $this->assertCount(12, $rs['themeFiles']); + //戻り値を確認 + $this->assertCount(11, $rs['themeFiles']); $this->assertNotNull($rs['currentPath']); $this->assertNotNull($rs['path']); $this->assertNotNull($rs['plugin']); @@ -105,7 +105,7 @@ public function test_getViewVarsForAdd() $param ); - //戻る値を確認 + //戻り値を確認 $this->assertArrayHasKey('themeFileForm', $rs); $this->assertArrayHasKey('themeFile', $rs); $this->assertNotNull($rs['currentPath']); @@ -138,7 +138,7 @@ public function test_getViewVarsForEdit() $param ); - //戻る値を確認 + //戻り値を確認 $this->assertArrayHasKey('themeFileForm', $rs); $this->assertArrayHasKey('themeFile', $rs); $this->assertNotNull($rs['currentPath']); diff --git a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php index 84469019f2..966c83775f 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php @@ -50,7 +50,7 @@ public function test_getNew() $fullPath = '/var/www/html/plugins/bc-front/webroot/img'; //対象のメソッドをコル $rs = $this->ThemeFoldersService->getNew($fullPath); - //戻る値を確認 + //戻り値を確認 $this->assertEquals($rs->type, 'folder'); $this->assertEquals($rs->fullpath, $fullPath); $this->assertEquals($rs->parent, $fullPath); @@ -64,7 +64,7 @@ public function test_get() $fullPath = '/var/www/html/plugins/bc-front/webroot/img'; //対象のメソッドをコル $rs = $this->ThemeFoldersService->get($fullPath); - //戻る値を確認 + //戻り値を確認 $this->assertEquals($rs->type, 'folder'); $this->assertEquals($rs->fullpath, $fullPath); $this->assertEquals($rs->parent, '/var/www/html/plugins/bc-front/webroot/'); @@ -79,18 +79,18 @@ public function test_getIndex() $param['fullpath'] = '/var/www/html/plugins/bc-front/templates'; $param['type'] = 'folder'; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(12, $themeFiles); + $this->assertCount(11, $themeFiles); //typeはetcかつpathは指定しない場合、 $param['type'] = 'etc'; $param['path'] = ''; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(8, $themeFiles); + $this->assertCount(7, $themeFiles); //typeはetcかつpathは指定した場合、 $param['path'] = '/var/www/html/plugins/bc-front/templates'; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(12, $themeFiles); + $this->assertCount(11, $themeFiles); } /** @@ -105,7 +105,7 @@ public function test_create() 'name' => 'new_folder', ]; $rs = $this->ThemeFoldersService->create($data); - //戻る値を確認 + //戻り値を確認 $this->assertEquals($rs->getData('mode'), 'create'); $this->assertEquals($rs->getData('fullpath'), $data['fullpath'] . DS . $data['name']); $this->assertEquals($rs->getData('name'), $data['name']); @@ -149,7 +149,7 @@ public function test_delete() $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout'; (new BcFolder($fullpath . DS . 'delete_folder'))->create(); $rs = $this->ThemeFoldersService->delete($fullpath . DS . 'delete_folder'); - //戻る値を確認 + //戻り値を確認 $this->assertTrue($rs); //実際にフォルダが削除されいてるか確認すること $this->assertFalse(file_exists($fullpath . 'delete_folder')); @@ -167,7 +167,7 @@ public function test_copy() //対象のメソッドを確認 $rs = $this->ThemeFoldersService->copy($fullpath . 'new_folder'); - //戻る値を確認 + //戻り値を確認 $this->assertEquals($rs->type, 'folder'); $this->assertEquals($rs->fullpath, $fullpath . 'new_folder_copy'); $this->assertEquals($rs->parent, $fullpath); @@ -211,7 +211,7 @@ public function test_getNamesByFullpath() ]; //対象のメソッドをコル $rs = $this->ThemeFoldersService->getNamesByFullpath($fullPaths); - //戻る値を確認 + //戻り値を確認 $this->assertEquals($rs, ['img', 'js']); } @@ -235,7 +235,7 @@ public function test_copyToTheme() ]; $rs = $this->ThemeFoldersService->copyToTheme($data); - //戻る値を確認 + //戻り値を確認 $this->assertEquals($rs, '/plugins/BcPluginSample/templates/Pages/'); //実際にフォルダがコピーできるか確認すること $this->assertTrue(is_dir($fullpath . '/Pages')); @@ -247,7 +247,7 @@ public function test_copyToTheme() $data ['fullpath'] = '/var/www/html/plugins/bc-front/templates/Pages/11111'; $rs = $this->ThemeFoldersService->copyToTheme($data); - //戻る値を確認 + //戻り値を確認 $this->assertFalse($rs); }