Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:baserproject/ucmitz into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Nov 14, 2022
2 parents d682388 + c1f5aa7 commit 0343e5f
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function testGetType(): void
'ContentFolder' => 'フォルダー',
'ContentAlias' => 'エイリアス',
'Page' => '固定ページ',
'BlogContent' => 'ブログ'
'BlogContent' => 'ブログ',
'ContentLink' => 'リンク'
];
$this->assertEquals($expected, $this->ContentsAdmin->getTypes());
}
Expand Down
21 changes: 11 additions & 10 deletions plugins/bc-blog/src/Controller/Admin/BlogPostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ class BlogPostsController extends BlogAdminAppController

/**
* initialize
*
*
* ブログ記事に関する処理の初期化を行う
*
*
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function initialize(): void
{
Expand Down Expand Up @@ -94,7 +95,7 @@ public function beforeFilter(EventInterface $event)

/**
* [ADMIN] ブログ記事一覧表示
*
*
* ブログ記事の一覧を表示する。
* ページネーションで次の記事が見つからなかった場合は、1ページ目にリダイレクトする。
*
Expand Down Expand Up @@ -144,9 +145,9 @@ public function index(BlogPostsAdminServiceInterface $service, int $blogContentI

/**
* [ADMIN] ブログ記事追加処理
*
*
* 指定したブログに記事を追加して、ブログ記事編集画面へリダイレクトする。
*
*
* ###エラー
* ブログ記事の追加に失敗した場合、PersistenceFailedExceptionかBcExceptionが発生する。
*
Expand Down Expand Up @@ -198,7 +199,7 @@ public function add(BlogPostsAdminServiceInterface $service, int $blogContentId)

/**
* [ADMIN] ブログ記事編集処理
*
*
* 指定したブログ記事を編集する。
* 記事の保存に失敗した場合、PersistenceFailedExceptionかBcExceptionのエラーが発生する。
*
Expand Down Expand Up @@ -248,7 +249,7 @@ public function edit(BlogPostsAdminServiceInterface $service, int $blogContentId

/**
* [ADMIN] ブログ記事削除処理
*
*
* 指定したブログ記事を削除し、ブログ記事一覧へリダイレクトする。
*
* @param BlogPostsServiceInterface $service
Expand All @@ -273,7 +274,7 @@ public function delete(BlogPostsServiceInterface $service, int $blogContentId, i

/**
* [ADMIN] ブログ記事を非公開状態にする
*
*
* 指定したブログ記事を非公開にしてブログ記事一覧へリダイレクトする。
*
* @param string $blogContentId
Expand All @@ -297,7 +298,7 @@ public function unpublish(BlogPostsServiceInterface $service, $blogContentId, $i

/**
* [ADMIN] ブログ記事を公開状態にする
*
*
* 指定したブログ記事を公開状態にしてブログ記事一覧にリダイレクトする。
*
* @param string $blogContentId
Expand All @@ -321,7 +322,7 @@ public function publish(BlogPostsServiceInterface $service, $blogContentId, $id)

/**
* [ADMIN] コピー
*
*
* 指定したブログ記事をコピーする。
* HTTPメソッドがGETの場合はコピー処理は行わず、ブログ記事一覧へリダイレクトする。
*
Expand Down
13 changes: 7 additions & 6 deletions plugins/bc-blog/src/Controller/Admin/BlogTagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class BlogTagsController extends BlogAdminAppController

/**
* initialize
*
*
* Admin/BlogTagsControllerの初期化を行う
*
*
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function initialize(): void
{
Expand All @@ -45,7 +46,7 @@ public function initialize(): void

/**
* [ADMIN] ブログタグ一覧
*
*
* ブログのタグ一覧を表示する。
* ページネーションによる遷移先でレコードがなければ1ページ目にリダイレクトする。
*
Expand Down Expand Up @@ -76,7 +77,7 @@ public function index(BlogTagsServiceInterface $service, $blogContentId = [])
*
* ブロブのタグを登録する。
* 登録に成功した場合、タグの一覧へリダイレクトする。
*
*
* @param BlogTagsService $service
* @return void
*/
Expand Down Expand Up @@ -104,7 +105,7 @@ public function add(BlogTagsServiceInterface $service)
* [ADMIN] ブログタグ編集
*
* 指定したブログのタグを編集し、ブログのタグ一覧へリダイレクトする
*
*
* @param BlogTagsService $service
* @param int $id タグID
* @return void
Expand Down Expand Up @@ -135,7 +136,7 @@ public function edit(BlogTagsServiceInterface $service, $id)
* [ADMIN] ブログタグの削除処理
*
* 指定したブログのタグを削除して、ブログのタグ一覧へリダイレクトする。
*
*
* @param BlogTagsService $service
* @param int $id
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BlogCommentsController extends BcApiController
*
* 指定したブログのコメントに対して削除、公開、非公開の処理を一括で行う
*
* ###エラー
* ### エラー
* 受け取ったPOSTデータのキー名'batch'が'delete','publish','unpublish'以外の値であれば500エラーを発生させる
*
* @param BlogCommentsService $service
Expand Down
7 changes: 6 additions & 1 deletion plugins/bc-blog/src/Controller/Api/BlogPostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ class BlogPostsController extends BcApiController
{

/**
* バッチ処理
* ブログ記事のバッチ処理
*
* 指定したブログ記事に対して削除、公開、非公開の処理を一括で行う
*
* ### エラー
* 受け取ったPOSTデータのキー名'batch'が'delete','publish','unpublish'以外の値であれば500エラーを発生させる
*
* @param BlogPostsServiceInterface $service
* @checked
Expand Down
14 changes: 12 additions & 2 deletions plugins/bc-blog/src/Controller/Api/BlogTagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class BlogTagsController extends BcApiController
{

/**
* [ADMIN] タグ登録
* [ADMIN] ブログタグ登録
*
* ブログのタグを登録する
* ブログタグの登録に失敗した場合、HTTPレスポンスのステータスに400を返します。
*
*/
public function add(BlogTagsServiceInterface $service)
{
Expand All @@ -50,7 +54,13 @@ public function add(BlogTagsServiceInterface $service)
}

/**
* バッチ処理
* ブログタグのバッチ処理
*
* 指定したブログのコメントに対して削除処理を一括で行う
*
* ### エラー
* delete以外のHTTPメソッドには500エラーを返す
* 一括処理に失敗すると400エラーを返す
*
* @param BlogTagsService $service
* @checked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function tearDown(): void
*/
public function testInitialize(): void
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->assertNotEmpty($this->BlogPostsController->BcAdminContents);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
// TODO : コード確認要
return;

/**
* baserCMS : Based Website Development Project <https://basercms.net>
* Copyright (c) baserCMS Users Community <https://basercms.net/community/>
Expand All @@ -12,81 +11,100 @@
* @license https://basercms.net/license/index.html
*/

App::uses('BlogTagsController', 'BcBlog.Controller');
namespace BcBlog\Test\TestCase\Controller\Admin;

use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BcBlog\Controller\Admin\BlogTagsController;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

/**
* Class BlogTagsControllerTest
*
* @package Blog.Test.Case.Controller
* @property BlogTagsController $BlogTagsController
* @property BlogTagsController $BlogTagsController
*/
class BlogTagsControllerTest extends BaserTestCase
class BlogTagsControllerTest extends BcTestCase
{

/**
* Trait
*/
use ScenarioAwareTrait;

/**
* Fixtures
*
* @var array
*/
public $fixtures = [
'plugin.BaserCore.Factory/Sites',
'plugin.BaserCore.Factory/SiteConfigs',
'plugin.BaserCore.Factory/Users',
'plugin.BaserCore.Factory/UsersUserGroups',
'plugin.BaserCore.Factory/UserGroups',
'plugin.BcBlog.Factory/BlogPosts',
'plugin.BcBlog.Factory/BlogTags',
];

/**
* set up
*
* @return void
*/
public function setUp()
public function setUp(): void
{
$this->setFixtureTruncate();
parent::setUp();
$this->loadFixtureScenario(InitAppScenario::class);
$this->BlogTagsController = new BlogTagsController($this->loginAdmin($this->getRequest()));
}

/**
* tearDown
*
* @return void
*/
public function tearDown()
public function tearDown(): void
{
parent::tearDown();
}

/**
* [ADMIN] タグ一覧
*/
public function testAdmin_index()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}

/**
* [ADMIN] タグ登録
* test index
*/
public function testAdmin_add()
public function test_initialize()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->assertNotEmpty($this->BlogTagsController->BcAdminContents);
}

