Skip to content

Commit

Permalink
Merge pull request #4061 from thangnnmd/unitTest_MailHelper_link
Browse files Browse the repository at this point in the history
MailHelper::link
  • Loading branch information
HungDV2022 authored Dec 10, 2024
2 parents 8522806 + e652709 commit d5139a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 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 @@ -210,6 +210,7 @@ public function descriptionExists()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function link($title, $contentsName, $datas = [], $options = [])
{
Expand Down
19 changes: 7 additions & 12 deletions plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,20 @@ public function testGetToken()
* メールフォームへのリンクを取得
* @dataProvider linkProvider
*/
public function testLink($title, $contentsName, $expected)
public function testLink($title, $contentsName, $url, $expected)
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
ContentFactory::make(['plugin' => 'BcMail', 'type' => 'MailContent', 'name' => $contentsName, 'url' => $url, '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/', '<a href="/a/index">タイトル</a>'],
[' ', 'a', '/a/', '<a href="/a/index"> </a>'],
[' ', ' ', '', '<a href="/bc-mail/mail"> </a>'],
[' ', '///', '///', '<a href="/index"> </a>'],
];
}

Expand Down

0 comments on commit d5139a0

Please sign in to comment.