Skip to content

Commit

Permalink
fix #2005 BlogTagsTable::hasNewTagAddablePermission のユニットテスト実装 (#2202)
Browse files Browse the repository at this point in the history
Co-authored-by: Đỗ Văn Hùng <HungDV2022>
  • Loading branch information
HungDV2022 committed May 30, 2023
1 parent 8ee2351 commit 37711bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/bc-blog/src/Model/Table/BlogTagsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function validationDefault(Validator $validator): Validator
* @param int $blogContentId ブログコンテンツID
* @checked
* @noTodo
* @unitTest
*/
public function hasNewTagAddablePermission($userGroupId, $blogContentId)
{
Expand Down
17 changes: 17 additions & 0 deletions plugins/bc-blog/tests/TestCase/Model/BlogTagsTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace BcBlog\Test\TestCase\Model;

use BaserCore\Test\Factory\UserGroupFactory;
use BaserCore\TestSuite\BcTestCase;
use BcBlog\Model\Table\BlogTagsTable;
use BcBlog\Test\Factory\BlogTagFactory;
Expand All @@ -29,6 +30,7 @@ class BlogTagsTableTest extends BcTestCase
'plugin.BcBlog.Factory/BlogPosts',
'plugin.BcBlog.Factory/BlogPostsBlogTags',
'plugin.BcBlog.Factory/BlogTags',
'plugin.BaserCore.Factory/UserGroups',
];

/**
Expand Down Expand Up @@ -208,4 +210,19 @@ public function testAfterCopyEvent()
$query = $blogTags->find()->where(['name' => 'afterAdd']);
$this->assertEquals(1, $query->count());
}

/**
* test hasNewTagAddablePermission
*/
public function test_hasNewTagAddablePermission()
{
//データーを生成
UserGroupFactory::make(['id' => 2])->persist();

//アクセス制限がある場合、
$this->assertTrue($this->BlogTagsTable->hasNewTagAddablePermission([1], 1));

//アクセス制限がない場合、
$this->assertFalse($this->BlogTagsTable->hasNewTagAddablePermission([2], 1));
}
}

0 comments on commit 37711bb

Please sign in to comment.