mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Convert test to use a dataprovider instead of multiple calls.
Dataproviders are generally a bit easier to work with in the future.
This commit is contained in:
parent
96df2c4b68
commit
74d8e9ea40
1 changed files with 54 additions and 37 deletions
|
@ -363,54 +363,71 @@ class TextHelperTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testAutoLinkEmails method
|
* Data provider for autoLinkEmail.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAutoLinkEmails() {
|
public function autoLinkEmailProvider() {
|
||||||
$text = 'This is a test text';
|
return array(
|
||||||
$expected = 'This is a test text';
|
array(
|
||||||
$result = $this->Text->autoLinkUrls($text);
|
'This is a test text',
|
||||||
$this->assertEquals($expected, $result);
|
'This is a test text',
|
||||||
|
),
|
||||||
|
|
||||||
$text = 'email@example.com address';
|
array(
|
||||||
$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
|
'email@example.com address',
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'<a href="mailto:email@example.com">email@example.com</a> address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = 'email@example.com address';
|
array(
|
||||||
$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
|
'email@example.com address',
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'<a href="mailto:email@example.com">email@example.com</a> address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = '(email@example.com) address';
|
array(
|
||||||
$expected = '(<a href="mailto:email@example.com">email@example.com</a>) address';
|
'(email@example.com) address',
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'(<a href="mailto:email@example.com">email@example.com</a>) address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = 'Text with email@example.com address';
|
array(
|
||||||
$expected = 'Text with <a href="mailto:email@example.com">email@example.com</a> address';
|
'Text with email@example.com address',
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'Text with <a href="mailto:email@example.com">email@example.com</a> address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = "Text with o'hare._-bob@example.com address";
|
array(
|
||||||
$expected = 'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address';
|
"Text with o'hare._-bob@example.com address",
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = 'Text with email@example.com address';
|
array(
|
||||||
$expected = 'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address';
|
'Text with düsentrieb@küchenschöhn-not-working.de address',
|
||||||
$result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
|
'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
|
array(
|
||||||
$expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address';
|
'Text with me@subdomain.küchenschöhn.de address',
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address',
|
||||||
$this->assertEquals($expected, $result);
|
),
|
||||||
|
|
||||||
$text = 'Text with me@subdomain.küchenschöhn.de address';
|
array(
|
||||||
$expected = 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address';
|
'Text with email@example.com address',
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address',
|
||||||
|
array('class' => 'link'),
|
||||||
|
),
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testAutoLinkEmails method
|
||||||
|
*
|
||||||
|
* @param string $text The text to link
|
||||||
|
* @param string $expected The expected results.
|
||||||
|
* @dataProvider autoLinkEmailProvider
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAutoLinkEmails($text, $expected, $attrs = array()) {
|
||||||
|
$result = $this->Text->autoLinkEmails($text, $attrs);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue