Skip to content

Commit 98987cf

Browse files
author
Gunter Grodotzki
committed
make addDisclose usefuller (fixes #1)
1 parent 1a0ea77 commit 98987cf

File tree

7 files changed

+274
-7
lines changed

7 files changed

+274
-7
lines changed

examples/create_contact_disclose.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
// debug
4+
error_reporting(E_ALL);
5+
ini_set('display_errors', true);
6+
7+
chdir(__DIR__);
8+
9+
require '../src/AfriCC/autoload.php';
10+
11+
use AfriCC\EPP\Frame\Command\Create\Contact as CreateContact;
12+
13+
$frame = new CreateContact;
14+
$frame->skipInt();
15+
$frame->setId('CONTACT1');
16+
$frame->setName('Günter Grodotzki');
17+
$frame->setOrganization('weheartwebsites UG');
18+
$frame->addStreet('Rönskenstraße 23');
19+
$frame->addStreet('Around the Corner');
20+
$frame->setCity('Cape Town');
21+
$frame->setProvince('WC');
22+
$frame->setPostalCode('8001');
23+
$frame->setCountryCode('ZA');
24+
$frame->setVoice('+27.844784784');
25+
$frame->setFax('+1.844784784');
26+
$frame->setEmail('[email protected]');
27+
$auth = $frame->setAuthInfo();
28+
$frame->addDisclose('voice', 1);
29+
$frame->addDisclose('email', 0);
30+
echo $frame;
31+
var_dump($auth);

examples/update_contact.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
require '../src/AfriCC/autoload.php';
1010

11-
use AfriCC\EPP\Frame\Command\Update\Contact as ContactUpdate;
11+
use AfriCC\EPP\Frame\Command\Update\Contact as UpdateContact;
1212

13-
$frame = new ContactUpdate;
13+
$frame = new UpdateContact;
1414
$frame->setId('C0054');
1515
$frame->addCity('Voerde');
1616
$frame->addAddStreet('Long St. 14');

examples/update_contact_disclose.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
// debug
4+
error_reporting(E_ALL);
5+
ini_set('display_errors', true);
6+
7+
chdir(__DIR__);
8+
9+
require '../src/AfriCC/autoload.php';
10+
11+
use AfriCC\EPP\Frame\Command\Update\Contact as UpdateContact;
12+
13+
$frame = new UpdateContact;
14+
$frame->setId('C0054');
15+
$frame->addCity('Voerde');
16+
$frame->addAddStreet('Long St. 14');
17+
$frame->addAddStreet('CBD');
18+
$frame->changeAddStreet('Long St. 15');
19+
$frame->changeCity('Cape Town');
20+
$frame->removeAddStreet('Long St. 16');
21+
$frame->removeCity('Durban');
22+
$frame->changeAddDisclose('voice', 1);
23+
$frame->changeAddDisclose('name[@type=\'int\']', 1);
24+
echo $frame;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public function setAuthInfo($pw = null)
8181
return $this->appendAuthInfo('contact:authInfo/contact:pw', $pw);
8282
}
8383

84-
public function addDisclose($value)
84+
public function addDisclose($value, $flag = 0)
8585
{
86-
$this->appendDisclose('contact:disclose[@flag=\'0\']/contact:' . $value);
86+
$this->appendDisclose(sprintf('contact:disclose[@flag=\'%d\']/contact:%s', (int) $flag, $value));
8787
}
8888
}

src/AfriCC/EPP/Frame/Command/Update/Contact.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ private function setAuthInfo($mode, $pw = null)
8181
return $this->appendAuthInfo(sprintf('contact:%s/contact:authInfo/contact:pw', $mode), $pw);
8282
}
8383

84-
private function addDisclose($mode, $value)
84+
private function addDisclose($mode, $value, $flag = 0)
8585
{
86-
$this->appendDisclose(sprintf('contact:%s/contact:disclose[@flag=\'0\']/contact:' . $value, $mode));
86+
$this->appendDisclose(sprintf('contact:%s/contact:disclose[@flag=\'%d\']/contact:%s', $mode, $flag, $value));
8787
}
8888

8989
public function __call($name, $arguments)

