-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I split the test into one really basic one and a more functional one. The more functional one now has DRY-er code and is easier to add more tests to. It also paves the way for testing IP based lookups easier in the future.
- Loading branch information
1 parent
d13e1a5
commit 75085c6
Showing
2 changed files
with
63 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
namespace MallardDuck\Whois\Test; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use MallardDuck\Whois\WhoisServerList\Locator; | ||
|
||
/** | ||
* Corresponding Class to test the Locator class | ||
* | ||
* For each class in your library, there should be a corresponding Unit-Test for it | ||
* Unit-Tests should be as much as possible independent from other test going on. | ||
* | ||
* @author mallardduck <[email protected]> | ||
*/ | ||
class WhoisLocatorLookupsTest extends TestCase | ||
{ | ||
|
||
|
||
/** | ||
* Test the ability to call the locators find function and get function fluently. | ||
* @param string $domain Test domains! | ||
* @param string $server Whois Server domains! | ||
* @dataProvider validDomainPairsProvider | ||
*/ | ||
public function testFindAndGetCorrectDomainWhoisServer($domain, $server) | ||
{ | ||
$var = new Locator; | ||
$results = $var->findWhoisServer($domain)->getWhoisServer(); | ||
$this->assertTrue(is_string($results) && !empty($results)); | ||
$this->assertTrue($server === $results); | ||
unset($var, $results); | ||
} | ||
|
||
/** | ||
* Test the ability to call the locators get function directly. | ||
* @param string $domain Test domains! | ||
* @param string $server Whois Server domains! | ||
* @dataProvider validDomainPairsProvider | ||
*/ | ||
public function testGetCorrectDomainWhoisServer($domain, $server) | ||
{ | ||
$var = new Locator; | ||
$results = $var->getWhoisServer($domain); | ||
$this->assertTrue(is_string($results) && !empty($results)); | ||
$this->assertTrue($server === $results); | ||
unset($var, $results); | ||
} | ||
|
||
/** | ||
* A list of valid domain and whois server domain pairs. | ||
*/ | ||
public function validDomainPairsProvider() | ||
{ | ||
return [ | ||
['google.com', 'whois.verisign-grs.com'], | ||
['google.net', 'whois.verisign-grs.com'], | ||
['liquidweb.com', 'whois.verisign-grs.com'], | ||
['danpock.xyz', 'whois.nic.xyz'], | ||
['bbc.co.uk', 'whois.nic.uk'], | ||
['goober.biz', 'whois.biz'], // literally a made up domain - but it does exist lul | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters