@@ -40,7 +40,9 @@ public function testAddZone()
4040 $ this ->equalTo ([
4141 'name ' => 'example.com ' ,
4242 'jump_start ' => true ,
43- 'organization ' => ['id ' => '01a7362d577a6c3019a474fd6f485823 ' ]
43+ 'account ' => [
44+ 'id ' => '01a7362d577a6c3019a474fd6f485823 ' ,
45+ ],
4446 ])
4547 );
4648
@@ -49,6 +51,33 @@ public function testAddZone()
4951 $ this ->assertEquals ('9a7806061c88ada191ed06f989cc3dac ' , $ zones ->getBody ()->result ->id );
5052 }
5153
54+ public function testAddZoneWithAccountId ()
55+ {
56+ $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/addZone.json ' );
57+
58+ $ mock = $ this ->getMockBuilder (\Cloudflare \API \Adapter \Adapter::class)->getMock ();
59+ $ mock ->method ('post ' )->willReturn ($ response );
60+
61+ $ mock ->expects ($ this ->once ())
62+ ->method ('post ' )
63+ ->with (
64+ $ this ->equalTo ('zones ' ),
65+ $ this ->equalTo ([
66+ 'name ' => 'example.com ' ,
67+ 'jump_start ' => false ,
68+ 'account ' => [
69+ 'id ' => '023e105f4ecef8ad9ca31a8372d0c353 ' ,
70+ ],
71+ ])
72+ );
73+
74+ $ zones = new \Cloudflare \API \Endpoints \Zones ($ mock );
75+ $ result = $ zones ->addZone ('example.com ' , false , '023e105f4ecef8ad9ca31a8372d0c353 ' );
76+
77+ $ this ->assertObjectHasAttribute ('id ' , $ result );
78+ $ this ->assertEquals ('023e105f4ecef8ad9ca31a8372d0c353 ' , $ result ->account ->id );
79+ }
80+
5281 public function testActivationTest ()
5382 {
5483 $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/activationTest.json ' );
@@ -188,78 +217,4 @@ public function testChangeDevelopmentMode()
188217 $ this ->assertTrue ($ result );
189218 $ this ->assertEquals ('development_mode ' , $ zones ->getBody ()->result ->id );
190219 }
191-
192- public function testCachePurgeEverything ()
193- {
194- $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/cachePurgeEverything.json ' );
195-
196- $ mock = $ this ->getMockBuilder (\Cloudflare \API \Adapter \Adapter::class)->getMock ();
197- $ mock ->method ('post ' )->willReturn ($ response );
198-
199- $ mock ->expects ($ this ->once ())
200- ->method ('post ' )
201- ->with (
202- $ this ->equalTo ('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache ' ),
203- $ this ->equalTo (['purge_everything ' => true ])
204- );
205-
206- $ zones = new \Cloudflare \API \Endpoints \Zones ($ mock );
207- $ result = $ zones ->cachePurgeEverything ('c2547eb745079dac9320b638f5e225cf483cc5cfdda41 ' );
208-
209- $ this ->assertTrue ($ result );
210- $ this ->assertEquals ('023e105f4ecef8ad9ca31a8372d0c353 ' , $ zones ->getBody ()->result ->id );
211- }
212-
213- public function testCachePurgeHost ()
214- {
215- $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/cachePurgeHost.json ' );
216-
217- $ mock = $ this ->getMockBuilder (\Cloudflare \API \Adapter \Adapter::class)->getMock ();
218- $ mock ->method ('post ' )->willReturn ($ response );
219-
220- $ mock ->expects ($ this ->once ())
221- ->method ('post ' )
222- ->with (
223- $ this ->equalTo ('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache ' ),
224- $ this ->equalTo (
225- [
226- 'files ' => [],
227- 'tags ' => [],
228- 'hosts ' => ['dash.cloudflare.com ' ]
229- ]
230- )
231- );
232-
233- $ zones = new \Cloudflare \API \Endpoints \Zones ($ mock );
234- $ result = $ zones ->cachePurge ('c2547eb745079dac9320b638f5e225cf483cc5cfdda41 ' , [], [], ['dash.cloudflare.com ' ]);
235-
236- $ this ->assertTrue ($ result );
237- $ this ->assertEquals ('023e105f4ecef8ad9ca31a8372d0c353 ' , $ zones ->getBody ()->result ->id );
238- }
239-
240- public function testCachePurge ()
241- {
242- $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/cachePurge.json ' );
243-
244- $ mock = $ this ->getMockBuilder (\Cloudflare \API \Adapter \Adapter::class)->getMock ();
245- $ mock ->method ('post ' )->willReturn ($ response );
246-
247- $ mock ->expects ($ this ->once ())
248- ->method ('post ' )
249- ->with (
250- $ this ->equalTo ('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache ' ),
251- $ this ->equalTo (['files ' => [
252- 'https://example.com/file.jpg ' ,
253- ]
254- ])
255- );
256-
257- $ zones = new \Cloudflare \API \Endpoints \Zones ($ mock );
258- $ result = $ zones ->cachePurge ('c2547eb745079dac9320b638f5e225cf483cc5cfdda41 ' , [
259- 'https://example.com/file.jpg ' ,
260- ]);
261-
262- $ this ->assertTrue ($ result );
263- $ this ->assertEquals ('023e105f4ecef8ad9ca31a8372d0c353 ' , $ zones ->getBody ()->result ->id );
264- }
265220}
0 commit comments