Skip to content

Commit

Permalink
Add unitTest_MailMessageService_update
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed Dec 2, 2024
1 parent cec8631 commit 1d8276c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/bc-mail/src/Service/MailMessagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public function convertToForm(EntityInterface $mailMessage)
* @return EntityInterface|null
* @checked
* @noTodo
* @unitTest
*/
public function update(EntityInterface $entity, array $postData): ?EntityInterface
{
Expand Down
18 changes: 18 additions & 0 deletions plugins/bc-mail/tests/TestCase/Service/MailMessagesServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ public function testGet()
$MailMessagesService->get(1);
}

/**
* test update
*/
public function testUpdate()
{
//準備
$mailMessagesService = $this->getService(MailMessagesServiceInterface::class);
$mailMessageTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages');
$mailMessageTable->setup(1);
$mailMessageTable->save(new Entity(['id' => 1, 'name_1' => 'name 1']));
$mailMessage = $mailMessagesService->get(1);
$mailMessage->name_1 = 'name update';

//正常実行
$rs = $mailMessagesService->update($mailMessage, $mailMessage->toArray());
$this->assertEquals('name update', $rs->name_1);
}

/**
* test getIndex
*/
Expand Down

0 comments on commit 1d8276c

Please sign in to comment.