Skip to content

Commit

Permalink
Merge pull request #49 from lifeofguenter/increase-code-coverage
Browse files Browse the repository at this point in the history
Increase Code Coverage
  • Loading branch information
lifeofguenter committed Apr 27, 2017
2 parents 035d740 + c94158d commit 1e68f23
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/AfriCC/EPP/Frame/Command/Create/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,7 @@ public function setAuthInfo($pw = null)
}

$this->set('domain:authInfo/domain:pw', $pw);

return $pw;
}
}
23 changes: 23 additions & 0 deletions tests/EPP/DOM/DOMElementTest.php
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());
}
}
28 changes: 28 additions & 0 deletions tests/EPP/Frame/Command/Check/ContactCheckTest.php
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
);
}
}
45 changes: 45 additions & 0 deletions tests/EPP/Frame/Command/Check/DomainCheckTest.php
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));
}
}
}
}
45 changes: 45 additions & 0 deletions tests/EPP/Frame/Command/Check/HostCheckTest.php
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));
}
}
}
}
10 changes: 5 additions & 5 deletions tests/EPP/Frame/Command/Create/ContactCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use AfriCC\EPP\Frame\Command\Create\Contact;
use PHPUnit\Framework\TestCase;

class CreateContactTest extends TestCase
class ContactCreateTest extends TestCase
{
public function testCreateContactFrame()
public function testContactCreateFrame()
{
$frame = new Contact();
$frame->setId('CONTACT1');
Expand Down Expand Up @@ -77,7 +77,7 @@ public function testCreateContactFrame()
);
}

public function testCreateContactSkipIntFrame()
public function testContactCreateSkipIntFrame()
{
$frame = new Contact();
$frame->skipInt();
Expand Down Expand Up @@ -136,7 +136,7 @@ public function testCreateContactSkipIntFrame()
);
}

public function testCreateContactSkipLocFrame()
public function testContactCreateSkipLocFrame()
{
$frame = new Contact();
$frame->skipLoc();
Expand Down Expand Up @@ -195,7 +195,7 @@ public function testCreateContactSkipLocFrame()
);
}

public function testCreateContactDiscloseFrame()
public function testContactCreateDiscloseFrame()
{
$frame = new Contact();
$frame->skipInt();
Expand Down
57 changes: 57 additions & 0 deletions tests/EPP/Frame/Command/Create/DomainCreateTest.php
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
);
}
}
51 changes: 51 additions & 0 deletions tests/EPP/Frame/Command/Create/HostCreateTest.php
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));
}
}
}
}
30 changes: 30 additions & 0 deletions tests/EPP/Frame/Command/Delete/ContactDeleteTest.php
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
);
}
}
47 changes: 47 additions & 0 deletions tests/EPP/Frame/Command/Delete/DomainDeleteTest.php
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));
}
}
}
}
Loading

0 comments on commit 1e68f23

Please sign in to comment.