tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/SelectTest.php
/**
     * Selection of a parent navigation property casues selection of child navigations
     * for example $expand=A/B/C & $select = A/B
     * case result to include A and subtree of A (i.e B/C)
     * but result won't include immediate properties of A, but include immediate
     * properties of B and C
     */
Selection of a parent navigation property casues selection of child navigations
for example $expand=A/B/C & $select = A/B
case result to include A and subtree of A
but result won't include immediate properties of A, but include immediate
properties of B and C
Selection of a parent navigation property casues selection of child navigations for example $expand = A / B / C & $select = A / B case result to include A and subtree of A but result won ' t include immediate properties of A but include immediate properties of B and C
public function testInclusionOfSubTreeDueToParentInclusion2()
    {
        $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/Product, Order_Details/Product/Order_Details/Order', 
                                    'Order_Details/Product', 
                                    $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->assertFalse($childNodes['Order_Details']->canSelectAllProperties());
        $childNodes = $childNodes['Order_Details']->getChildNodes();
        $this->assertEquals(count($childNodes), 1);
        $this->assertTrue(array_key_exists('Product', $childNodes));
        $this->assertTrue($childNodes['Product'] instanceof ExpandedProjectionNode);
        $this->assertTrue($childNodes['Product']->canSelectAllProperties());
        $childNodes = $childNodes['Product']->getChildNodes();
        $this->assertEquals(count($childNodes), 1);
        $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);
        $this->assertTrue(array_key_exists('Product', $childNodes));
        $this->assertTrue($childNodes['Product'] instanceof ExpandedProjectionNode);
        $this->assertTrue(array_key_exists('Order', $childNodes));
        $this->assertTrue($childNodes['Order'] instanceof ExpandedProjectionNode);
        $this->assertTrue($childNodes['Product']->canSelectAllProperties());
        $this->assertTrue($childNodes['Order']->canSelectAllProperties());
    }
public function testInclusionOfSubTreeDueToParentInclusion2 ( ) { $ 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/Product, Order_Details/Product/Order_Details/Order' , 'Order_Details/Product' , $ 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 -> assertFalse ( $ childNodes [ 'Order_Details' ] -> canSelectAllProperties ( ) ) ; $ childNodes = $ childNodes [ 'Order_Details' ] -> getChildNodes ( ) ; $ this -> assertEquals ( count ( $ childNodes ) , 1 ) ; $ this -> assertTrue ( array_key_exists ( 'Product' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] instanceof ExpandedProjectionNode ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] -> canSelectAllProperties ( ) ) ; $ childNodes = $ childNodes [ 'Product' ] -> getChildNodes ( ) ; $ this -> assertEquals ( count ( $ childNodes ) , 1 ) ; $ 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 ) ; $ this -> assertTrue ( array_key_exists ( 'Product' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] instanceof ExpandedProjectionNode ) ; $ this -> assertTrue ( array_key_exists ( 'Order' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Order' ] instanceof ExpandedProjectionNode ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] -> canSelectAllProperties ( ) ) ; $ this -> assertTrue ( $ childNodes [ 'Order' ] -> canSelectAllProperties ( ) ) ; }
Selection of a parent navigation property casues selection of child navigations
 for example $expand=A/B/C & $select = A/B
 case result to include A and subtree of A (i.e B/C)
 but result won't include immediate properties of A, but include immediate
 properties of B and C
Selection of a parent navigation property casues selection of child navigations for example $expand = A / B / C & $select = A / B case result to include A and subtree of A ( i . e B / C ) but result won ' t include immediate properties of A but include immediate properties of B and C
//IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuration //$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' //Properties of 'Order_Details' cannot be selected, its selectSubTree flag is false //There is one child node for 'Order_Details', 'Product' //All properties of 'Product' should be selected, as its selectSubTree flag is true (because it is last segment) //Product has one child node 'Order_Details' //This is the Order_Details at level 3 child node of Product //Product is last segment means properties of all nodes in the sub-tree should be included in the result //Order_Details at level 3 has 2 child nodes //Both child nodes's all properties should be included in the result