Skip to content

Commit

Permalink
Convert MatchTest to using providers
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 11, 2014
1 parent 26d5bca commit dede274
Showing 1 changed file with 69 additions and 10 deletions.
79 changes: 69 additions & 10 deletions framework/Mail/test/Horde/Mail/MatchTest.php
Expand Up @@ -9,22 +9,81 @@

class Horde_Mail_MatchTest extends PHPUnit_Framework_TestCase
{
public function testMatch()
/**
* @dataProvider matchProvider
*/
public function testMatch($in, $match, $expected)
{
$address = new Horde_Mail_Rfc822_Address('Test <test@example.com>');
$address = new Horde_Mail_Rfc822_Address($in);

$this->assertTrue($address->match('Foo <test@example.com>'));
$this->assertTrue($address->match('Foo <test@EXAMPLE.COM>'));
$this->assertFalse($address->match('Foo <Test@example.com>'));
$this->assertEquals(
$expected,
$address->match($match)
);
}

public function testInsensitiveMatch()
public function matchProvider()
{
$address = new Horde_Mail_Rfc822_Address('Test <test@example.com>');
$test1 = 'Test <test@example.com>';

$this->assertTrue($address->matchInsensitive('Foo <test@example.com>'));
$this->assertTrue($address->matchInsensitive('Foo <test@EXAMPLE.COM>'));
$this->assertTrue($address->matchInsensitive('Foo <Test@example.com>'));
return array(
array(
$test1,
'Foo <test@example.com>',
true
),
array(
$test1,
'Foo <test@EXAMPLE.COM>',
true
),
array(
$test1,
'Foo <Test@example.com>',
false
)
);
}

/**
* @dataProvider insensitiveMatchProvider
*/
public function testInsensitiveMatch($in, $match, $expected)
{
$address = new Horde_Mail_Rfc822_Address($in);

$this->assertEquals(
$expected,
$address->matchInsensitive($match)
);
}

public function insensitiveMatchProvider()
{
$test1 = 'Test <test@example.com>';

return array(
array(
$test1,
'Foo <test@example.com>',
true
),
array(
$test1,
'Foo <test@EXAMPLE.COM>',
true
),
array(
$test1,
'Foo <Test@example.com>',
true
),
array(
$test1,
'test1@example.com',
false
)
);
}

}

0 comments on commit dede274

Please sign in to comment.