Skip to content

Commit

Permalink
fix #1610 BlogPostsService::delete のユニットテスト実装 (#1738)
Browse files Browse the repository at this point in the history
Co-authored-by: Đỗ Văn Hùng <HungDV2022>
  • Loading branch information
HungDV2022 committed Jan 2, 2023
1 parent ad26d9d commit e7db450
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/bc-blog/src/Service/BlogPostsService.php
Expand Up @@ -626,6 +626,7 @@ public function unpublish(int $id)
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function delete(int $id): bool
{
Expand Down
13 changes: 12 additions & 1 deletion plugins/bc-blog/tests/TestCase/Service/BlogPostsServiceTest.php
Expand Up @@ -17,6 +17,7 @@
use BcBlog\Service\BlogPostsService;
use BcBlog\Service\BlogPostsServiceInterface;
use BcBlog\Test\Factory\BlogPostFactory;
use Cake\Datasource\Exception\RecordNotFoundException;

/**
* BlogPostsServiceTest
Expand Down Expand Up @@ -411,7 +412,17 @@ public function testUnpublish()
*/
public function testDelete()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
//データ 生成
BlogPostFactory::make(['id' => '1'])->persist();

// //存在しているBlogPostIdを削除
$result = $this->BlogPostsService->delete(1);
//戻り値を確認
$this->assertTrue($result);

//存在しないBlogPostIdを削除
$this->expectException(RecordNotFoundException::class);
$this->BlogPostsService->get(1);
}

/**
Expand Down

0 comments on commit e7db450

Please sign in to comment.