Skip to content

Commit 1e68f23

Browse files
Merge pull request #49 from lifeofguenter/increase-code-coverage
Increase Code Coverage
2 parents 035d740 + c94158d commit 1e68f23

File tree

13 files changed

+382
-7
lines changed

13 files changed

+382
-7
lines changed

src/AfriCC/EPP/Frame/Command/Create/Domain.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ public function setAuthInfo($pw = null)
8080
}
8181

8282
$this->set('domain:authInfo/domain:pw', $pw);
83+
84+
return $pw;
8385
}
8486
}

tests/EPP/DOM/DOMElementTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\DOM;
4+
5+
use AfriCC\EPP\DOM\DOMElement;
6+
use DOMDocument;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class DOMElementTest extends TestCase
10+
{
11+
public function testHasChildNodes()
12+
{
13+
$dom = new DOMDocument('1.0', 'utf-8');
14+
15+
$parent = new DOMElement('foo');
16+
$dom->appendChild($parent);
17+
$this->assertFalse($parent->hasChildNodes());
18+
19+
$child = new DOMElement('bar');
20+
$parent->appendChild($child);
21+
$this->assertTrue($parent->hasChildNodes());
22+
}
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Check;
4+
5+
use AfriCC\EPP\Frame\Command\Check\Contact as ContactCheck;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class ContactCheckTest extends TestCase
9+
{
10+
public function testContactCheckFrame()
11+
{
12+
$frame = new ContactCheck();
13+
$frame->addId('handle-1234');
14+
$this->assertXmlStringEqualsXmlString(
15+
'<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
16+
<command>
17+
<check>
18+
<contact:check xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
19+
<contact:id>handle-1234</contact:id>
20+
</contact:check>
21+
</check>
22+
</command>
23+
</epp>
24+
',
25+
(string) $frame
26+
);
27+
}
28+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Check;
4+
5+
use AfriCC\EPP\Frame\Command\Check\Domain as DomainCheck;
6+
use Exception;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class DomainCheckTest extends TestCase
10+
{
11+
public function testDomainCheckFrame()
12+
{
13+
$frame = new DomainCheck();
14+
$frame->addDomain(TEST_DOMAIN);
15+
$this->assertXmlStringEqualsXmlString(
16+
'<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
17+
<command>
18+
<check>
19+
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
20+
<domain:name>' . TEST_DOMAIN . '</domain:name>
21+
</domain:check>
22+
</check>
23+
</command>
24+
</epp>
25+
',
26+
(string) $frame
27+
);
28+
}
29+
30+
public function testDomainCheckFrameInvalidDomain()
31+
{
32+
$frame = new DomainCheck();
33+
34+
if (method_exists($this, 'expectException')) {
35+
$this->expectException(Exception::class);
36+
$frame->addDomain('invalid_domain');
37+
} else {
38+
try {
39+
$frame->addDomain('invalid_domain');
40+
} catch (Exception $e) {
41+
$this->assertEquals('Exception', get_class($e));
42+
}
43+
}
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Check;
4+
5+
use AfriCC\EPP\Frame\Command\Check\Host as HostCheck;
6+
use Exception;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class HostCheckTest extends TestCase
10+
{
11+
public function testHostCheckFrame()
12+
{
13+
$frame = new HostCheck();
14+
$frame->addHost('ns1.' . TEST_DOMAIN);
15+
$this->assertXmlStringEqualsXmlString(
16+
'<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
17+
<command>
18+
<check>
19+
<host:check xmlns:host="urn:ietf:params:xml:ns:host-1.0">
20+
<host:name>ns1.' . TEST_DOMAIN . '</host:name>
21+
</host:check>
22+
</check>
23+
</command>
24+
</epp>
25+
',
26+
(string) $frame
27+
);
28+
}
29+
30+
public function testHostCheckFrameInvalidHost()
31+
{
32+
$frame = new HostCheck();
33+
34+
if (method_exists($this, 'expectException')) {
35+
$this->expectException(Exception::class);
36+
$frame->addHost('invalid_host');
37+
} else {
38+
try {
39+
$frame->addHost('invalid_host');
40+
} catch (Exception $e) {
41+
$this->assertEquals('Exception', get_class($e));
42+
}
43+
}
44+
}
45+
}

tests/EPP/Frame/Command/Create/ContactCreateTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
use AfriCC\EPP\Frame\Command\Create\Contact;
66
use PHPUnit\Framework\TestCase;
77

8-
class CreateContactTest extends TestCase
8+
class ContactCreateTest extends TestCase
99
{
10-
public function testCreateContactFrame()
10+
public function testContactCreateFrame()
1111
{
1212
$frame = new Contact();
1313
$frame->setId('CONTACT1');
@@ -77,7 +77,7 @@ public function testCreateContactFrame()
7777
);
7878
}
7979

80-
public function testCreateContactSkipIntFrame()
80+
public function testContactCreateSkipIntFrame()
8181
{
8282
$frame = new Contact();
8383
$frame->skipInt();
@@ -136,7 +136,7 @@ public function testCreateContactSkipIntFrame()
136136
);
137137
}
138138

139-
public function testCreateContactSkipLocFrame()
139+
public function testContactCreateSkipLocFrame()
140140
{
141141
$frame = new Contact();
142142
$frame->skipLoc();
@@ -195,7 +195,7 @@ public function testCreateContactSkipLocFrame()
195195
);
196196
}
197197

198-
public function testCreateContactDiscloseFrame()
198+
public function testContactCreateDiscloseFrame()
199199
{
200200
$frame = new Contact();
201201
$frame->skipInt();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Create;
4+
5+
use AfriCC\EPP\Frame\Command\Create\Domain;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class DomainCreateTest extends TestCase
9+
{
10+
public function testDomainCreateFrame()
11+
{
12+
$frame = new Domain();
13+
$frame->setDomain(TEST_DOMAIN);
14+
$frame->setPeriod('1y');
15+
$frame->addHostAttr('ns2.' . TEST_DOMAIN);
16+
$frame->addHostAttr('ns1.' . TEST_DOMAIN, [
17+
'8.8.8.8',
18+
'2a00:1450:4009:809::100e',
19+
]);
20+
$frame->setRegistrant('C001');
21+
$frame->setAdminContact('C002');
22+
$frame->setTechContact('C003');
23+
$auth = $frame->setAuthInfo();
24+
25+
$this->assertXmlStringEqualsXmlString(
26+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
27+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
28+
<command>
29+
<create>
30+
<domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
31+
<domain:name>' . TEST_DOMAIN . '</domain:name>
32+
<domain:period unit="y">1</domain:period>
33+
<domain:ns>
34+
<domain:hostAttr>
35+
<domain:hostName>ns2.' . TEST_DOMAIN . '</domain:hostName>
36+
</domain:hostAttr>
37+
<domain:hostAttr>
38+
<domain:hostName>ns1.' . TEST_DOMAIN . '</domain:hostName>
39+
<domain:hostAddr ip="v4">8.8.8.8</domain:hostAddr>
40+
<domain:hostAddr ip="v6">2a00:1450:4009:809::100e</domain:hostAddr>
41+
</domain:hostAttr>
42+
</domain:ns>
43+
<domain:registrant>C001</domain:registrant>
44+
<domain:contact type="admin">C002</domain:contact>
45+
<domain:contact type="tech">C003</domain:contact>
46+
<domain:authInfo>
47+
<domain:pw>' . $auth . '</domain:pw>
48+
</domain:authInfo>
49+
</domain:create>
50+
</create>
51+
</command>
52+
</epp>
53+
',
54+
(string) $frame
55+
);
56+
}
57+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Create;
4+
5+
use AfriCC\EPP\Frame\Command\Create\Host;
6+
use Exception;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class HostCreateTest extends TestCase
10+
{
11+
public function testHostCreateFrame()
12+
{
13+
$frame = new Host();
14+
$frame->setHost('ns1.' . TEST_DOMAIN);
15+
$frame->addAddr('8.8.8.8');
16+
$frame->addAddr('2a00:1450:4009:809::100e');
17+
18+
$this->assertXmlStringEqualsXmlString(
19+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
20+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
21+
<command>
22+
<create>
23+
<host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
24+
<host:name>ns1.' . TEST_DOMAIN . '</host:name>
25+
<host:addr ip="v4">8.8.8.8</host:addr>
26+
<host:addr ip="v6">2a00:1450:4009:809::100e</host:addr>
27+
</host:create>
28+
</create>
29+
</command>
30+
</epp>
31+
',
32+
(string) $frame
33+
);
34+
}
35+
36+
public function testHostCreateFrameInvalidHost()
37+
{
38+
$frame = new Host();
39+
40+
if (method_exists($this, 'expectException')) {
41+
$this->expectException(Exception::class);
42+
$frame->setHost('invalid_domain');
43+
} else {
44+
try {
45+
$frame->setHost('invalid_domain');
46+
} catch (Exception $e) {
47+
$this->assertEquals('Exception', get_class($e));
48+
}
49+
}
50+
}
51+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Delete;
4+
5+
use AfriCC\EPP\Frame\Command\Delete\Contact;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class ContactDeleteTest extends TestCase
9+
{
10+
public function testContactDeleteFrame()
11+
{
12+
$frame = new Contact();
13+
$frame->setId('C001');
14+
15+
$this->assertXmlStringEqualsXmlString(
16+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
17+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
18+
<command>
19+
<delete>
20+
<contact:delete xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
21+
<contact:id>C001</contact:id>
22+
</contact:delete>
23+
</delete>
24+
</command>
25+
</epp>
26+
',
27+
(string) $frame
28+
);
29+
}
30+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace AfriCC\Tests\EPP\Frame\Command\Delete;
4+
5+
use AfriCC\EPP\Frame\Command\Delete\Domain;
6+
use Exception;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class DomainDeleteTest extends TestCase
10+
{
11+
public function testDomainDeleteFrame()
12+
{
13+
$frame = new Domain();
14+
$frame->setDomain(TEST_DOMAIN);
15+
16+
$this->assertXmlStringEqualsXmlString(
17+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
18+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
19+
<command>
20+
<delete>
21+
<domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
22+
<domain:name>' . TEST_DOMAIN . '</domain:name>
23+
</domain:delete>
24+
</delete>
25+
</command>
26+
</epp>
27+
',
28+
(string) $frame
29+
);
30+
}
31+
32+
public function testDomainDeleteFrameInvalidDomain()
33+
{
34+
$frame = new Domain();
35+
36+
if (method_exists($this, 'expectException')) {
37+
$this->expectException(Exception::class);
38+
$frame->setDomain('invalid_domain');
39+
} else {
40+
try {
41+
$frame->setDomain('invalid_domain');
42+
} catch (Exception $e) {
43+
$this->assertEquals('Exception', get_class($e));
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)