tests/UnitTests/POData/UriProcessor/QueryProcessor/SkipTokenParser/SkipTokenParserTest.php
/**
     * Skiptoken should not contain leading and trailing commas, use
     * commas only to separate token sub-values.
     */
Skiptoken should not contain leading and trailing commas, use
commas only to separate token sub-values.
Skiptoken should not contain leading and trailing commas use commas only to separate token sub - values .
public function testSkipTokenWithLeadingAndTrailingCommas()
    {
        $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 = "'Antonio%20Moreno%20Taquer%C3%ADa',22.000,10365,";
        $skipToken = urldecode($skipToken);
        try {
            $internalSkipTokenInfo = SkipTokenParser::parseSkipTokenClause($resourceType, $internalOrderByInfo, $skipToken);
            $this->fail('An expected ODataException for syntax error has not been raised (because of trailing comma)');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('Bad Request - Error in the syntax of skiptoken', $odataException->getMessage());
        }
        $skipToken = ",'Antonio%20Moreno%20Taquer%C3%ADa',22.000,10365,";
        $skipToken = urldecode($skipToken);
        try {
            $internalSkipTokenInfo = SkipTokenParser::parseSkipTokenClause($resourceType, $internalOrderByInfo, $skipToken);
            $this->fail('An expected ODataException for syntax error has not been raised (because of leading comma)');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('Bad Request - Error in the syntax of skiptoken', $odataException->getMessage());
        }
        $skipToken = "'Antonio%20Moreno%20Taquer%C3%ADa',,22.000,10365,";
        $skipToken = urldecode($skipToken);
        try {
            $internalSkipTokenInfo = SkipTokenParser::parseSkipTokenClause($resourceType, $internalOrderByInfo, $skipToken);
            $this->fail('An expected ODataException for syntax error has not been raised (because of extra comma)');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('Bad Request - Error in the syntax of skiptoken', $odataException->getMessage());
        }
    }
public function testSkipTokenWithLeadingAndTrailingCommas ( ) { $ 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 = " 'Antonio%20Moreno%20Taquer%C3%ADa',22.000,10365, " ; $ skipToken = urldecode ( $ skipToken ) ; try { $ internalSkipTokenInfo = SkipTokenParser :: parseSkipTokenClause ( $ resourceType , $ internalOrderByInfo , $ skipToken ) ; $ this -> fail ( 'An expected ODataException for syntax error has not been raised (because of trailing comma)' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'Bad Request - Error in the syntax of skiptoken' , $ odataException -> getMessage ( ) ) ; } $ skipToken = " ,'Antonio%20Moreno%20Taquer%C3%ADa',22.000,10365, " ; $ skipToken = urldecode ( $ skipToken ) ; try { $ internalSkipTokenInfo = SkipTokenParser :: parseSkipTokenClause ( $ resourceType , $ internalOrderByInfo , $ skipToken ) ; $ this -> fail ( 'An expected ODataException for syntax error has not been raised (because of leading comma)' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'Bad Request - Error in the syntax of skiptoken' , $ odataException -> getMessage ( ) ) ; } $ skipToken = " 'Antonio%20Moreno%20Taquer%C3%ADa',,22.000,10365, " ; $ skipToken = urldecode ( $ skipToken ) ; try { $ internalSkipTokenInfo = SkipTokenParser :: parseSkipTokenClause ( $ resourceType , $ internalOrderByInfo , $ skipToken ) ; $ this -> fail ( 'An expected ODataException for syntax error has not been raised (because of extra comma)' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'Bad Request - Error in the syntax of skiptoken' , $ odataException -> getMessage ( ) ) ; } }
Skiptoken should not contain leading and trailing commas, use
 commas only to separate token sub-values.
Skiptoken should not contain leading and trailing commas use commas only to separate token sub - values .
//IMetadataProvider implementation //Service configuration //Note: library will add prim key as last sort key //Test with trailing comma //Test with leading comma //Test with extra comma between values