tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/SelectTest.php
/**
     * Once client applied selection clause, navigation properties specified in the expand clause
	 * will included in the result only if they are selected. For example:
	 * $expand=A/B, X/Y & select=A
     * The result will include only A and associated B (with all properties). X/Y will be 
     * ignored as they are not selected
     */
Once client applied selection clause, navigation properties specified in the expand clause
will included in the result only if they are selected. For example:
$expand=A/B, X/Y & select=A
The result will include only A and associated B (with all properties). X/Y will be
ignored as they are not selected
Once client applied selection clause navigation properties specified in the expand clause will included in the result only if they are selected . For example : $expand = A / B X / Y & select = A The result will include only A and associated B ( with all properties ) . X / Y will be ignored as they are not selected
public function testRemovalOfSubTreeWhichIsExpandedButNotSelected1()
    {
        $northWindMetadata = NorthWindMetadata::Create();
        $queryProvider = new NorthWindQueryProvider();
        $configuration = new ServiceConfiguration($northWindMetadata);
        $configuration->setEntitySetAccessRule('*', EntitySetRights::ALL);
        $providersWrapper = new ProvidersWrapper(
                                       $northWindMetadata, 
                                       $queryProvider, 
                                       $configuration, 
                                       false
                                     );
        $orderDetailsResourceSetWrapper = $providersWrapper->resolveResourceSet('Order_Details');
        $orderDetailsResourceType = $orderDetailsResourceSetWrapper->getResourceType();
        $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                    $orderDetailsResourceSetWrapper,
                                    $orderDetailsResourceType,
                                    null,
                                    null,
                                    null,
                                    'Product, Order', 
                                    '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('Product', $childNodes));
        $this->assertTrue($childNodes['Product'] instanceof ExpandedProjectionNode);
        $this->assertTrue($childNodes['Product']->canSelectAllProperties());
        $childNodes = $childNodes['Product']->getChildNodes();
        $this->assertEquals(count($childNodes), 0);
        $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/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->assertTrue($childNodes['Product'] instanceof ExpandedProjectionNode);
        $this->assertFalse($childNodes['Product']->canSelectAllProperties());
         this is level 3 segment
        $childNodes = $childNodes['Product']->getChildNodes();
        $this->assertEquals(count($childNodes), 1);
        $this->assertTrue(array_key_exists('Order_Details', $childNodes));
        $this->assertTrue($childNodes['Order_Details'] instanceof ExpandedProjectionNode);
        $childNodes = $childNodes['Order_Details']->getChildNodes();
        $this->assertEquals(count($childNodes), 1);
        $this->assertTrue(array_key_exists('Product', $childNodes));
        $this->assertTrue($childNodes['Product'] instanceof ExpandedProjectionNode);
    }
public function testRemovalOfSubTreeWhichIsExpandedButNotSelected1 ( ) { $ northWindMetadata = NorthWindMetadata :: Create ( ) ; $ queryProvider = new NorthWindQueryProvider ( ) ; $ configuration = new ServiceConfiguration ( $ northWindMetadata ) ; $ configuration -> setEntitySetAccessRule ( '*' , EntitySetRights :: ALL ) ; $ providersWrapper = new ProvidersWrapper ( $ northWindMetadata , $ queryProvider , $ configuration , false ) ; $ orderDetailsResourceSetWrapper = $ providersWrapper -> resolveResourceSet ( 'Order_Details' ) ; $ orderDetailsResourceType = $ orderDetailsResourceSetWrapper -> getResourceType ( ) ; $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ orderDetailsResourceSetWrapper , $ orderDetailsResourceType , null , null , null , 'Product, Order' , '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 ( 'Product' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] instanceof ExpandedProjectionNode ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] -> canSelectAllProperties ( ) ) ; $ childNodes = $ childNodes [ 'Product' ] -> getChildNodes ( ) ; $ this -> assertEquals ( count ( $ childNodes ) , 0 ) ; $ 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/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 -> assertTrue ( $ childNodes [ 'Product' ] instanceof ExpandedProjectionNode ) ; $ this -> assertFalse ( $ 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 ) ; $ childNodes = $ childNodes [ 'Order_Details' ] -> getChildNodes ( ) ; $ this -> assertEquals ( count ( $ childNodes ) , 1 ) ; $ this -> assertTrue ( array_key_exists ( 'Product' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Product' ] instanceof ExpandedProjectionNode ) ; }
Once client applied selection clause, navigation properties specified in the expand clause
 will included in the result only if they are selected.
Once client applied selection clause navigation properties specified in the expand clause will included in the result only if they are selected .
//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. to 'Order_Details' //selectSubTree flag for root resource set is false (canSelectAllProperities is true for '*' and selectsubTree //there should be only 1 child nodes for the root, 'Orders' will not be there in the result as its not //selected //The child node is 'ExpandProjectionNode' for 'Product' //All properties of 'Product' should be selected as its last node //There is no child node for 'Product' //---------------------------------------------------------------------------------------------------- //Test the same case but with one more level of navigation //Here parser should discard the last expanded node 'Orders' in 'Order_Details/Product/Order_Details/Order' //$expand //$select //expand option is present //select is applied //We did not applied '*' for root resource set i.e. to 'Order_Details' //selectSubTree flag for root resource set is false (canSelectAllProperities is true for '*' and selectsubTree //The child node is 'ExpandProjectionNode' for 'Order_Details' //All properties of 'Order_Details' should not be selected //The child node is 'ExpandProjectionNode' for 'Product' //All properties of 'Product' should not be selected //The child node is 'ExpandProjectionNode' for 'Order_Details' this is level 3 segment //In the expand clause there are 2 child segments after level 3 'ORder_Details' segment //namely 'Product' and 'Order', but only is selected in select clause i.e. 'Product' so //'Order' will be removed from the tree. //count is 1 not 2