public function testConfiguration4() { $customersResourceSet = $this->_northWindMetadata->resolveResourceSet('Customers'); $this->assertNotNull($customersResourceSet); $this->AssertEquals($this->_dataServiceConfiguration->getEntitySetAccessRule($customersResourceSet), EntitySetRights::NONE); try { $this->_dataServiceConfiguration->setEntitySetAccessRule('Customers', EntitySetRights::ALL + 1); $this->fail('An expected InvalidOperationException for \'page size and max result per collection mutual exclusion\' was not thrown for month'); } catch (\InvalidArgumentException $exception) { $this->AssertEquals('The argument \'$rights\' of \'setEntitySetAccessRule\' should be EntitySetRights enum value', $exception->getMessage()); } $this->_dataServiceConfiguration->setEntitySetAccessRule('Customers', EntitySetRights::READ_ALL); $this->AssertEquals($this->_dataServiceConfiguration->getEntitySetAccessRule($customersResourceSet), EntitySetRights::READ_ALL); try { $this->_dataServiceConfiguration->setEntitySetAccessRule('NonExistEntitySet', EntitySetRights::READ_MULTIPLE); $this->fail('An expected InvalidArgumentException for \'non-exist entity set name\' was not thrown for month'); } catch (\InvalidArgumentException $exception) { $this->AssertEquals('The given name \'NonExistEntitySet\' was not found in the entity sets', $exception->getMessage()); } }
public function testGetResourceSetsSecondOneIsNotVisible() { $fakeSets = array($this->mockResourceSet, $this->mockResourceSet2); Phockito::when($this->mockMetadataProvider->getResourceSets())->return($fakeSets); Phockito::when($this->mockResourceSet->getName())->return("fake name 1"); Phockito::when($this->mockResourceSet2->getName())->return("fake name 2"); Phockito::when($this->mockResourceSet->getResourceType())->return($this->mockResourceType); Phockito::when($this->mockResourceSet2->getResourceType())->return($this->mockResourceType); Phockito::when($this->mockServiceConfig->getEntitySetAccessRule($this->mockResourceSet))->return(EntitySetRights::NONE); Phockito::when($this->mockServiceConfig->getEntitySetAccessRule($this->mockResourceSet2))->return(EntitySetRights::READ_SINGLE); $wrapper = $this->getMockedWrapper(); $actual = $wrapper->getResourceSets(); $expected = array(new ResourceSetWrapper($this->mockResourceSet2, $this->mockServiceConfig)); $this->assertEquals($expected, $actual); }
/** * Constructs a new instance of ResourceSetWrapper * * @param ResourceSet $resourceSet The resource set to wrap * @param ServiceConfiguration $configuration Configuration to take settings specific to wrapped resource set */ public function __construct(ResourceSet $resourceSet, ServiceConfiguration $configuration) { $this->_resourceSet = $resourceSet; $this->_resourceSetRights = $configuration->getEntitySetAccessRule($resourceSet); $this->_resourceSetPageSize = $configuration->getEntitySetPageSize($resourceSet); }