/**
* [ADMIN] タグ編集
* test add
*/
public function testAdmin_edit()
public function test_add(): void
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}

/**
* [ADMIN] 削除処理
* test delete
*/
public function testAdmin_delete()
public function test_delete()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}

/**
* [ADMIN] 削除処理 (ajax)
* test edit
*/
public function testAdmin_ajax_delete()
public function test_edit()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}

/**
* [ADMIN] AJAXタグ登録
* test index
*/
public function testAdmin_ajax_add()
public function test_index()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function add(ContentLinksServiceInterface $service)
$message = __d('baser', 'リンク「{0}」を追加しました。', $entity->content->title);
} catch (\Cake\ORM\Exception\PersistenceFailedException $e) {
$entity = $e->getEntity();
$message = __d('baser', "入力エラーです。内容を修正してください。\n");
$message = __d('baser', "入力エラーです。内容を修正してください。");
$this->setResponse($this->response->withStatus(400));
}
$this->set([
Expand Down Expand Up @@ -164,4 +164,46 @@ public function delete(ContentLinksServiceInterface $service, $id)
$this->viewBuilder()->setOption('serialize', ['message', 'contentLink', 'errors']);
}

/**
* コンテンツリンク取得
*
* /baser/api/bc-content-link/content_links/view/{id}.json
*
* クエリーパラーメーター
* - status: string 公開ステータス(初期値:publish)
* - `publish` 公開されたページ
* - `` 全て
*
* @param ContentLinksServiceInterface $service
* @param $id
* @checked
* @noTodo
* @unitTest
*/
public function view(ContentLinksServiceInterface $service, $id)
{
$this->request->allowMethod('get');
$queryParams = $this->getRequest()->getQueryParams();
if(isset($queryParams['status'])) {
if(!$this->Authentication->getIdentity()) throw new ForbiddenException();
}

$queryParams = array_merge($queryParams, [
'status' => 'publish'
]);

$contentLink = $message = null;
try {
$contentLink = $service->get($id, $queryParams);
} catch(\Exception $e) {
$this->setResponse($this->response->withStatus(401));
$message = $e->getMessage();
}

$this->set([
'contentLink' => $contentLink,
'message' => $message
]);
$this->viewBuilder()->setOption('serialize', ['contentLink', 'message']);
}
}
Loading

0 comments on commit 0343e5f

Please sign in to comment.