Skip to content

Commit

Permalink
fix #1661 BlogPostsService::unpublish のユニットテスト実装 (#1756)
Browse files Browse the repository at this point in the history
* fix #1661 BlogPostsService::unpublish のユニットテスト実装

* ユニットテストを調整

Co-authored-by: Đỗ Văn Hùng <HungDV2022>
  • Loading branch information
HungDV2022 committed Jan 18, 2023
1 parent 8c7c4de commit 55beb35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/bc-blog/src/Service/BlogPostsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ public function publish(int $id)
* @return EntityInterface|false
* @checked
* @noTodo
* @unitTest
*/
public function unpublish(int $id)
{
Expand Down
11 changes: 10 additions & 1 deletion plugins/bc-blog/tests/TestCase/Service/BlogPostsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,16 @@ public function testPublish()
*/
public function testUnpublish()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
// データを生成
BlogPostFactory::make([])->publish(1, 1)->persist();

// サービスメソッドを呼ぶ
$entity = $this->BlogPostsService->unpublish(1);

// 戻る値を確認
$this->assertFalse($entity->status);
$this->assertNull($entity->publish_begin);
$this->assertNull($entity->publish_end);
}

/**
Expand Down

0 comments on commit 55beb35

Please sign in to comment.