tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/SelectTest.php
/**
     * Application of '*' on a node means select (only) all immediate properties of that node
     * in this case parser should remove any explicitly included nodes if its there
     * this will actually test the function 'ExpandProjectionNode::removeNodesAlreadyIncludedImplicitly'
     *
     */
Application of '*' on a node means select (only) all immediate properties of that node
in this case parser should remove any explicitly included nodes if its there
this will actually test the function 'ExpandProjectionNode::removeNodesAlreadyIncludedImplicitly'
Application of ' * ' on a node means select ( only ) all immediate properties of that node in this case parser should remove any explicitly included nodes if its there this will actually test the function ' ExpandProjectionNode :: removeNodesAlreadyIncludedImplicitly '
public function testWildCardWithExplicitSelectionOnRoot()
    {
        $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();
        $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                                    $customersResourceSetWrapper,
                                                    $customerResourceType,
                                                    null,
                                                    null,
                                                    null,
                                                    null, 
                                                    'CustomerID,CustomerName,Orders', 
                                                    $providersWrapper);
        $this->assertFalse($projectionTreeRoot->isExpansionSpecified());
        $this->assertTrue($projectionTreeRoot->isSelectionSpecified());
        $this->assertFalse($projectionTreeRoot->canSelectAllImmediateProperties());
        $this->assertFalse($projectionTreeRoot->canSelectAllProperties());
        $this->assertEquals(count($projectionTreeRoot->getChildNodes()), 3);
        $childNodes = $projectionTreeRoot->getChildNodes();
        $this->assertTrue(array_key_exists('CustomerID', $childNodes));
        $this->assertTrue($childNodes['CustomerID'] instanceof ProjectionNode);
        $this->assertTrue(array_key_exists('CustomerName', $childNodes));
        $this->assertTrue($childNodes['CustomerName'] instanceof ProjectionNode);
        $this->assertTrue(array_key_exists('Orders', $childNodes));
        $this->assertTrue($childNodes['Orders'] instanceof ProjectionNode);
        $this->assertFalse($childNodes['Orders'] instanceof ExpandedProjectionNode);
        $projectionTreeRoot = ExpandProjectionParser::parseExpandAndSelectClause(
                                                    $customersResourceSetWrapper,
                                                    $customerResourceType,
                                                    null,
                                                    null,
                                                    null,
                                                    null, 
                                                    'CustomerID,CustomerName,Orders,*', 
                                                    $providersWrapper);
        $this->assertFalse($projectionTreeRoot->isExpansionSpecified());
        $this->assertTrue($projectionTreeRoot->isSelectionSpecified());
        $this->assertTrue($projectionTreeRoot->canSelectAllImmediateProperties());
        $this->assertTrue($projectionTreeRoot->canSelectAllProperties());
        $this->assertEquals(count($projectionTreeRoot->getChildNodes()), 0);
    }
public function testWildCardWithExplicitSelectionOnRoot ( ) { $ 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 ( ) ; $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ customersResourceSetWrapper , $ customerResourceType , null , null , null , null , 'CustomerID,CustomerName,Orders' , $ providersWrapper ) ; $ this -> assertFalse ( $ projectionTreeRoot -> isExpansionSpecified ( ) ) ; $ this -> assertTrue ( $ projectionTreeRoot -> isSelectionSpecified ( ) ) ; $ this -> assertFalse ( $ projectionTreeRoot -> canSelectAllImmediateProperties ( ) ) ; $ this -> assertFalse ( $ projectionTreeRoot -> canSelectAllProperties ( ) ) ; $ this -> assertEquals ( count ( $ projectionTreeRoot -> getChildNodes ( ) ) , 3 ) ; $ childNodes = $ projectionTreeRoot -> getChildNodes ( ) ; $ this -> assertTrue ( array_key_exists ( 'CustomerID' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'CustomerID' ] instanceof ProjectionNode ) ; $ this -> assertTrue ( array_key_exists ( 'CustomerName' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'CustomerName' ] instanceof ProjectionNode ) ; $ this -> assertTrue ( array_key_exists ( 'Orders' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Orders' ] instanceof ProjectionNode ) ; $ this -> assertFalse ( $ childNodes [ 'Orders' ] instanceof ExpandedProjectionNode ) ; $ projectionTreeRoot = ExpandProjectionParser :: parseExpandAndSelectClause ( $ customersResourceSetWrapper , $ customerResourceType , null , null , null , null , 'CustomerID,CustomerName,Orders,*' , $ providersWrapper ) ; $ this -> assertFalse ( $ projectionTreeRoot -> isExpansionSpecified ( ) ) ; $ this -> assertTrue ( $ projectionTreeRoot -> isSelectionSpecified ( ) ) ; $ this -> assertTrue ( $ projectionTreeRoot -> canSelectAllImmediateProperties ( ) ) ; $ this -> assertTrue ( $ projectionTreeRoot -> canSelectAllProperties ( ) ) ; $ this -> assertEquals ( count ( $ projectionTreeRoot -> getChildNodes ( ) ) , 0 ) ; }
Application of '*' on a node means select (only) all immediate properties of that node
 in this case parser should remove any explicitly included nodes if its there
 this will actually test the function 'ExpandProjectionNode::removeNodesAlreadyIncludedImplicitly'
Application of ' * ' on a node means select ( only ) all immediate properties of that node in this case parser should remove any explicitly included nodes if its there this will actually test the function ' ExpandProjectionNode :: removeNodesAlreadyIncludedImplicitly '
//IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuration //First test with explicit selection and no '*' application // $expand //$select //expand option is absent //select is applied //We selected 3 properties (one is a link to 'Orders' navigation property) explicitly, there is no '*' //there are 3 child nodes for the root //The child nodes are 'ProjectionNode' for CustomerID, CompanyName and Orders //even though 'Orders' is a navigation property, corresponding node will not be //'ExpandedProjectionNode' because 'Orders' is not expanded, its just selected //so that only link will be inlcuded in the result //Now test selection with both '*' and explicit property inclusion // $expand //$select //expand option is absent //select is applied //We applied '*' on root, so flag for selection of all immediate properties must me true //Even though we explicity selected 'CustomerID', 'CustomerName' and link to 'Orders' //these children will be removed since '*' implcilty select all properties