tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/SelectTest.php
/**
     * Only navigation property can come as intermediate path segment
     * Primitive/Bag/Complex types should be the last segment
     * 
     */
Only navigation property can come as intermediate path segment
Primitive/Bag/Complex types should be the last segment
Only navigation property can come as intermediate path segment Primitive / Bag / Complex types should be the last segment
public function testPrimitiveBagComplexAsIntermediateSegments()
    {
        $northWindMetadata = NorthWindMetadata::Create();
        $queryProvider = new NorthWindQueryProvider();
        $configuration = new ServiceConfiguration($northWindMetadata);
        $configuration->setEntitySetAccessRule('*', EntitySetRights::ALL);
        $providersWrapper = new ProvidersWrapper(
                                       $northWindMetadata, 
                                       $queryProvider, 
                                       $configuration, 
                                       false
                                     );
        $customersResourceSetWrapper = $providersWrapper->resolveResourceSet('Customers');
        $customerResourceType = $customersResourceSetWrapper->getResourceType();
        try {
            $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                        $customersResourceSetWrapper,
                                        $customerResourceType,
                                        null,
                                        null,
                                        null,
                                        'Orders', 
                                        'Orders/OrderID/*', 
                                        $providersWrapper);
            $this->fail('An expected ODataException usage of primitive type as navigation property has not been thrown');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('Property \'OrderID\' on type \'Order\' is of primitive type and cannot be used as a navigation property.', $odataException->getMessage());
        }
        try {
            $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                        $customersResourceSetWrapper,
                                        $customerResourceType,
                                        null,
                                        null,
                                        null,
                                        'Orders', 
                                        'Address/HouseNumber', 
                                        $providersWrapper);
            $this->fail('An expected ODataException usage of complex type as navigation property has not been thrown');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('select doesn\'t support selection of properties of complex type. The property \'Address\' on type \'Customer\' is a complex type', $odataException->getMessage());
        }
        $employeesResourceSetWrapper = $providersWrapper->resolveResourceSet('Employees');
        $employeeResourceType = $employeesResourceSetWrapper->getResourceType();
        try {
            $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                        $employeesResourceSetWrapper,
                                        $employeeResourceType,
                                        null,
                                        null,
                                        null,
                                        null, 
                                        'Emails/ABC', 
                                        $providersWrapper);
            $this->fail('An expected ODataException usage of bag type as navigation property has not been thrown');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith('The selection from property \'Emails\' on type \'Employee\' is not valid. The select query option does not support selection items from a bag property', $odataException->getMessage());
        }
    }
public function testPrimitiveBagComplexAsIntermediateSegments ( ) { $ northWindMetadata = NorthWindMetadata :: Create ( ) ; $ queryProvider = new NorthWindQueryProvider ( ) ; $ configuration = new ServiceConfiguration ( $ northWindMetadata ) ; $ configuration -> setEntitySetAccessRule ( '*' , EntitySetRights :: ALL ) ; $ providersWrapper = new ProvidersWrapper ( $ northWindMetadata , $ queryProvider , $ configuration , false ) ; $ customersResourceSetWrapper = $ providersWrapper -> resolveResourceSet ( 'Customers' ) ; $ customerResourceType = $ customersResourceSetWrapper -> getResourceType ( ) ; try { $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ customersResourceSetWrapper , $ customerResourceType , null , null , null , 'Orders' , 'Orders/OrderID/*' , $ providersWrapper ) ; $ this -> fail ( 'An expected ODataException usage of primitive type as navigation property has not been thrown' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'Property \'OrderID\' on type \'Order\' is of primitive type and cannot be used as a navigation property.' , $ odataException -> getMessage ( ) ) ; } try { $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ customersResourceSetWrapper , $ customerResourceType , null , null , null , 'Orders' , 'Address/HouseNumber' , $ providersWrapper ) ; $ this -> fail ( 'An expected ODataException usage of complex type as navigation property has not been thrown' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'select doesn\'t support selection of properties of complex type. The property \'Address\' on type \'Customer\' is a complex type' , $ odataException -> getMessage ( ) ) ; } $ employeesResourceSetWrapper = $ providersWrapper -> resolveResourceSet ( 'Employees' ) ; $ employeeResourceType = $ employeesResourceSetWrapper -> getResourceType ( ) ; try { $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ employeesResourceSetWrapper , $ employeeResourceType , null , null , null , null , 'Emails/ABC' , $ providersWrapper ) ; $ this -> fail ( 'An expected ODataException usage of bag type as navigation property has not been thrown' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( 'The selection from property \'Emails\' on type \'Employee\' is not valid. The select query option does not support selection items from a bag property' , $ odataException -> getMessage ( ) ) ; } }
Only navigation property can come as intermediate path segment
 Primitive/Bag/Complex types should be the last segment
Only navigation property can come as intermediate path segment Primitive / Bag / Complex types should be the last segment
//IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuration //Test using primitive type as navigation //$expand //$select //Test using complex type as navigation //$expand //$select //Test using bag type as navigation //$expand //$select