Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
geekwright committed Feb 16, 2017
1 parent f4aefc2 commit a65cb1b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/RegisteredDomainTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?php
namespace Geekwright\RegDom;

/**
* Class TestProtectedDecodePunycode used to test protected decodePunycode() method that is
* only used if intl extension is not loaded.
*/
class TestProtectedDecodePunycode extends RegisteredDomain
{
public function doDecodePunycode($string)
{
return $this->decodePunycode($string);
}
}

class RegisteredDomainTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -144,4 +156,32 @@ public function domainsProvider()
);
return $provider;
}

/**
* @covers Geekwright\RegDom\RegisteredDomain::getRegisteredDomain
*
* @dataProvider punycodeProvider
*/
public function testDecodePunycode($punycode, $decoded)
{
$object = new TestProtectedDecodePunycode();
$this->assertEquals($decoded, $object->doDecodePunycode($punycode));
}

/**
* @return array
*/
public function punycodeProvider()
{
$provider = array(
array(null, null),
// Mixed case.
array('test', 'test'),
// punycoded
array('xn--85x722f', '食狮'),
array('xn--55qx5d', '公司'),
array('xn--fiqs8s', '中国'),
);
return $provider;
}
}

0 comments on commit a65cb1b

Please sign in to comment.