tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/SelectTest.php
/**
     * Selection of a parent navigation property causes selection of child navigations
     * for example $expand=A/B/C, A/D/F & $select = A
     * case result to include A and subtree of A (i.e B/C and D/F)
     * with all immediate properties of A, B, C, D and F
     */
Selection of a parent navigation property causes selection of child navigations
for example $expand=A/B/C, A/D/F & $select = A
case result to include A and subtree of A
with all immediate properties of A, B, C, D and F
Selection of a parent navigation property causes selection of child navigations for example $expand = A / B / C A / D / F & $select = A case result to include A and subtree of A with all immediate properties of A B C D and F
public function testInclusionOfSubTreeDueToParentInclusion1()
    {
        $northWindMetadata = NorthWindMetadata::Create();
        $queryProvider = new NorthWindQueryProvider();
        $configuration = new ServiceConfiguration($northWindMetadata);
        $configuration->setEntitySetAccessRule('*', EntitySetRights::ALL);
        $providersWrapper = new ProvidersWrapper(
                                       $northWindMetadata, 
                                       $queryProvider, 
                                       $configuration, 
                                       false
                                     );
        $ordersResourceSetWrapper = $providersWrapper->resolveResourceSet('Orders');
        $orderResourceType = $ordersResourceSetWrapper->getResourceType();
        $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                                    $ordersResourceSetWrapper,
                                                    $orderResourceType,
                                                    null,
                                                    null,
                                                    null,
                                                    'Order_Details/Product,Order_Details/Order', 
                                                    'Order_Details', 
                                                    $providersWrapper);
        $this->assertTrue($projectionTreeRoot->isExpansionSpecified());
        $this->assertTrue($projectionTreeRoot->isSelectionSpecified());
        $this->assertFalse($projectionTreeRoot->canSelectAllImmediateProperties());
        $this->assertFalse($projectionTreeRoot->canSelectAllProperties());
        $this->assertEquals(count($projectionTreeRoot->getChildNodes()), 1);
        $childNodes = $projectionTreeRoot->getChildNodes();
        $this->assertTrue(array_key_exists('Order_Details', $childNodes));
        $this->assertTrue($childNodes['Order_Details'] instanceof ExpandedProjectionNode);
        $this->assertTrue($childNodes['Order_Details']->canSelectAllProperties());
        $childNodes = $childNodes['Order_Details']->getChildNodes();
        $this->assertEquals(count($childNodes), 2);
        $i = 0;
        foreach ($childNodes as $propertyName => $childNode) {
            if ($i == 0) {
                $this->assertEquals($propertyName, 'Order');
            } else if($i == 1) {
                $this->assertEquals($propertyName, 'Product');
            }
            $i++;
        }
    }
public function testInclusionOfSubTreeDueToParentInclusion1 ( ) { $ northWindMetadata = NorthWindMetadata :: Create ( ) ; $ queryProvider = new NorthWindQueryProvider ( ) ; $ configuration = new ServiceConfiguration ( $ northWindMetadata ) ; $ configuration -> setEntitySetAccessRule ( '*' , EntitySetRights :: ALL ) ; $ providersWrapper = new ProvidersWrapper ( $ northWindMetadata , $ queryProvider , $ configuration , false ) ; $ ordersResourceSetWrapper = $ providersWrapper -> resolveResourceSet ( 'Orders' ) ; $ orderResourceType = $ ordersResourceSetWrapper -> getResourceType ( ) ; $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ ordersResourceSetWrapper , $ orderResourceType , null , null , null , 'Order_Details/Product,Order_Details/Order' , 'Order_Details' , $ providersWrapper ) ; $ this -> assertTrue ( $ projectionTreeRoot -> isExpansionSpecified ( ) ) ; $ this -> assertTrue ( $ projectionTreeRoot -> isSelectionSpecified ( ) ) ; $ this -> assertFalse ( $ projectionTreeRoot -> canSelectAllImmediateProperties ( ) ) ; $ this -> assertFalse ( $ projectionTreeRoot -> canSelectAllProperties ( ) ) ; $ this -> assertEquals ( count ( $ projectionTreeRoot -> getChildNodes ( ) ) , 1 ) ; $ childNodes = $ projectionTreeRoot -> getChildNodes ( ) ; $ this -> assertTrue ( array_key_exists ( 'Order_Details' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Order_Details' ] instanceof ExpandedProjectionNode ) ; $ this -> assertTrue ( $ childNodes [ 'Order_Details' ] -> canSelectAllProperties ( ) ) ; $ childNodes = $ childNodes [ 'Order_Details' ] -> getChildNodes ( ) ; $ this -> assertEquals ( count ( $ childNodes ) , 2 ) ; $ i = 0 ; foreach ( $ childNodes as $ propertyName => $ childNode ) { if ( $ i == 0 ) { $ this -> assertEquals ( $ propertyName , 'Order' ) ; } else if ( $ i == 1 ) { $ this -> assertEquals ( $ propertyName , 'Product' ) ; } $ i ++ ; } }
Selection of a parent navigation property causes selection of child navigations
 for example $expand=A/B/C, A/D/F & $select = A
 case result to include A and subtree of A (i.e B/C and D/F)
 with all immediate properties of A, B, C, D and F
Selection of a parent navigation property causes selection of child navigations for example $expand = A / B / C A / D / F & $select = A case result to include A and subtree of A ( i . e B / C and D / F ) with all immediate properties of A B C D and F
//IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuration //First test with explicit selection and no '*' application // $expand //$select //expand option is present //select is applied //We did not applied '*' for root resource set i.e. 'Orders' //selectSubTree flag for root resource set is false (canSelectAllProperities is true for '*' and selectsubTree //there is 1 child nodes for the root //The child nodes are 'ExpandProjectionNode' for 'Order_Details' //'Order_Details is last sub segment in select path segment, means result should include //all properties of 'Order_Details' and the sub-tree Product, Order should be included in the result //'Order_Details' has two children //The child nodes of 'Order_Details' are 'Product' and 'Order' //In the metadata provider the order of registering of these //navigation properties are 'Order' followed by 'Product' //Check whether parser sort the nodes accordingly