tests/UnitTests/POData/UriProcessor/QueryProcessor/ExpandProjectionParser/ExpandTest.php
/**
     * Test expand with only one level of navigation     
     */
Test expand with only one level of navigation
Test expand with only one level of navigation
public function testExpandWithOneLevelNavigationProperty()
    {
        $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,
                                                    'Orders', 
                                                    null, 
                                                    $providersWrapper);
        $this->assertTrue($projectionTreeRoot->isExpansionSpecified());
        $this->assertFalse($projectionTreeRoot->isSelectionSpecified());
        $this->assertEquals(count($projectionTreeRoot->getChildNodes()), 1);
        $childNodes = $projectionTreeRoot->getChildNodes();
        $this->assertTrue(array_key_exists('Orders', $childNodes));
        $this->assertTrue($childNodes['Orders'] instanceof ExpandedProjectionNode);
        $this->assertNotNull($childNodes['Orders']->getPropertyName());
        $this->assertEquals($childNodes['Orders']->getPropertyName(), 'Orders');
        $this->assertNotNull($childNodes['Orders']->getResourceProperty());
        $this->assertEquals($childNodes['Orders']->getResourceProperty()->getName(), 'Orders');
        $this->assertNotNull($childNodes['Orders']->getResourceSetWrapper());
        $this->assertNotNull($childNodes['Orders']->getResourceSetWrapper()->getName(), 'Orders');
        $this->assertNotNull($childNodes['Orders']->getResourceType());
        $this->assertNotNull($childNodes['Orders']->getResourceType()->getName(), 'Order');
        $this->assertTrue($projectionTreeRoot->canSelectAllProperties());
        $this->assertTrue($childNodes['Orders']->canSelectAllProperties());
        $this->assertFalse($childNodes['Orders']->canSelectAllImmediateProperties());
    }
public function testExpandWithOneLevelNavigationProperty ( ) { $ 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 , 'Orders' , null , $ providersWrapper ) ; $ this -> assertTrue ( $ projectionTreeRoot -> isExpansionSpecified ( ) ) ; $ this -> assertFalse ( $ projectionTreeRoot -> isSelectionSpecified ( ) ) ; $ this -> assertEquals ( count ( $ projectionTreeRoot -> getChildNodes ( ) ) , 1 ) ; $ childNodes = $ projectionTreeRoot -> getChildNodes ( ) ; $ this -> assertTrue ( array_key_exists ( 'Orders' , $ childNodes ) ) ; $ this -> assertTrue ( $ childNodes [ 'Orders' ] instanceof ExpandedProjectionNode ) ; $ this -> assertNotNull ( $ childNodes [ 'Orders' ] -> getPropertyName ( ) ) ; $ this -> assertEquals ( $ childNodes [ 'Orders' ] -> getPropertyName ( ) , 'Orders' ) ; $ this -> assertNotNull ( $ childNodes [ 'Orders' ] -> getResourceProperty ( ) ) ; $ this -> assertEquals ( $ childNodes [ 'Orders' ] -> getResourceProperty ( ) -> getName ( ) , 'Orders' ) ; $ this -> assertNotNull ( $ childNodes [ 'Orders' ] -> getResourceSetWrapper ( ) ) ; $ this -> assertNotNull ( $ childNodes [ 'Orders' ] -> getResourceSetWrapper ( ) -> getName ( ) , 'Orders' ) ; $ this -> assertNotNull ( $ childNodes [ 'Orders' ] -> getResourceType ( ) ) ; $ this -> assertNotNull ( $ childNodes [ 'Orders' ] -> getResourceType ( ) -> getName ( ) , 'Order' ) ; $ this -> assertTrue ( $ projectionTreeRoot -> canSelectAllProperties ( ) ) ; $ this -> assertTrue ( $ childNodes [ 'Orders' ] -> canSelectAllProperties ( ) ) ; $ this -> assertFalse ( $ childNodes [ 'Orders' ] -> canSelectAllImmediateProperties ( ) ) ; }
Test expand with only one level of navigation
Test expand with only one level of navigation
//IMetadataProvider implementation //IDataServiceQueryProvider implementation (set to null) //Service configuration // $expand // $select //Expansion is specified but selection is absent //There is one child node for root //The child node (of type ExpandedProjectionNode) represents 'Orders' navigation property //Check the required fields of the node is populated with proper values //We didn't applied any selection, so all properties needs to be selected by default //this one actually test whether 'ExpandedProjectionNode::markSubTreeAsSelected' method works properly //flag for SelectionOfImmediate properties will be true only if select include 'Orders\*'