Skip to content

Commit

Permalink
Add unitTest_MailHelper_link
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed Dec 3, 2024
1 parent 7a938a4 commit 322d3a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions plugins/bc-mail/src/View/Helper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public function descriptionExists()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function link($title, $contentsName, $datas = [], $options = [])
{
Expand Down
22 changes: 11 additions & 11 deletions plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,23 @@ public function testGetToken()
*/
public function testLink($title, $contentsName, $expected)
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
ContentFactory::make(['plugin' => 'BcMail', 'type' => 'MailContent', 'name' => $contentsName, 'entity_id' => 1])->persist();
$this->expectOutputString($expected);
$this->Mail->link($title, $contentsName, $datas = [], $options = []);
$this->MailHelper->link($title, $contentsName);
}

public static function linkProvider()
{
return [
['タイトル', 'Members', '<a href="/Members">タイトル</a>'],
[' ', 'a', '<a href="/a"> </a>'],
[' ', ' ', '<a href="/ "> </a>'],
[' ', '///', '<a href="/"> </a>'],
[' ', '////a', '<a href="/a"> </a>'],
[' ', '////a//a/aa', '<a href="/a/a/aa"> </a>'],
[' ', '/../../../../a', '<a href="/../../../../a"> </a>'],
['', 'javascript:void(0);', '<a href="/javascript:void(0);"></a>'],
['<script>alert(1)</script>', '////a', '<a href="/a"><script>alert(1)</script></a>']
['タイトル', 'Members', '<a href="/bc-mail/mail">タイトル</a>'],
[' ', 'a', '<a href="/bc-mail/mail"> </a>'],
[' ', ' ', '<a href="/bc-mail/mail"> </a>'],
[' ', '///', '<a href="/bc-mail/mail"> </a>'],
[' ', '////a', '<a href="/bc-mail/mail"> </a>'],
[' ', '////a//a/aa', '<a href="/bc-mail/mail"> </a>'],
[' ', '/../../../../a', '<a href="/bc-mail/mail"> </a>'],
['', 'javascript:void(0);', '<a href="/bc-mail/mail"></a>'],
['<script>alert(1)</script>', '////a', '<a href="/bc-mail/mail">&lt;script&gt;alert(1)&lt;/script&gt;</a>']
];
}

Expand Down

0 comments on commit 322d3a6

Please sign in to comment.