SetWordWrapTest: reorganize to use data providers
* Maintains the same test code and test cases. * Removes code duplication. * Makes it easier to add additional test cases in the future.
This commit is contained in:
parent
c6ed8ad0eb
commit
807a80b4a6
|
|
@ -22,46 +22,47 @@ final class SetWordWrapTest extends PreSendTestCase
|
|||
{
|
||||
|
||||
/**
|
||||
* Word-wrap an ASCII message.
|
||||
* Test word-wrapping a message.
|
||||
*
|
||||
* @dataProvider dataWordWrap
|
||||
*
|
||||
* @param string $message The message to use.
|
||||
* @param string $subjectSuffix Subject suffix to use.
|
||||
*/
|
||||
public function testWordWrap()
|
||||
public function testWordWrap($message, $subjectSuffix)
|
||||
{
|
||||
$this->Mail->WordWrap = 40;
|
||||
$my_body = str_repeat(
|
||||
'Here is the main body of this message. It should ' .
|
||||
'be quite a few lines. It should be wrapped at ' .
|
||||
'40 characters. Make sure that it is. ',
|
||||
10
|
||||
);
|
||||
$my_body = str_repeat($message, 10);
|
||||
$nBodyLen = strlen($my_body);
|
||||
$my_body .= "\n\nThis is the above body length: " . $nBodyLen;
|
||||
|
||||
$this->Mail->Body = $my_body;
|
||||
$this->Mail->Subject .= ': Wordwrap';
|
||||
$this->Mail->Subject .= ': ' . $subjectSuffix;
|
||||
|
||||
$this->buildBody();
|
||||
self::assertTrue($this->Mail->preSend(), $this->Mail->ErrorInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Word-wrap a multibyte message.
|
||||
* Data provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testWordWrapMultibyte()
|
||||
public function dataWordWrap()
|
||||
{
|
||||
$this->Mail->WordWrap = 40;
|
||||
$my_body = str_repeat(
|
||||
'飛兒樂 團光茫 飛兒樂 團光茫 飛兒樂 團光茫 飛兒樂 團光茫 ' .
|
||||
'飛飛兒樂 團光茫兒樂 團光茫飛兒樂 團光飛兒樂 團光茫飛兒樂 團光茫兒樂 團光茫 ' .
|
||||
'飛兒樂 團光茫飛兒樂 團飛兒樂 團光茫光茫飛兒樂 團光茫. ',
|
||||
10
|
||||
);
|
||||
$nBodyLen = strlen($my_body);
|
||||
$my_body .= "\n\nThis is the above body length: " . $nBodyLen;
|
||||
|
||||
$this->Mail->Body = $my_body;
|
||||
$this->Mail->Subject .= ': Wordwrap multibyte';
|
||||
|
||||
$this->buildBody();
|
||||
self::assertTrue($this->Mail->preSend(), $this->Mail->ErrorInfo);
|
||||
return [
|
||||
'ascii message' => [
|
||||
'message' => 'Here is the main body of this message. It should ' .
|
||||
'be quite a few lines. It should be wrapped at ' .
|
||||
'40 characters. Make sure that it is. ',
|
||||
'subjectSuffix' => 'Wordwrap',
|
||||
],
|
||||
'multibyte message' => [
|
||||
'message' => '飛兒樂 團光茫 飛兒樂 團光茫 飛兒樂 團光茫 飛兒樂 團光茫 ' .
|
||||
'飛飛兒樂 團光茫兒樂 團光茫飛兒樂 團光飛兒樂 團光茫飛兒樂 團光茫兒樂 團光茫 ' .
|
||||
'飛兒樂 團光茫飛兒樂 團飛兒樂 團光茫光茫飛兒樂 團光茫. ',
|
||||
'subjectSuffix' => 'Wordwrap multibyte',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue