tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/ExpandTest.php
/**
     * Test expand with non-navigation properties in the path
     */
Test expand with non-navigation properties in the path
Test expand with non - navigation properties in the path
public function testExpandWithNonNavigationPropertyInThePath()
    {
        $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,
                                                        'CustomerName', 
                                                        null,         
                                                        $providersWrapper);
            $this->fail('An expected ODataException for non-navigation property in the path has not been thrown');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith("Error in the expand clause. Expand path can contain only navigation property, the property 'CustomerName' defined in 'Customer' is not a navigation property", $odataException->getMessage());
        }
        try {
            $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                                        $customersResourceSetWrapper,
                                                        $customerResourceType,
                                                        null,
                                                        null,
                                                        null,
                                                        'Address', 
                                                        null,         
                                                        $providersWrapper);
            $this->fail('An expected ODataException for non-navigation property in the path has not been thrown');
        } catch (ODataException $odataException) {
            $this->assertStringStartsWith("Error in the expand clause. Expand path can contain only navigation property", $odataException->getMessage());
        }
    }
public function testExpandWithNonNavigationPropertyInThePath ( ) { $ 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 , 'CustomerName' , null , $ providersWrapper ) ; $ this -> fail ( 'An expected ODataException for non-navigation property in the path has not been thrown' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( " Error in the expand clause. Expand path can contain only navigation property, the property 'CustomerName' defined in 'Customer' is not a navigation property " , $ odataException -> getMessage ( ) ) ; } try { $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ customersResourceSetWrapper , $ customerResourceType , null , null , null , 'Address' , null , $ providersWrapper ) ; $ this -> fail ( 'An expected ODataException for non-navigation property in the path has not been thrown' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringStartsWith ( " Error in the expand clause. Expand path can contain only navigation property " , $ odataException -> getMessage ( ) ) ; } }
Test expand with non-navigation properties in the path
Test expand with non - navigation properties in the path
//IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuration //Test with Primitive property in expand path // $expand // $select //Test with complex property in expand path // $expand // $select