public function testGetOutputTwoResourceSets()
    {
        $fakeResourceSet1 = Phockito::mock('POData\\Providers\\Metadata\\ResourceSetWrapper');
        Phockito::when($fakeResourceSet1->getName())->return("Name 1");
        $fakeResourceSet2 = Phockito::mock('POData\\Providers\\Metadata\\ResourceSetWrapper');
        //TODO: this certainly doesn't seem right...see #73
        Phockito::when($fakeResourceSet2->getName())->return("XML escaped stuff \" ' <> & ?");
        $fakeResourceSets = array($fakeResourceSet1, $fakeResourceSet2);
        Phockito::when($this->mockProvider->getResourceSets())->return($fakeResourceSets);
        $writer = new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $this->serviceBase);
        $actual = $writer->writeServiceDocument($this->mockProvider)->getOutput();
        $expected = '{
    "d":{
        "EntitySet":[
            "Name 1","XML escaped stuff \\" \' <> & ?"
        ]
    }
}';
        $this->assertEquals($expected, $actual);
    }
예제 #2
0
 /**
  * Gets resource sets which are visible
  * 
  * @return ResourceSetWrapper[]
  */
 public function getResourceSets()
 {
     return $this->providersWrapper->getResourceSets();
 }
예제 #3
0
 /**
  * @param ProvidersWrapper $providers
  * @return IODataWriter
  */
 public function writeServiceDocument(ProvidersWrapper $providers)
 {
     $writer = $this->_writer;
     $writer->startObjectScope()->writeName("d")->startObjectScope()->writeName(ODataConstants::ENTITY_SET)->startArrayScope();
     foreach ($providers->getResourceSets() as $resourceSetWrapper) {
         $writer->writeValue($resourceSetWrapper->getName());
     }
     $writer->endScope()->endScope()->endScope();
     return $this;
 }
예제 #4
0
 /**
  * @param ProvidersWrapper $providers
  * @return IODataWriter
  */
 public function writeServiceDocument(ProvidersWrapper $providers)
 {
     $writer = $this->xmlWriter;
     $writer->startElementNs(null, ODataConstants::ATOM_PUBLISHING_SERVICE_ELEMENT_NAME, ODataConstants::APP_NAMESPACE);
     $writer->writeAttributeNs(ODataConstants::XML_NAMESPACE_PREFIX, ODataConstants::XML_BASE_ATTRIBUTE_NAME, null, $this->baseUri);
     $writer->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::ATOM_NAMESPACE_PREFIX, null, ODataConstants::ATOM_NAMESPACE);
     $writer->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::APP_NAMESPACE_PREFIX, null, ODataConstants::APP_NAMESPACE);
     $writer->startElement(ODataConstants::ATOM_PUBLISHING_WORKSPACE_ELEMNT_NAME);
     $writer->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
     $writer->text(ODataConstants::ATOM_PUBLISHING_WORKSPACE_DEFAULT_VALUE);
     $writer->endElement();
     foreach ($providers->getResourceSets() as $resourceSetWrapper) {
         //start collection node
         $writer->startElement(ODataConstants::ATOM_PUBLISHING_COLLECTION_ELEMENT_NAME);
         $writer->writeAttribute(ODataConstants::ATOM_HREF_ATTRIBUTE_NAME, $resourceSetWrapper->getName());
         //start title node
         $writer->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
         $writer->text($resourceSetWrapper->getName());
         //end title node
         $writer->endElement();
         //end collection node
         $writer->endElement();
     }
     //End workspace and service nodes
     $writer->endElement();
     $writer->endElement();
     return $this;
 }
예제 #5
0
    public function testGetOutputTwoResourceSets()
    {
        $fakeResourceSet1 = Phockito::mock('POData\\Providers\\Metadata\\ResourceSetWrapper');
        Phockito::when($fakeResourceSet1->getName())->return("Name 1");
        $fakeResourceSet2 = Phockito::mock('POData\\Providers\\Metadata\\ResourceSetWrapper');
        //TODO: this certainly doesn't seem right...see #73
        Phockito::when($fakeResourceSet2->getName())->return("XML escaped stuff \" ' <> & ?");
        $fakeResourceSets = array($fakeResourceSet1, $fakeResourceSet2);
        Phockito::when($this->mockProvider->getResourceSets())->return($fakeResourceSets);
        $fakeBaseURL = "http://some/place/some/where/" . uniqid();
        $writer = new AtomODataWriter($fakeBaseURL);
        $actual = $writer->writeServiceDocument($this->mockProvider)->getOutput();
        $expected = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<service xml:base="' . $fakeBaseURL . '" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
 <workspace>
  <atom:title>Default</atom:title>
  <collection href="Name 1">
   <atom:title>Name 1</atom:title>
  </collection>
  <collection href="XML escaped stuff &quot; \' &lt;&gt; &amp; ?">
   <atom:title>XML escaped stuff &quot; \' &lt;&gt; &amp; ?</atom:title>
  </collection>
 </workspace>
</service>
';
        $this->assertEquals($expected, $actual);
    }