-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from lifeofguenter/increase-code-coverage
Increase Code Coverage
- Loading branch information
Showing
13 changed files
with
382 additions
and
7 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 |
---|---|---|
|
@@ -80,5 +80,7 @@ public function setAuthInfo($pw = null) | |
} | ||
|
||
$this->set('domain:authInfo/domain:pw', $pw); | ||
|
||
return $pw; | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\DOM; | ||
|
||
use AfriCC\EPP\DOM\DOMElement; | ||
use DOMDocument; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DOMElementTest extends TestCase | ||
{ | ||
public function testHasChildNodes() | ||
{ | ||
$dom = new DOMDocument('1.0', 'utf-8'); | ||
|
||
$parent = new DOMElement('foo'); | ||
$dom->appendChild($parent); | ||
$this->assertFalse($parent->hasChildNodes()); | ||
|
||
$child = new DOMElement('bar'); | ||
$parent->appendChild($child); | ||
$this->assertTrue($parent->hasChildNodes()); | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Check; | ||
|
||
use AfriCC\EPP\Frame\Command\Check\Contact as ContactCheck; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ContactCheckTest extends TestCase | ||
{ | ||
public function testContactCheckFrame() | ||
{ | ||
$frame = new ContactCheck(); | ||
$frame->addId('handle-1234'); | ||
$this->assertXmlStringEqualsXmlString( | ||
'<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<check> | ||
<contact:check xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"> | ||
<contact:id>handle-1234</contact:id> | ||
</contact:check> | ||
</check> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Check; | ||
|
||
use AfriCC\EPP\Frame\Command\Check\Domain as DomainCheck; | ||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DomainCheckTest extends TestCase | ||
{ | ||
public function testDomainCheckFrame() | ||
{ | ||
$frame = new DomainCheck(); | ||
$frame->addDomain(TEST_DOMAIN); | ||
$this->assertXmlStringEqualsXmlString( | ||
'<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<check> | ||
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"> | ||
<domain:name>' . TEST_DOMAIN . '</domain:name> | ||
</domain:check> | ||
</check> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
|
||
public function testDomainCheckFrameInvalidDomain() | ||
{ | ||
$frame = new DomainCheck(); | ||
|
||
if (method_exists($this, 'expectException')) { | ||
$this->expectException(Exception::class); | ||
$frame->addDomain('invalid_domain'); | ||
} else { | ||
try { | ||
$frame->addDomain('invalid_domain'); | ||
} catch (Exception $e) { | ||
$this->assertEquals('Exception', get_class($e)); | ||
} | ||
} | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Check; | ||
|
||
use AfriCC\EPP\Frame\Command\Check\Host as HostCheck; | ||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HostCheckTest extends TestCase | ||
{ | ||
public function testHostCheckFrame() | ||
{ | ||
$frame = new HostCheck(); | ||
$frame->addHost('ns1.' . TEST_DOMAIN); | ||
$this->assertXmlStringEqualsXmlString( | ||
'<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<check> | ||
<host:check xmlns:host="urn:ietf:params:xml:ns:host-1.0"> | ||
<host:name>ns1.' . TEST_DOMAIN . '</host:name> | ||
</host:check> | ||
</check> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
|
||
public function testHostCheckFrameInvalidHost() | ||
{ | ||
$frame = new HostCheck(); | ||
|
||
if (method_exists($this, 'expectException')) { | ||
$this->expectException(Exception::class); | ||
$frame->addHost('invalid_host'); | ||
} else { | ||
try { | ||
$frame->addHost('invalid_host'); | ||
} catch (Exception $e) { | ||
$this->assertEquals('Exception', get_class($e)); | ||
} | ||
} | ||
} | ||
} |
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
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,57 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Create; | ||
|
||
use AfriCC\EPP\Frame\Command\Create\Domain; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DomainCreateTest extends TestCase | ||
{ | ||
public function testDomainCreateFrame() | ||
{ | ||
$frame = new Domain(); | ||
$frame->setDomain(TEST_DOMAIN); | ||
$frame->setPeriod('1y'); | ||
$frame->addHostAttr('ns2.' . TEST_DOMAIN); | ||
$frame->addHostAttr('ns1.' . TEST_DOMAIN, [ | ||
'8.8.8.8', | ||
'2a00:1450:4009:809::100e', | ||
]); | ||
$frame->setRegistrant('C001'); | ||
$frame->setAdminContact('C002'); | ||
$frame->setTechContact('C003'); | ||
$auth = $frame->setAuthInfo(); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
'<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<create> | ||
<domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"> | ||
<domain:name>' . TEST_DOMAIN . '</domain:name> | ||
<domain:period unit="y">1</domain:period> | ||
<domain:ns> | ||
<domain:hostAttr> | ||
<domain:hostName>ns2.' . TEST_DOMAIN . '</domain:hostName> | ||
</domain:hostAttr> | ||
<domain:hostAttr> | ||
<domain:hostName>ns1.' . TEST_DOMAIN . '</domain:hostName> | ||
<domain:hostAddr ip="v4">8.8.8.8</domain:hostAddr> | ||
<domain:hostAddr ip="v6">2a00:1450:4009:809::100e</domain:hostAddr> | ||
</domain:hostAttr> | ||
</domain:ns> | ||
<domain:registrant>C001</domain:registrant> | ||
<domain:contact type="admin">C002</domain:contact> | ||
<domain:contact type="tech">C003</domain:contact> | ||
<domain:authInfo> | ||
<domain:pw>' . $auth . '</domain:pw> | ||
</domain:authInfo> | ||
</domain:create> | ||
</create> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Create; | ||
|
||
use AfriCC\EPP\Frame\Command\Create\Host; | ||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HostCreateTest extends TestCase | ||
{ | ||
public function testHostCreateFrame() | ||
{ | ||
$frame = new Host(); | ||
$frame->setHost('ns1.' . TEST_DOMAIN); | ||
$frame->addAddr('8.8.8.8'); | ||
$frame->addAddr('2a00:1450:4009:809::100e'); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
'<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<create> | ||
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0"> | ||
<host:name>ns1.' . TEST_DOMAIN . '</host:name> | ||
<host:addr ip="v4">8.8.8.8</host:addr> | ||
<host:addr ip="v6">2a00:1450:4009:809::100e</host:addr> | ||
</host:create> | ||
</create> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
|
||
public function testHostCreateFrameInvalidHost() | ||
{ | ||
$frame = new Host(); | ||
|
||
if (method_exists($this, 'expectException')) { | ||
$this->expectException(Exception::class); | ||
$frame->setHost('invalid_domain'); | ||
} else { | ||
try { | ||
$frame->setHost('invalid_domain'); | ||
} catch (Exception $e) { | ||
$this->assertEquals('Exception', get_class($e)); | ||
} | ||
} | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Delete; | ||
|
||
use AfriCC\EPP\Frame\Command\Delete\Contact; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ContactDeleteTest extends TestCase | ||
{ | ||
public function testContactDeleteFrame() | ||
{ | ||
$frame = new Contact(); | ||
$frame->setId('C001'); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
'<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<delete> | ||
<contact:delete xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"> | ||
<contact:id>C001</contact:id> | ||
</contact:delete> | ||
</delete> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
|
||
namespace AfriCC\Tests\EPP\Frame\Command\Delete; | ||
|
||
use AfriCC\EPP\Frame\Command\Delete\Domain; | ||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class DomainDeleteTest extends TestCase | ||
{ | ||
public function testDomainDeleteFrame() | ||
{ | ||
$frame = new Domain(); | ||
$frame->setDomain(TEST_DOMAIN); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
'<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"> | ||
<command> | ||
<delete> | ||
<domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"> | ||
<domain:name>' . TEST_DOMAIN . '</domain:name> | ||
</domain:delete> | ||
</delete> | ||
</command> | ||
</epp> | ||
', | ||
(string) $frame | ||
); | ||
} | ||
|
||
public function testDomainDeleteFrameInvalidDomain() | ||
{ | ||
$frame = new Domain(); | ||
|
||
if (method_exists($this, 'expectException')) { | ||
$this->expectException(Exception::class); | ||
$frame->setDomain('invalid_domain'); | ||
} else { | ||
try { | ||
$frame->setDomain('invalid_domain'); | ||
} catch (Exception $e) { | ||
$this->assertEquals('Exception', get_class($e)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.