11<?php
2+
3+ use Cloudflare \API \Endpoints \Accounts ;
4+
25/**
36 * User: kanasite
47 * Date: 01/28/2019
@@ -24,7 +27,7 @@ public function testListZones()
2427 ])
2528 );
2629
27- $ accounts = new \ Cloudflare \ API \ Endpoints \ Accounts ($ mock );
30+ $ accounts = new Accounts ($ mock );
2831 $ result = $ accounts ->listAccounts (1 , 20 , 'desc ' );
2932
3033 $ this ->assertObjectHasAttribute ('result ' , $ result );
@@ -34,4 +37,50 @@ public function testListZones()
3437 $ this ->assertEquals (1 , $ result ->result_info ->page );
3538 $ this ->assertEquals ('023e105f4ecef8ad9ca31a8372d0c353 ' , $ accounts ->getBody ()->result [0 ]->id );
3639 }
40+
41+ public function testAddAccountWithDefaultType ()
42+ {
43+ $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/createStandardAccount.json ' );
44+
45+ $ mock = $ this ->getMockBuilder (\Cloudflare \API \Adapter \Adapter::class)->getMock ();
46+ $ mock ->method ('post ' )->willReturn ($ response );
47+
48+ $ mock ->expects ($ this ->once ())
49+ ->method ('post ' )
50+ ->with (
51+ $ this ->equalTo ('accounts ' ),
52+ $ this ->equalTo ([
53+ 'name ' => 'Foo Bar ' ,
54+ 'type ' => 'standard ' ,
55+ ])
56+ );
57+
58+ $ accounts = new Accounts ($ mock );
59+
60+ $ accounts ->addAccount ('Foo Bar ' );
61+ $ this ->assertEquals ('2bab6ace8c72ed3f09b9eca6db1396bb ' , $ accounts ->getBody ()->result ->id );
62+ }
63+
64+ public function testAddAccountWithCustomType ()
65+ {
66+ $ response = $ this ->getPsr7JsonResponseForFixture ('Endpoints/createEnterpriseAccount.json ' );
67+
68+ $ mock = $ this ->getMockBuilder (\Cloudflare \API \Adapter \Adapter::class)->getMock ();
69+ $ mock ->method ('post ' )->willReturn ($ response );
70+
71+ $ mock ->expects ($ this ->once ())
72+ ->method ('post ' )
73+ ->with (
74+ $ this ->equalTo ('accounts ' ),
75+ $ this ->equalTo ([
76+ 'name ' => 'Foo Bar ' ,
77+ 'type ' => 'enterprise ' ,
78+ ])
79+ );
80+
81+ $ accounts = new Accounts ($ mock );
82+
83+ $ accounts ->addAccount ('Foo Bar ' , 'enterprise ' );
84+ $ this ->assertEquals ('2bab6ace8c72ed3f09b9eca6db1396bb ' , $ accounts ->getBody ()->result ->id );
85+ }
3786}
0 commit comments