tests/UnitTests/POData/UriProcessor/QueryProcessor/SkipTokenParser/SkipTokenParserTest.php
/**
     * test skiptoken sub-values where type does not match with
     * corrseponding type of orderby path
     */
test skiptoken sub-values where type does not match with
corrseponding type of orderby path
test skiptoken sub - values where type does not match with corrseponding type of orderby path
public function testSkipTokenTypeInCompatibility()
    {
        $northWindMetadata = NorthWindMetadata::Create();
        $configuration = new ServiceConfiguration($northWindMetadata);
        $configuration->setEntitySetAccessRule('*', EntitySetRights::ALL);
        $providersWrapper = new ProvidersWrapper(
                                    $northWindMetadata, 
							        $this->mockQueryProvider,
                                    $configuration, 
                                    false
                                    );
        $resourceSetWrapper = $providersWrapper->resolveResourceSet('Orders');
        $resourceType = $resourceSetWrapper->getResourceType();
        $orderBy = 'ShipName asc, Price';
        $orderBy .= ', OrderID';
        $internalOrderByInfo = OrderByParser::parseOrderByClause($resourceSetWrapper, $resourceType, $orderBy, $providersWrapper);
        $skipToken = "datetime'1996-07-12T03%3A58%3A58', 22.00, 1234";
        $skipToken = urldecode($skipToken);
        try {
            $internalSkipTokenInfo = SkipTokenParser::parseSkipTokenClause($resourceType, $internalOrderByInfo, $skipToken);
            $this->fail('An expected ODataException for type mismatch (datetime and string) ');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('The skiptoken value \'datetime\'1996-07-12T03:58:58\', 22.00, 1234\' contain a value of type \'Edm.DateTime\' at position 0 which is not compatible with the type \'Edm.String\' of corresponding orderby constraint', $odataException->getMessage());
        }
        $skipToken = "'ANS', true, 1234";
        $skipToken = urldecode($skipToken);
        try {
            $internalSkipTokenInfo = SkipTokenParser::parseSkipTokenClause($resourceType, $internalOrderByInfo, $skipToken);
            $this->fail('An expected ODataException for type mismatch (boolean and double) ');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('The skiptoken value \'\'ANS\', true, 1234\' contain a value of type \'Edm.Boolean\' at position 1 which is not compatible with the type \'Edm.Double\' of corresponding orderby constraint', $odataException->getMessage());
        }
        $skipToken = "null, null, null";
        $internalSkipTokenInfo = SkipTokenParser::parseSkipTokenClause($resourceType, $internalOrderByInfo, $skipToken);
    }
public function testSkipTokenTypeInCompatibility ( ) { $ northWindMetadata = NorthWindMetadata :: Create ( ) ; $ configuration = new ServiceConfiguration ( $ northWindMetadata ) ; $ configuration -> setEntitySetAccessRule ( '*' , EntitySetRights :: ALL ) ; $ providersWrapper = new ProvidersWrapper ( $ northWindMetadata , $ this -> mockQueryProvider , $ configuration , false ) ; $ resourceSetWrapper = $ providersWrapper -> resolveResourceSet ( 'Orders' ) ; $ resourceType = $ resourceSetWrapper -> getResourceType ( ) ; $ orderBy = 'ShipName asc, Price' ; $ orderBy .= ', OrderID' ; $ internalOrderByInfo = OrderByParser :: parseOrderByClause ( $ resourceSetWrapper , $ resourceType , $ orderBy , $ providersWrapper ) ; $ skipToken = " datetime'1996-07-12T03%3A58%3A58', 22.00, 1234 " ; $ skipToken = urldecode ( $ skipToken ) ; try { $ internalSkipTokenInfo = SkipTokenParser :: parseSkipTokenClause ( $ resourceType , $ internalOrderByInfo , $ skipToken ) ; $ this -> fail ( 'An expected ODataException for type mismatch (datetime and string) ' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'The skiptoken value \'datetime\'1996-07-12T03:58:58\', 22.00, 1234\' contain a value of type \'Edm.DateTime\' at position 0 which is not compatible with the type \'Edm.String\' of corresponding orderby constraint' , $ odataException -> getMessage ( ) ) ; } $ skipToken = " 'ANS', true, 1234 " ; $ skipToken = urldecode ( $ skipToken ) ; try { $ internalSkipTokenInfo = SkipTokenParser :: parseSkipTokenClause ( $ resourceType , $ internalOrderByInfo , $ skipToken ) ; $ this -> fail ( 'An expected ODataException for type mismatch (boolean and double) ' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'The skiptoken value \'\'ANS\', true, 1234\' contain a value of type \'Edm.Boolean\' at position 1 which is not compatible with the type \'Edm.Double\' of corresponding orderby constraint' , $ odataException -> getMessage ( ) ) ; } $ skipToken = " null, null, null " ; $ internalSkipTokenInfo = SkipTokenParser :: parseSkipTokenClause ( $ resourceType , $ internalOrderByInfo , $ skipToken ) ; }
test skiptoken sub-values where type does not match with
 corrseponding type of orderby path
test skiptoken sub - values where type does not match with corrseponding type of orderby path
//IMetadataProvider implementation //Service configuration //Note: library will add prim key as last sort key //ShipName is String, but in skiptoken uses datetime //do decoding so token become "datetime'1996-07-12T03:58:58', 22.00, 1234"; //Price is Double, but in skiptoken uses true //null is allowed in skiptoken and compactable with all types