AccountRolesTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Endpoints;
  3. use Cloudflare\API\Adapter\Adapter;
  4. use Cloudflare\API\Endpoints\AccountRoles;
  5. use TestCase;
  6. class AccountRolesTest extends TestCase
  7. {
  8. public function testListAccountRoles()
  9. {
  10. $response = $this->getPsr7JsonResponseForFixture('Endpoints/listAccountRoles.json');
  11. $adapter = $this->getMockBuilder(Adapter::class)->getMock();
  12. $adapter->method('get')->willReturn($response);
  13. $adapter->expects($this->once())
  14. ->method('get')
  15. ->with($this->equalTo('accounts/023e105f4ecef8ad9ca31a8372d0c353/roles'));
  16. $roles = new AccountRoles($adapter);
  17. $result = $roles->listAccountRoles('023e105f4ecef8ad9ca31a8372d0c353');
  18. $this->assertObjectHasAttribute('result', $result);
  19. $this->assertObjectHasAttribute('result_info', $result);
  20. $this->assertEquals('3536bcfad5faccb999b47003c79917fb', $result->result[0]->id);
  21. $this->assertEquals(1, $result->result_info->page);
  22. $this->assertEquals('3536bcfad5faccb999b47003c79917fb', $roles->getBody()->result[0]->id);
  23. }
  24. }