tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/ExpandTest.php
/**
     * One can expand a navigation property only if corresponding resource set is visible
     * 
     */
One can expand a navigation property only if corresponding resource set is visible
One can expand a navigation property only if corresponding resource set is visible
public function testExpandWithNonVisibleResourceSet()
    {
        $northWindMetadata = NorthWindMetadata::Create();
        $queryProvider = new NorthWindQueryProvider();
        $configuration = new ServiceConfiguration($northWindMetadata);
        $configuration->setEntitySetAccessRule('Customers', EntitySetRights::ALL);
        $configuration->setEntitySetAccessRule('Orders', EntitySetRights::ALL);
        $providersWrapper = new ProvidersWrapper(
                                          $northWindMetadata, 
                                          $queryProvider, 
                                          $configuration, 
                                          false
                                         );
        $customersResourceSetWrapper = $providersWrapper->resolveResourceSet('Customers');
        $customerResourceType = $customersResourceSetWrapper->getResourceType();
        $exceptionThrown = false;
        try {
            $projectionTree = ExpandProjectionParser::parseExpandAndSelectClause(
                    $customersResourceSetWrapper,
                    $customerResourceType,
                    null,
                    null,
                    null,
                    'Orders/Order_Details', 
                    null,     
                    $providersWrapper);
            $this->fail('An expected ODataException for navigation to invisible resource set has not been thrown');
        } catch (ODataException $odataException) {
            $this->assertStringEndsWith("(Check the resource set of the navigation property 'Order_Details' is visible)", $odataException->getMessage());
        }
    }
public function testExpandWithNonVisibleResourceSet ( ) { $ northWindMetadata = NorthWindMetadata :: Create ( ) ; $ queryProvider = new NorthWindQueryProvider ( ) ; $ configuration = new ServiceConfiguration ( $ northWindMetadata ) ; $ configuration -> setEntitySetAccessRule ( 'Customers' , EntitySetRights :: ALL ) ; $ configuration -> setEntitySetAccessRule ( 'Orders' , EntitySetRights :: ALL ) ; $ providersWrapper = new ProvidersWrapper ( $ northWindMetadata , $ queryProvider , $ configuration , false ) ; $ customersResourceSetWrapper = $ providersWrapper -> resolveResourceSet ( 'Customers' ) ; $ customerResourceType = $ customersResourceSetWrapper -> getResourceType ( ) ; $ exceptionThrown = false ; try { $ projectionTree = ExpandProjectionParser :: parseExpandAndSelectClause ( $ customersResourceSetWrapper , $ customerResourceType , null , null , null , 'Orders/Order_Details' , null , $ providersWrapper ) ; $ this -> fail ( 'An expected ODataException for navigation to invisible resource set has not been thrown' ) ; } catch ( ODataException $ odataException ) { $ this -> assertStringEndsWith ( " (Check the resource set of the navigation property 'Order_Details' is visible) " , $ odataException -> getMessage ( ) ) ; } }
One can expand a navigation property only if corresponding resource set is visible
One can expand a navigation property only if corresponding resource set is visible
//Make 'Customers' and 'Orders' visible, make 'Order_Details' invisible //IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuuration // $expand // $select