Beispiel #1
0
 public function testRaiseVersion()
 {
     $version = new Version(2, 0);
     $version->raiseVersion(1, 5);
     $this->assertEquals(2, $version->getMajor());
     $this->assertEquals(0, $version->getMinor());
     $version->raiseVersion(3, 0);
     $this->assertEquals(3, $version->getMajor());
     $this->assertEquals(0, $version->getMinor());
     $version->raiseVersion(3, 1);
     $this->assertEquals(3, $version->getMajor());
     $this->assertEquals(1, $version->getMinor());
 }
 public function provider()
 {
     $v1 = Version::v1();
     $v2 = Version::v2();
     $v3 = Version::v3();
     return array(array(101, TargetKind::METADATA(), $v1, null, null, MimeTypes::MIME_APPLICATION_XML), array(102, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_XML, null, MimeTypes::MIME_APPLICATION_XML), array(103, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, null), array(104, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(105, TargetKind::METADATA(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(106, TargetKind::METADATA(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(108, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, null), array(109, TargetKind::METADATA(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, null), array(110, TargetKind::METADATA(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, null), array(111, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, null), array(112, TargetKind::METADATA(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, null), array(113, TargetKind::METADATA(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, null), array(114, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, null), array(115, TargetKind::METADATA(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, null), array(116, TargetKind::METADATA(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, null), array(124, TargetKind::METADATA(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, null), array(125, TargetKind::METADATA(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, null), array(126, TargetKind::METADATA(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, null), array(201, TargetKind::SERVICE_DIRECTORY(), $v1, null, null, MimeTypes::MIME_APPLICATION_XML), array(202, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_ATOMSERVICE, null, MimeTypes::MIME_APPLICATION_ATOMSERVICE), array(203, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_JSON, null, MimeTypes::MIME_APPLICATION_JSON), array(204, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, null), array(205, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_ATOM, MimeTypes::MIME_APPLICATION_JSON, MimeTypes::MIME_APPLICATION_JSON), array(206, TargetKind::SERVICE_DIRECTORY(), $v2, MimeTypes::MIME_APPLICATION_ATOM, MimeTypes::MIME_APPLICATION_JSON, MimeTypes::MIME_APPLICATION_JSON), array(207, TargetKind::SERVICE_DIRECTORY(), $v3, MimeTypes::MIME_APPLICATION_ATOM, MimeTypes::MIME_APPLICATION_JSON, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(208, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(209, TargetKind::SERVICE_DIRECTORY(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(210, TargetKind::SERVICE_DIRECTORY(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(211, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(212, TargetKind::SERVICE_DIRECTORY(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(213, TargetKind::SERVICE_DIRECTORY(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(214, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(215, TargetKind::SERVICE_DIRECTORY(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(216, TargetKind::SERVICE_DIRECTORY(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(224, TargetKind::SERVICE_DIRECTORY(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(225, TargetKind::SERVICE_DIRECTORY(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(226, TargetKind::SERVICE_DIRECTORY(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(400, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_XML, null, MimeTypes::MIME_APPLICATION_XML), array(401, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_TEXTXML, null, MimeTypes::MIME_TEXTXML), array(402, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_JSON, null, MimeTypes::MIME_APPLICATION_JSON), array(403, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, null), array(404, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(405, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(406, TargetKind::PRIMITIVE(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(407, TargetKind::PRIMITIVE(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(408, TargetKind::PRIMITIVE(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(409, TargetKind::PRIMITIVE(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(418, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(419, TargetKind::PRIMITIVE(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(420, TargetKind::PRIMITIVE(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(421, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(422, TargetKind::PRIMITIVE(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(423, TargetKind::PRIMITIVE(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(424, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(425, TargetKind::PRIMITIVE(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(426, TargetKind::PRIMITIVE(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(434, TargetKind::PRIMITIVE(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(435, TargetKind::PRIMITIVE(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(436, TargetKind::PRIMITIVE(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(500, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_XML, null, MimeTypes::MIME_APPLICATION_XML), array(501, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_TEXTXML, null, MimeTypes::MIME_TEXTXML), array(502, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_JSON, null, MimeTypes::MIME_APPLICATION_JSON), array(503, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, null), array(504, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(505, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(506, TargetKind::COMPLEX_OBJECT(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(507, TargetKind::COMPLEX_OBJECT(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(508, TargetKind::COMPLEX_OBJECT(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(509, TargetKind::COMPLEX_OBJECT(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(518, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(519, TargetKind::COMPLEX_OBJECT(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(520, TargetKind::COMPLEX_OBJECT(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(521, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(522, TargetKind::COMPLEX_OBJECT(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(523, TargetKind::COMPLEX_OBJECT(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(524, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(525, TargetKind::COMPLEX_OBJECT(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(526, TargetKind::COMPLEX_OBJECT(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(534, TargetKind::COMPLEX_OBJECT(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(535, TargetKind::COMPLEX_OBJECT(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(536, TargetKind::COMPLEX_OBJECT(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(600, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_XML, null, MimeTypes::MIME_APPLICATION_XML), array(601, TargetKind::BAG(), $v1, MimeTypes::MIME_TEXTXML, null, MimeTypes::MIME_TEXTXML), array(602, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_JSON, null, MimeTypes::MIME_APPLICATION_JSON), array(603, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, null), array(604, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(605, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(606, TargetKind::BAG(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(607, TargetKind::BAG(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(608, TargetKind::BAG(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(609, TargetKind::BAG(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(618, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(619, TargetKind::BAG(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(620, TargetKind::BAG(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(621, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(622, TargetKind::BAG(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(623, TargetKind::BAG(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(624, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(625, TargetKind::BAG(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(626, TargetKind::BAG(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(634, TargetKind::BAG(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(635, TargetKind::BAG(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(636, TargetKind::BAG(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(700, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_XML, null, MimeTypes::MIME_APPLICATION_XML), array(701, TargetKind::LINK(), $v1, MimeTypes::MIME_TEXTXML, null, MimeTypes::MIME_TEXTXML), array(702, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_JSON, null, MimeTypes::MIME_APPLICATION_JSON), array(703, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, null), array(704, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(705, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(706, TargetKind::LINK(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(707, TargetKind::LINK(), $v2, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(708, TargetKind::LINK(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_XML, MimeTypes::MIME_APPLICATION_XML), array(709, TargetKind::LINK(), $v3, MimeTypes::MIME_APPLICATION_ATOM, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(718, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(719, TargetKind::LINK(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(720, TargetKind::LINK(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(721, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(722, TargetKind::LINK(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(723, TargetKind::LINK(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(724, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(725, TargetKind::LINK(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(726, TargetKind::LINK(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(734, TargetKind::LINK(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(735, TargetKind::LINK(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(736, TargetKind::LINK(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(800, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_ATOM, null, MimeTypes::MIME_APPLICATION_ATOM), array(802, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_JSON, null, MimeTypes::MIME_APPLICATION_JSON), array(803, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_XML, null, null), array(804, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_XML, ODataConstants::FORMAT_ATOM, MimeTypes::MIME_APPLICATION_ATOM), array(805, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_XML, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(806, TargetKind::RESOURCE(), $v2, MimeTypes::MIME_APPLICATION_XML, ODataConstants::FORMAT_ATOM, MimeTypes::MIME_APPLICATION_ATOM), array(807, TargetKind::RESOURCE(), $v2, MimeTypes::MIME_APPLICATION_XML, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON), array(808, TargetKind::RESOURCE(), $v3, MimeTypes::MIME_APPLICATION_XML, ODataConstants::FORMAT_ATOM, MimeTypes::MIME_APPLICATION_ATOM), array(809, TargetKind::RESOURCE(), $v3, MimeTypes::MIME_APPLICATION_XML, ODataConstants::FORMAT_JSON, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(818, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(819, TargetKind::RESOURCE(), $v2, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(820, TargetKind::RESOURCE(), $v3, MimeTypes::MIME_APPLICATION_JSON_FULL_META, null, MimeTypes::MIME_APPLICATION_JSON_FULL_META), array(821, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(822, TargetKind::RESOURCE(), $v2, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(823, TargetKind::RESOURCE(), $v3, MimeTypes::MIME_APPLICATION_JSON_NO_META, null, MimeTypes::MIME_APPLICATION_JSON_NO_META), array(824, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(825, TargetKind::RESOURCE(), $v2, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(826, TargetKind::RESOURCE(), $v3, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, null, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META), array(834, TargetKind::RESOURCE(), $v1, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(835, TargetKind::RESOURCE(), $v2, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE), array(836, TargetKind::RESOURCE(), $v3, MimeTypes::MIME_APPLICATION_JSON_VERBOSE, null, MimeTypes::MIME_APPLICATION_JSON_VERBOSE));
 }
 /**
  * Determines if the given writer is capable of writing the response or not
  * @param Version $responseVersion the OData version of the response
  * @param string $contentType the Content Type of the response
  * @return boolean true if the writer can handle the response, false otherwise
  */
 public function canHandle(Version $responseVersion, $contentType)
 {
     if ($responseVersion != Version::v1()) {
         return false;
     }
     $parts = explode(";", $contentType);
     return in_array(MimeTypes::MIME_APPLICATION_JSON, $parts);
 }
 /**
  * Determines if the given writer is capable of writing the response or not
  * @param Version $responseVersion the OData version of the response
  * @param string $contentType the Content Type of the response
  * @return boolean true if the writer can handle the response, false otherwise
  */
 public function canHandle(Version $responseVersion, $contentType)
 {
     if ($responseVersion != Version::v3()) {
         return false;
     }
     $parts = explode(";", $contentType);
     //It must be app/json and have the right odata= piece
     return in_array(MimeTypes::MIME_APPLICATION_JSON, $parts) && in_array($this->metadataLevel->getValue(), $parts);
 }
 public function testRegister()
 {
     $registry = new ODataWriterRegistry();
     $registry->register($this->mockWriter1);
     $registry->register($this->mockWriter2);
     Phockito::when($this->mockWriter2->canHandle(Version::v2(), MimeTypes::MIME_APPLICATION_ATOM))->return(true);
     $this->assertEquals($this->mockWriter2, $registry->getWriter(Version::v2(), MimeTypes::MIME_APPLICATION_ATOM));
     $this->assertNull($registry->getWriter(Version::v1(), MimeTypes::MIME_APPLICATION_ATOM));
     //now clear it, should be no matches
     $registry->reset();
     $this->assertNull($registry->getWriter(Version::v2(), MimeTypes::MIME_APPLICATION_ATOM));
 }
 /**
  * Determines if the given writer is capable of writing the response or not
  * @param Version $responseVersion the OData version of the response
  * @param string $contentType the Content Type of the response
  * @return boolean true if the writer can handle the response, false otherwise
  */
 public function canHandle(Version $responseVersion, $contentType)
 {
     $parts = explode(";", $contentType);
     //special case, in v3 verbose is the v2 writer
     if ($responseVersion == Version::v3()) {
         return in_array(MimeTypes::MIME_APPLICATION_JSON, $parts) && in_array('odata=verbose', $parts);
     }
     if ($responseVersion != Version::v2()) {
         return false;
     }
     return in_array(MimeTypes::MIME_APPLICATION_JSON, $parts);
 }
 /**
  * This function is used to perform following checking (validation)
  * for capability negotiation.
  *  (1) Check client request's 'DataServiceVersion' header value is 
  *      less than or equal to the minimum version required to intercept
  *      the response
  *  (2) Check client request's 'MaxDataServiceVersion' header value is
  *      less than or equal to the version of protocol required to generate
  *      the response
  *  (3) Check the configured maximum protocol version is less than or equal 
  *      to the version of protocol required to generate the response
  *  In addition to these checking, this function is also responsible for
  *  initializing the properties representing 'DataServiceVersion' and
  *  'MaxDataServiceVersion'.
  *  
  *
  * @throws ODataException If any of the above 3 check fails.
  */
 public function validateVersions()
 {
     //If the request version is below the minimum version required by supplied request arguments..throw an exception
     if ($this->requestVersion->compare($this->requiredMinRequestVersion) < 0) {
         throw ODataException::createBadRequestError(Messages::requestVersionTooLow($this->requestVersion->toString(), $this->requiredMinRequestVersion->toString()));
     }
     //If the requested max version is below the version required to fulfill the response...throw an exception
     if ($this->requestMaxVersion->compare($this->requiredMinResponseVersion) < 0) {
         throw ODataException::createBadRequestError(Messages::requestVersionTooLow($this->requestMaxVersion->toString(), $this->requiredMinResponseVersion->toString()));
     }
     //If the max version supported by the service is below the version required to fulfill the response..throw an exception
     if ($this->maxServiceVersion->compare($this->requiredMinResponseVersion) < 0) {
         throw ODataException::createBadRequestError(Messages::requestVersionIsBiggerThanProtocolVersion($this->requiredMinResponseVersion->toString(), $this->maxServiceVersion->toString()));
     }
 }
Beispiel #8
0
 /**
  * Write the metadata in CSDL format.
  * 
  * @return string
  */
 public function writeMetadata()
 {
     $this->_metadataManager = MetadataManager::create($this->providersWrapper);
     $this->_dataServiceVersion = new Version(1, 0);
     $edmSchemaVersion = $this->providersWrapper->getEdmSchemaVersion();
     $this->_metadataManager->getDataServiceAndEdmSchemaVersions($this->_dataServiceVersion, $edmSchemaVersion);
     $this->_xmlWriter = new \XMLWriter();
     $this->_xmlWriter->openMemory();
     $this->_xmlWriter->setIndent(4);
     $this->_writeTopLevelElements($this->_dataServiceVersion->toString());
     $resourceTypesInContainerNamespace = array();
     $containerNamespace = $this->providersWrapper->getContainerNamespace();
     foreach ($this->_metadataManager->getResourceTypesAlongWithNamespace() as $resourceTypeNamespace => $resourceTypesWithName) {
         if ($resourceTypeNamespace == $containerNamespace) {
             foreach ($resourceTypesWithName as $resourceTypeName => $resourceType) {
                 $resourceTypesInContainerNamespace[] = $resourceType;
             }
         } else {
             $associationsInThisNamespace = $this->_metadataManager->getResourceAssociationTypesForNamespace($resourceTypeNamespace);
             $this->_writeSchemaElement($resourceTypeNamespace, $edmSchemaVersion);
             $uniqueAssociationsInThisNamespace = $this->_metadataManager->getUniqueResourceAssociationTypesForNamespace($resourceTypeNamespace);
             $this->_writeResourceTypes(array_values($resourceTypesWithName), $associationsInThisNamespace);
             $this->_writeAssociationTypes($uniqueAssociationsInThisNamespace);
         }
     }
     //write Container schema node and define required nmaespaces
     $this->_writeSchemaElement($resourceTypeNamespace, $edmSchemaVersion);
     if (!empty($resourceTypesInContainerNamespace)) {
         //Get assocation types in container namespace as array of
         //key-value pairs (with key as association type
         //lookup key i.e. ResourceType::Name_NavigationProperty::Name.
         //Same association will appear twice for di-directional relationship
         //(duplicate value will be there in this case)
         $associationsInThisNamespace = $this->_metadataManager->getResourceAssociationTypesForNamespace($containerNamespace);
         //Get association type in container namespace as array of unique values
         $uniqueAssociationsInThisNamespace = $this->_metadataManager->getUniqueResourceAssociationTypesForNamespace($containerNamespace);
         $this->_writeResourceTypes($resourceTypesInContainerNamespace, $associationsInThisNamespace);
         $this->_writeAssociationTypes($uniqueAssociationsInThisNamespace);
     }
     $this->_writeEntityContainer();
     //End container Schema node
     $this->_xmlWriter->endElement();
     //End edmx:Edmx and edmx:DataServices nodes
     $this->_xmlWriter->endElement();
     $this->_xmlWriter->endElement();
     $metadataInCsdl = $this->_xmlWriter->outputMemory(true);
     return $metadataInCsdl;
 }
Beispiel #9
0
 public function testTranslateFormatToMimeVersion30FormatRandom()
 {
     $format = uniqid("xxx");
     $actual = ServiceHost::translateFormatToMime(Version::v3(), $format);
     $expected = "{$format};q=1.0";
     $this->assertEquals($expected, $actual);
 }
Beispiel #10
0
 /**
  * Gets the response format for the requested resource.
  * 
  * @param RequestDescription $request The request submitted by client and it's execution result.
  * @param UriProcessor $uriProcessor The reference to the UriProcessor.
  * @param IService $service Reference to the service implementation instance
  *
  * @return string the response content-type, a null value means the requested resource
  * is named stream and IDSSP2::getStreamContentType returned null
  * 
  * @throws ODataException, HttpHeaderFailure
  */
 public static function getResponseContentType(RequestDescription $request, UriProcessor $uriProcessor, IService $service)
 {
     // The Accept request-header field specifies media types which are acceptable for the response
     $host = $service->getHost();
     $requestAcceptText = $host->getRequestAccept();
     $requestVersion = $request->getResponseVersion();
     //if the $format header is present it overrides the accepts header
     $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT);
     if (!is_null($format)) {
         //There's a strange edge case..if application/json is supplied and it's V3
         if ($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()) {
             //then it's actual minimalmetadata
             //TODO: should this be done with the header text too?
             $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META;
         }
         $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format);
     }
     //The response format can be dictated by the target resource kind. IE a $value will be different then expected
     //getTargetKind doesn't deal with link resources directly and this can change things
     $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind();
     switch ($targetKind) {
         case TargetKind::METADATA():
             return HttpProcessUtility::selectMimeType($requestAcceptText, array(MimeTypes::MIME_APPLICATION_XML));
         case TargetKind::SERVICE_DIRECTORY():
             return HttpProcessUtility::selectMimeType($requestAcceptText, array(MimeTypes::MIME_APPLICATION_XML, MimeTypes::MIME_APPLICATION_ATOMSERVICE, MimeTypes::MIME_APPLICATION_JSON, MimeTypes::MIME_APPLICATION_JSON_FULL_META, MimeTypes::MIME_APPLICATION_JSON_NO_META, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, MimeTypes::MIME_APPLICATION_JSON_VERBOSE));
         case TargetKind::PRIMITIVE_VALUE():
             $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN);
             if ($request->getIdentifier() != '$count') {
                 $projectedProperty = $request->getProjectedProperty();
                 self::assert(!is_null($projectedProperty), '!is_null($projectedProperty)');
                 $type = $projectedProperty->getInstanceType();
                 self::assert(!is_null($type) && $type instanceof IType, '!is_null($type) && $type instanceof IType');
                 if ($type instanceof Binary) {
                     $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM);
                 }
             }
             return HttpProcessUtility::selectMimeType($requestAcceptText, $supportedResponseMimeTypes);
         case TargetKind::PRIMITIVE():
         case TargetKind::COMPLEX_OBJECT():
         case TargetKind::BAG():
         case TargetKind::LINK():
             return HttpProcessUtility::selectMimeType($requestAcceptText, array(MimeTypes::MIME_APPLICATION_XML, MimeTypes::MIME_TEXTXML, MimeTypes::MIME_APPLICATION_JSON, MimeTypes::MIME_APPLICATION_JSON_FULL_META, MimeTypes::MIME_APPLICATION_JSON_NO_META, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, MimeTypes::MIME_APPLICATION_JSON_VERBOSE));
         case TargetKind::RESOURCE():
             return HttpProcessUtility::selectMimeType($requestAcceptText, array(MimeTypes::MIME_APPLICATION_ATOM, MimeTypes::MIME_APPLICATION_JSON, MimeTypes::MIME_APPLICATION_JSON_FULL_META, MimeTypes::MIME_APPLICATION_JSON_NO_META, MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, MimeTypes::MIME_APPLICATION_JSON_VERBOSE));
         case TargetKind::MEDIA_RESOURCE():
             if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()) {
                 throw ODataException::createBadRequestError(Messages::badRequestInvalidUriForMediaResource($host->getAbsoluteRequestUri()->getUrlAsString()));
             }
             $uriProcessor->execute();
             $request->setExecuted();
             // DSSW::getStreamContentType can throw error in 2 cases
             // 1. If the required stream implementation not found
             // 2. If IDSSP::getStreamContentType returns NULL for MLE
             $responseContentType = $service->getStreamProviderWrapper()->getStreamContentType($request->getTargetResult(), $request->getResourceStreamInfo());
             // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not
             // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error
             if (!is_null($responseContentType)) {
                 $responseContentType = HttpProcessUtility::selectMimeType($requestAcceptText, array($responseContentType));
             }
             return $responseContentType;
     }
     //If we got here, we just don't know what it is...
     throw new ODataException(Messages::unsupportedMediaType(), 415);
 }
 public function canHandleProvider()
 {
     return array(array(100, Version::v1(), MimeTypes::MIME_APPLICATION_ATOMSERVICE, false), array(101, Version::v2(), MimeTypes::MIME_APPLICATION_ATOMSERVICE, false), array(102, Version::v3(), MimeTypes::MIME_APPLICATION_ATOMSERVICE, false), array(200, Version::v1(), MimeTypes::MIME_APPLICATION_JSON, false), array(201, Version::v2(), MimeTypes::MIME_APPLICATION_JSON, false), array(202, Version::v3(), MimeTypes::MIME_APPLICATION_JSON, false), array(300, Version::v1(), MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, false), array(301, Version::v2(), MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, false), array(302, Version::v3(), MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, false), array(400, Version::v1(), MimeTypes::MIME_APPLICATION_JSON_NO_META, false), array(401, Version::v2(), MimeTypes::MIME_APPLICATION_JSON_NO_META, false), array(402, Version::v3(), MimeTypes::MIME_APPLICATION_JSON_NO_META, false), array(500, Version::v1(), MimeTypes::MIME_APPLICATION_JSON_FULL_META, false), array(501, Version::v2(), MimeTypes::MIME_APPLICATION_JSON_FULL_META, false), array(502, Version::v3(), MimeTypes::MIME_APPLICATION_JSON_FULL_META, true), array(600, Version::v1(), MimeTypes::MIME_APPLICATION_JSON_VERBOSE, false), array(601, Version::v2(), MimeTypes::MIME_APPLICATION_JSON_VERBOSE, false), array(602, Version::v3(), MimeTypes::MIME_APPLICATION_JSON_VERBOSE, false));
 }
Beispiel #12
0
 /**
  * Get appropriate data service and edm schema version
  * 
  * @param Version &$dsVersion        On return, this parmater will contain 
  *                                   data service version for the metadata
  * @param string  &$edmSchemaVersion On return, this parmater will contain 
  *                                   edm schema version for the metadata
  * 
  * @return void 
  */
 public function getDataServiceAndEdmSchemaVersions(Version &$dsVersion, &$edmSchemaVersion)
 {
     if ($this->_metadataResourceTypeSet->hasNamedStreams()) {
         $dsVersion->raiseVersion(3, 0);
         if ($edmSchemaVersion < EdmSchemaVersion::VERSION_2_DOT_0) {
             $edmSchemaVersion = EdmSchemaVersion::VERSION_2_DOT_0;
         }
     }
     if ($this->_metadataResourceTypeSet->hasBagProperty()) {
         $dsVersion->raiseVersion(3, 0);
         if ($edmSchemaVersion < EdmSchemaVersion::VERSION_2_DOT_2) {
             $edmSchemaVersion = EdmSchemaVersion::VERSION_2_DOT_2;
         }
     }
 }
Beispiel #13
0
 /**
  * Translates the short $format forms into the full mime type forms
  * @param Version $responseVersion the version scheme to interpret the short form with
  * @param string $format the short $format form
  * @return string the full mime type corresponding to the short format form for the given version
  */
 public static function translateFormatToMime(Version $responseVersion, $format)
 {
     //TODO: should the version switches be off of the requestVersion, not the response version? see #91
     switch ($format) {
         case ODataConstants::FORMAT_XML:
             $format = MimeTypes::MIME_APPLICATION_XML;
             break;
         case ODataConstants::FORMAT_ATOM:
             $format = MimeTypes::MIME_APPLICATION_ATOM;
             break;
         case ODataConstants::FORMAT_VERBOSE_JSON:
             if ($responseVersion == Version::v3()) {
                 //only translatable in 3.0 systems
                 $format = MimeTypes::MIME_APPLICATION_JSON_VERBOSE;
             }
             break;
         case ODataConstants::FORMAT_JSON:
             if ($responseVersion == Version::v3()) {
                 $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META;
             } else {
                 $format = MimeTypes::MIME_APPLICATION_JSON;
             }
             break;
     }
     return $format . ';q=1.0';
 }
 public function testGetResponseVersionConfigMaxVersion30RequestVersion30RequestMaxVersion30()
 {
     $requestVersion = "3.0";
     $requestMaxVersion = "3.0";
     $fakeConfigMaxVersion = Version::v3();
     Phockito::when($this->mockServiceConfiguration->getMaxDataServiceVersion())->return($fakeConfigMaxVersion);
     $fakeURL = new Url("http://host/service.svc/Collection");
     $fakeSegments = array(new SegmentDescriptor());
     $request = new RequestDescription($fakeSegments, $fakeURL, $fakeConfigMaxVersion, $requestVersion, $requestMaxVersion);
     //This respects the max version
     $this->assertEquals(Version::v3(), $request->getResponseVersion());
     $request->raiseResponseVersion(2, 0);
     //max is already 3, so this is allowed
     $this->assertEquals(Version::v3(), $request->getResponseVersion());
     $request->raiseResponseVersion(3, 0);
     //max is already 3 ditto
     $this->assertEquals(Version::v3(), $request->getResponseVersion());
 }
 public function canHandleProvider()
 {
     return array(array(100, Version::v1(), MimeTypes::MIME_APPLICATION_ATOMSERVICE, true), array(101, Version::v2(), MimeTypes::MIME_APPLICATION_ATOMSERVICE, true), array(102, Version::v3(), MimeTypes::MIME_APPLICATION_ATOMSERVICE, true), array(200, Version::v1(), MimeTypes::MIME_APPLICATION_XML, true), array(201, Version::v2(), MimeTypes::MIME_APPLICATION_XML, true), array(202, Version::v3(), MimeTypes::MIME_APPLICATION_XML, true), array(300, Version::v1(), MimeTypes::MIME_APPLICATION_ATOM, true), array(301, Version::v2(), MimeTypes::MIME_APPLICATION_ATOM, true), array(302, Version::v3(), MimeTypes::MIME_APPLICATION_ATOM, true));
 }