tests/AfriCC/EPP/Test/Frame/Command/Create/ContactTest.php renamed to tests/AfriCC/EPP/Test/Frame/Command/Create/ContactCreateTest.php

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use AfriCC\EPP\Frame\Command\Create\Contact as CreateContact;
66

7-
class ContactTest extends \PHPUnit_Framework_TestCase
7+
class ContactCreateTest extends \PHPUnit_Framework_TestCase
88
{
99
public function testContactCreate()
1010
{
@@ -130,4 +130,62 @@ public function testContactCreateSkipInt()
130130
</epp>'
131131
);
132132
}
133+
134+
public function testContactCreateDisclose()
135+
{
136+
$frame = new CreateContact;
137+
$frame->skipInt();
138+
$frame->setId('CONTACT1');
139+
$frame->setName('Günter Grodotzki');
140+
$frame->setOrganization('weheartwebsites UG');
141+
$frame->addStreet('Rönskenstraße 23');
142+
$frame->addStreet('Around the Corner');
143+
$frame->setCity('Cape Town');
144+
$frame->setProvince('WC');
145+
$frame->setPostalCode('8001');
146+
$frame->setCountryCode('ZA');
147+
$frame->setVoice('+27.844784784');
148+
$frame->setFax('+1.844784784');
149+
$frame->setEmail('[email protected]');
150+
$auth = $frame->setAuthInfo();
151+
$frame->addDisclose('voice', 1);
152+
$frame->addDisclose('email', 0);
153+
154+
$this->assertXmlStringEqualsXmlString((string) $frame,
155+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
156+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
157+
<command>
158+
<create>
159+
<contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
160+
<contact:id>CONTACT1</contact:id>
161+
<contact:postalInfo type="loc">
162+
<contact:name>Günter Grodotzki</contact:name>
163+
<contact:org>weheartwebsites UG</contact:org>
164+
<contact:addr>
165+
<contact:street>Rönskenstraße 23</contact:street>
166+
<contact:street>Around the Corner</contact:street>
167+
<contact:city>Cape Town</contact:city>
168+
<contact:sp>WC</contact:sp>
169+
<contact:pc>8001</contact:pc>
170+
<contact:cc>ZA</contact:cc>
171+
</contact:addr>
172+
</contact:postalInfo>
173+
<contact:voice>+27.844784784</contact:voice>
174+
<contact:fax>+1.844784784</contact:fax>
175+
<contact:email>[email protected]</contact:email>
176+
<contact:authInfo>
177+
<contact:pw>' . $auth . '</contact:pw>
178+
</contact:authInfo>
179+
<contact:disclose flag="1">
180+
<contact:voice/>
181+
</contact:disclose>
182+
<contact:disclose flag="0">
183+
<contact:email/>
184+
</contact:disclose>
185+
</contact:create>
186+
</create>
187+
</command>
188+
</epp>'
189+
);
190+
}
133191
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?php
2+
3+
namespace AfriCC\EPP\Frame\Command;
4+
5+
use AfriCC\EPP\Frame\Command\Update\Contact as UpdateContact;
6+
7+
class ContactUpdateTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testContactUpdate()
10+
{
11+
$frame = new UpdateContact;
12+
$frame->setId('C0054');
13+
$frame->addCity('Voerde');
14+
$frame->addAddStreet('Long St. 14');
15+
$frame->addAddStreet('CBD');
16+
$frame->changeAddStreet('Long St. 15');
17+
$frame->changeCity('Cape Town');
18+
$frame->removeAddStreet('Long St. 16');
19+
$frame->removeCity('Durban');
20+
21+
$this->assertXmlStringEqualsXmlString((string) $frame,
22+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
23+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
24+
<command>
25+
<update>
26+
<contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
27+
<contact:id>C0054</contact:id>
28+
<contact:add>
29+
<contact:postalInfo type="loc">
30+
<contact:addr>
31+
<contact:city>Voerde</contact:city>
32+
<contact:street>Long St. 14</contact:street>
33+
<contact:street>CBD</contact:street>
34+
</contact:addr>
35+
</contact:postalInfo>
36+
<contact:postalInfo type="int">
37+
<contact:addr>
38+
<contact:city>Voerde</contact:city>
39+
<contact:street>Long St. 14</contact:street>
40+
<contact:street>CBD</contact:street>
41+
</contact:addr>
42+
</contact:postalInfo>
43+
</contact:add>
44+
<contact:chg>
45+
<contact:postalInfo type="loc">
46+
<contact:addr>
47+
<contact:street>Long St. 15</contact:street>
48+
<contact:city>Cape Town</contact:city>
49+
</contact:addr>
50+
</contact:postalInfo>
51+
<contact:postalInfo type="int">
52+
<contact:addr>
53+
<contact:street>Long St. 15</contact:street>
54+
<contact:city>Cape Town</contact:city>
55+
</contact:addr>
56+
</contact:postalInfo>
57+
</contact:chg>
58+
<contact:rem>
59+
<contact:postalInfo type="loc">
60+
<contact:addr>
61+
<contact:street>Long St. 16</contact:street>
62+
<contact:city>Durban</contact:city>
63+
</contact:addr>
64+
</contact:postalInfo>
65+
<contact:postalInfo type="int">
66+
<contact:addr>
67+
<contact:street>Long St. 16</contact:street>
68+
<contact:city>Durban</contact:city>
69+
</contact:addr>
70+
</contact:postalInfo>
71+
</contact:rem>
72+
</contact:update>
73+
</update>
74+
</command>
75+
</epp>'
76+
);
77+
}
78+
79+
public function testContactUpdateDisclose()
80+
{
81+
$frame = new UpdateContact;
82+
$frame->setId('C0054');
83+
$frame->addCity('Voerde');
84+
$frame->addAddStreet('Long St. 14');
85+
$frame->addAddStreet('CBD');
86+
$frame->changeAddStreet('Long St. 15');
87+
$frame->changeCity('Cape Town');
88+
$frame->removeAddStreet('Long St. 16');
89+
$frame->removeCity('Durban');
90+
$frame->changeAddDisclose('voice', 1);
91+
$frame->changeAddDisclose('name[@type=\'int\']', 1);
92+
93+
$this->assertXmlStringEqualsXmlString((string) $frame,
94+
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>
95+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
96+
<command>
97+
<update>
98+
<contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
99+
<contact:id>C0054</contact:id>
100+
<contact:add>
101+
<contact:postalInfo type="loc">
102+
<contact:addr>
103+
<contact:city>Voerde</contact:city>
104+
<contact:street>Long St. 14</contact:street>
105+
<contact:street>CBD</contact:street>
106+
</contact:addr>
107+
</contact:postalInfo>
108+
<contact:postalInfo type="int">
109+
<contact:addr>
110+
<contact:city>Voerde</contact:city>
111+
<contact:street>Long St. 14</contact:street>
112+
<contact:street>CBD</contact:street>
113+
</contact:addr>
114+
</contact:postalInfo>
115+
</contact:add>
116+
<contact:chg>
117+
<contact:postalInfo type="loc">
118+
<contact:addr>
119+
<contact:street>Long St. 15</contact:street>
120+
<contact:city>Cape Town</contact:city>
121+
</contact:addr>
122+
</contact:postalInfo>
123+
<contact:postalInfo type="int">
124+
<contact:addr>
125+
<contact:street>Long St. 15</contact:street>
126+
<contact:city>Cape Town</contact:city>
127+
</contact:addr>
128+
</contact:postalInfo>
129+
<contact:disclose flag="1">
130+
<contact:voice/>
131+
<contact:name type="int"/>
132+
</contact:disclose>
133+
</contact:chg>
134+
<contact:rem>
135+
<contact:postalInfo type="loc">
136+
<contact:addr>
137+
<contact:street>Long St. 16</contact:street>
138+
<contact:city>Durban</contact:city>
139+
</contact:addr>
140+
</contact:postalInfo>
141+
<contact:postalInfo type="int">
142+
<contact:addr>
143+
<contact:street>Long St. 16</contact:street>
144+
<contact:city>Durban</contact:city>
145+
</contact:addr>
146+
</contact:postalInfo>
147+
</contact:rem>
148+
</contact:update>
149+
</update>
150+
</command>
151+
</epp>'
152+
);
153+
}
154+
}

0 commit comments

Comments
 (0)