コード例 #1
0
 /**
  * This method is called only once to initialize service-wide policies
  * 
  * @param ServiceConfiguration $config
  */
 public function initialize(ServiceConfiguration $config)
 {
     $config->setEntitySetAccessRule('*', EntitySetRights::ALL);
     //we are using V1 protocol, but still we set page size because with
     //a top value which is less than pagesize we can use V1 protocol
     //even though paging is enabled.
     $config->setEntitySetPageSize('*', 5);
     $config->setAcceptCountRequests(true);
     $config->setAcceptProjectionRequests(true);
     $config->setMaxDataServiceVersion(ProtocolVersion::V1());
 }
コード例 #2
0
ファイル: BaseServiceTest.php プロジェクト: grimmlink/podata
 public function testRegisterWritersV1()
 {
     /** @var BaseService $service */
     $service = Phockito::spy('\\POData\\BaseService');
     $service->setHost($this->mockHost);
     //TODO: have to do this since the registry & config is actually only instantiated during a handleRequest
     //will change this once that request pipeline is cleaned up
     Phockito::when($service->getODataWriterRegistry())->return($this->mockRegistry);
     $fakeConfig = new ServiceConfiguration($this->mockMetaProvider);
     $fakeConfig->setMaxDataServiceVersion(ProtocolVersion::V1());
     Phockito::when($service->getConfiguration())->return($fakeConfig);
     //fake the service url
     $fakeUrl = "http://host/service.svc/Collection";
     Phockito::when($this->mockHost->getAbsoluteServiceUri())->return(new Url($fakeUrl));
     Phockito::verify($this->mockRegistry, 0)->register(anything());
     //nothing should be registered at first
     $service->registerWriters();
     //only 2 writers for v1
     Phockito::verify($this->mockRegistry, 2)->register(anything());
     Phockito::verify($this->mockRegistry, 1)->register(anInstanceOf('\\POData\\Writers\\Atom\\AtomODataWriter'));
     Phockito::verify($this->mockRegistry, 1)->register(anInstanceOf('\\POData\\Writers\\Json\\JsonODataV1Writer'));
 }
コード例 #3
0
ファイル: UriProcessorTest.php プロジェクト: grimmlink/podata
 public function testProcessRequestForCollectionWithNoInlineCountWhenVersionIsTooLow()
 {
     //I'm not so sure about this test...basically $inlinecount is ignored if it's none, but maybe we should
     //be throwing an exception?
     $requestURI = new Url('http://host.com/data.svc/Collection/?$inlinecount=none');
     Phockito::when($this->mockServiceHost->getAbsoluteRequestUri())->return($requestURI);
     //mock inline count as all pages
     Phockito::when($this->mockServiceHost->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_INLINECOUNT))->return("none");
     $this->fakeServiceConfig->setAcceptCountRequests(true);
     $this->fakeServiceConfig->setMaxDataServiceVersion(ProtocolVersion::V1());
     $uriProcessor = UriProcessor::process($this->mockService);
     $fakeQueryResult = new QueryResult();
     $fakeQueryResult->results = array(1, 2, 3);
     $fakeQueryResult->count = 10;
     //note this is different than the size of the array
     Phockito::when($this->mockProvidersWrapper->getResourceSet(QueryType::ENTITIES(), $this->mockCollectionResourceSetWrapper, null, null, null, null))->return($fakeQueryResult);
     //indicate that POData must perform the paging (thus it will use the count of the results in QueryResult)
     Phockito::when($this->mockProvidersWrapper->handlesOrderedPaging())->return(false);
     $uriProcessor->execute();
     $request = $uriProcessor->getRequest();
     $actual = $request->getTargetResult();
     $this->assertEquals(array(1, 2, 3), $actual);
     $this->assertNull($request->getCountValue(), 'Since $inlinecount is specified as none, there should be no count set');
 }
コード例 #4
0
 /**
  * Gets Maximum version of the response sent by server.
  *
  * @return Version
  */
 public function getMaxDataServiceVersion()
 {
     switch ($this->maxVersion) {
         case ProtocolVersion::V1():
             return new Version(1, 0);
         case ProtocolVersion::V2():
             return new Version(2, 0);
         case ProtocolVersion::V3():
         default:
             return new Version(3, 0);
     }
 }