Example #1
0
 public function testXrnParsing()
 {
     $resource = new Resource('xrn:partition:service:region:account:resourceType/resourceKey');
     $this->assertEquals($resource->getPartition(), 'partition');
     $this->assertEquals($resource->getService(), 'service');
     $this->assertEquals($resource->getRegion(), 'region');
     $this->assertEquals($resource->getAccount(), 'account');
     $this->assertEquals($resource->getResourceType(), 'resourceType');
     $this->assertEquals($resource->getResourceKey(), 'resourceKey');
     $resource = new Resource('xrn:partition:service:region:account:t:k');
     $this->assertEquals($resource->getResourceType(), 't');
     $this->assertEquals($resource->getResourceKey(), 'k');
     $resource = new Resource('xrn:partition:service:region:account:x');
     $this->assertEquals($resource->getResourceType(), '');
     $this->assertEquals($resource->getResourceKey(), 'x');
 }
 private function matchResource(Resource $resource1, Resource $resource2)
 {
     if (!$this->matchString($resource1->getPartition(), $resource2->getPartition())) {
         return false;
     }
     if (!$this->matchString($resource1->getService(), $resource2->getService())) {
         return false;
     }
     if (!$this->matchString($resource1->getRegion(), $resource2->getRegion())) {
         return false;
     }
     if (!$this->matchString($resource1->getAccount(), $resource2->getAccount())) {
         return false;
     }
     if (!$this->matchString($resource1->getResourceType(), $resource2->getResourceType())) {
         return false;
     }
     if (!$this->matchString($resource1->getResourceKey(), $resource2->getResourceKey())) {
         return false;
     }
     return true;
 }