/**
  * Write the service document in Atom format.
  * 
  * @param Object &$dummy Dummy object
  * 
  * @return string
  */
 public function writeRequest(&$dummy)
 {
     $this->_xmlWriter = new \XMLWriter();
     $this->_xmlWriter->openMemory();
     $this->_xmlWriter->startElementNs(null, ODataConstants::ATOM_PUBLISHING_SERVICE_ELEMENT_NAME, ODataConstants::APP_NAMESPACE);
     $this->_xmlWriter->writeAttributeNs(ODataConstants::XML_NAMESPACE_PREFIX, ODataConstants::XML_BASE_ATTRIBUTE_NAME, null, $this->_baseUri);
     $this->_xmlWriter->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::ATOM_NAMESPACE_PREFIX, null, ODataConstants::ATOM_NAMESPACE);
     $this->_xmlWriter->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::APP_NAMESPACE_PREFIX, null, ODataConstants::APP_NAMESPACE);
     $this->_xmlWriter->startElement(ODataConstants::ATOM_PUBLISHING_WORKSPACE_ELEMNT_NAME);
     $this->_xmlWriter->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
     $this->_xmlWriter->text(ODataConstants::ATOM_PUBLISHING_WORKSPACE_DEFAULT_VALUE);
     $this->_xmlWriter->endElement();
     foreach ($this->_metadataQueryproviderWrapper->getResourceSets() as $resourceSetWrapper) {
         //start collection node
         $this->_xmlWriter->startElement(ODataConstants::ATOM_PUBLISHING_COLLECTION_ELEMENT_NAME);
         $this->_xmlWriter->writeAttribute(ODataConstants::ATOM_HREF_ATTRIBUTE_NAME, $resourceSetWrapper->getName());
         //start title node
         $this->_xmlWriter->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
         $this->_xmlWriter->text($resourceSetWrapper->getName());
         //end title node
         $this->_xmlWriter->endElement();
         //end collection node
         $this->_xmlWriter->endElement();
     }
     //End workspace and service nodes
     $this->_xmlWriter->endElement();
     $this->_xmlWriter->endElement();
     $serviceDocumentInAtom = $this->_xmlWriter->outputMemory(true);
     return $serviceDocumentInAtom;
 }
 /**
  * Write the service document in JSON format.
  * 
  * @param Object &$dummy Dummy object
  * 
  * @return string
  */
 public function writeRequest(&$dummy)
 {
     // { "d" :
     $this->_writer->startObjectScope();
     $this->_writer->writeDataWrapper();
     // {
     $this->_writer->startObjectScope();
     // "EntitySets"
     $this->_writer->writeName(ODataConstants::ENTITY_SET);
     // [
     $this->_writer->startArrayScope();
     foreach ($this->_metadataQueryproviderWrapper->getResourceSets() as $resourceSetWrapper) {
         $this->_writer->writeValue($resourceSetWrapper->getName());
     }
     // ]
     $this->_writer->endScope();
     // }
     $this->_writer->endScope();
     // }
     $this->_writer->endScope();
     //result
     $serviceDocumentInJson = $this->_writer->getJsonOutput();
     return $serviceDocumentInJson;
 }
 /**
  * Gets resource sets which are visible
  * 
  * @return array(ResourceSetWrapper)
  */
 public function getResourceSets()
 {
     return $this->_metadataQueryproviderWrapper->getResourceSets();
 }
 public function testGetResourceSets2()
 {
     try {
         //Try to get all resource sets with non of the resouce sets are visible
         $configuration = null;
         $metadataProvider = $this->_createMetadataAndConfiguration2($configuration);
         $metaQueryProverWrapper = new MetadataQueryProviderWrapper($metadataProvider, null, $configuration, false);
         $exceptionThrown = false;
         try {
             $metaQueryProverWrapper->getResourceSets();
         } catch (ODataException $exception) {
             $exceptionThrown = true;
             $this->assertEquals($exception->getMessage(), 'More than one entity set with the name \'Customers\' was found. Entity set names must be unique');
         }
         if (!$exceptionThrown) {
             $this->fail('An expected ODataException for entity set repetition has not been thrown');
         }
     } catch (\Exception $exception) {
         $this->fail('An unexpected Exception has been raised' . $exception->getMessage());
     }
 }