Skip to content

Commit 61f905e

Browse files
committed
phpunit 4.8 compat and more tests
-
1 parent b3a7b7a commit 61f905e

5 files changed

Lines changed: 132 additions & 6 deletions

File tree

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/Frame/Command/Check/DomainCheckTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@ public function testDomainCheckFrame()
2929

3030
public function testDomainCheckFrameInvalidDomain()
3131
{
32-
$this->expectException(Exception::class);
33-
3432
$frame = new DomainCheck();
35-
$frame->addDomain('invalid_domain');
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+
}
3644
}
3745
}

tests/EPP/Frame/Command/Check/HostCheckTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@ public function testHostCheckFrame()
2929

3030
public function testHostCheckFrameInvalidHost()
3131
{
32-
$this->expectException(Exception::class);
33-
3432
$frame = new HostCheck();
35-
$frame->addHost('invalid_host');
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+
}
3644
}
3745
}
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+
}

0 commit comments

Comments
 (0)