tests/UnitTests/POData/UriProcessor/UriProcessorTest.php
/**
     * Test request uri for row count ($count)     
     * 
     * $skip and/or $top options along with $orderby option cause internalOrderInfo
     * to include sorter functions using keys + paths in the $orderby clause
     */
Test request uri for row count ($count)

$skip and/or $top options along with $orderby option cause internalOrderInfo
to include sorter functions using keys + paths in the $orderby clause
Test request uri for row count ( $count ) $skip and / or $top options along with $orderby option cause internalOrderInfo to include sorter functions using keys + paths in the $orderby clause
public function testUriProcessorForCountRequest6()
    {
        $hostInfo = array(
            'AbsoluteRequestUri' => new Url('http://localhost:8083/NorthWindDataService.svc/Customers/$count'),
            'AbsoluteServiceUri' => new Url('http://localhost:8083/NorthWindDataService.svc'),
            'QueryString' => '$skip=2&$top=4&$orderby=Country',
            'DataServiceVersion' => new Version(2, 0),
            'MaxDataServiceVersion' => new Version(2, 0),
        );
        $host = new ServiceHostTestFake($hostInfo);
        $dataService = new NorthWindService2();
        $dataService->setHost($host);
        $uriProcessor = $dataService->handleRequest();
        $requestDescription = $uriProcessor->getRequest();
        $this->assertNotNull($requestDescription);
        $this->assertEquals($requestDescription->getTopCount(), 4);
        $this->assertEquals($requestDescription->getSkipCount(), 2);
        $internalOrderByInfo = $requestDescription->getInternalOrderByInfo();
        $this->assertNotNull($internalOrderByInfo);
        $object = $internalOrderByInfo->getDummyObject();
        $this->assertNotNull($object);
        $this->assertTrue($object instanceof Customer2);
        $pathSegments = $internalOrderByInfo->getOrderByPathSegments();
        $this->assertNotNull($pathSegments);
        $this->assertTrue(is_array($pathSegments));
        $this->assertEquals(count($pathSegments), 3);
        $this->assertTrue($pathSegments[0] instanceof OrderByPathSegment);
        $subPathSegments = $pathSegments[0]->getSubPathSegments();
        $this->assertNotNull($subPathSegments);
        $this->assertTrue(is_array($subPathSegments));
        $this->assertEquals(count($subPathSegments), 1);
        $this->assertTrue($subPathSegments[0] instanceof OrderBySubPathSegment);
        $this->assertEquals($subPathSegments[0]->getName(), 'Country');
        $this->assertTrue($pathSegments[1] instanceof OrderByPathSegment);
        $subPathSegments = $pathSegments[1]->getSubPathSegments();
        $this->assertNotNull($subPathSegments);
        $this->assertTrue(is_array($subPathSegments));
        $this->assertEquals(count($subPathSegments), 1);
        $this->assertTrue($subPathSegments[0] instanceof OrderBySubPathSegment);
        $this->assertEquals($subPathSegments[0]->getName(), 'CustomerID');
        $this->assertTrue($pathSegments[2] instanceof OrderByPathSegment);
        $subPathSegments = $pathSegments[2]->getSubPathSegments();
        $this->assertNotNull($subPathSegments);
        $this->assertTrue(is_array($subPathSegments));
        $this->assertEquals(count($subPathSegments), 1);
        $this->assertTrue($subPathSegments[0] instanceof OrderBySubPathSegment);
        $this->assertEquals($subPathSegments[0]->getName(), 'CustomerGuid');
    }
public function testUriProcessorForCountRequest6 ( ) { $ hostInfo = array ( 'AbsoluteRequestUri' => new Url ( 'http://localhost:8083/NorthWindDataService.svc/Customers/$count' ) , 'AbsoluteServiceUri' => new Url ( 'http://localhost:8083/NorthWindDataService.svc' ) , 'QueryString' => '$skip=2&$top=4&$orderby=Country' , 'DataServiceVersion' => new Version ( 2 , 0 ) , 'MaxDataServiceVersion' => new Version ( 2 , 0 ) , ) ; $ host = new ServiceHostTestFake ( $ hostInfo ) ; $ dataService = new NorthWindService2 ( ) ; $ dataService -> setHost ( $ host ) ; $ uriProcessor = $ dataService -> handleRequest ( ) ; $ requestDescription = $ uriProcessor -> getRequest ( ) ; $ this -> assertNotNull ( $ requestDescription ) ; $ this -> assertEquals ( $ requestDescription -> getTopCount ( ) , 4 ) ; $ this -> assertEquals ( $ requestDescription -> getSkipCount ( ) , 2 ) ; $ internalOrderByInfo = $ requestDescription -> getInternalOrderByInfo ( ) ; $ this -> assertNotNull ( $ internalOrderByInfo ) ; $ object = $ internalOrderByInfo -> getDummyObject ( ) ; $ this -> assertNotNull ( $ object ) ; $ this -> assertTrue ( $ object instanceof Customer2 ) ; $ pathSegments = $ internalOrderByInfo -> getOrderByPathSegments ( ) ; $ this -> assertNotNull ( $ pathSegments ) ; $ this -> assertTrue ( is_array ( $ pathSegments ) ) ; $ this -> assertEquals ( count ( $ pathSegments ) , 3 ) ; $ this -> assertTrue ( $ pathSegments [ 0 ] instanceof OrderByPathSegment ) ; $ subPathSegments = $ pathSegments [ 0 ] -> getSubPathSegments ( ) ; $ this -> assertNotNull ( $ subPathSegments ) ; $ this -> assertTrue ( is_array ( $ subPathSegments ) ) ; $ this -> assertEquals ( count ( $ subPathSegments ) , 1 ) ; $ this -> assertTrue ( $ subPathSegments [ 0 ] instanceof OrderBySubPathSegment ) ; $ this -> assertEquals ( $ subPathSegments [ 0 ] -> getName ( ) , 'Country' ) ; $ this -> assertTrue ( $ pathSegments [ 1 ] instanceof OrderByPathSegment ) ; $ subPathSegments = $ pathSegments [ 1 ] -> getSubPathSegments ( ) ; $ this -> assertNotNull ( $ subPathSegments ) ; $ this -> assertTrue ( is_array ( $ subPathSegments ) ) ; $ this -> assertEquals ( count ( $ subPathSegments ) , 1 ) ; $ this -> assertTrue ( $ subPathSegments [ 0 ] instanceof OrderBySubPathSegment ) ; $ this -> assertEquals ( $ subPathSegments [ 0 ] -> getName ( ) , 'CustomerID' ) ; $ this -> assertTrue ( $ pathSegments [ 2 ] instanceof OrderByPathSegment ) ; $ subPathSegments = $ pathSegments [ 2 ] -> getSubPathSegments ( ) ; $ this -> assertNotNull ( $ subPathSegments ) ; $ this -> assertTrue ( is_array ( $ subPathSegments ) ) ; $ this -> assertEquals ( count ( $ subPathSegments ) , 1 ) ; $ this -> assertTrue ( $ subPathSegments [ 0 ] instanceof OrderBySubPathSegment ) ; $ this -> assertEquals ( $ subPathSegments [ 0 ] -> getName ( ) , 'CustomerGuid' ) ; }
Test request uri for row count ($count)
Test request uri for row count ( $count )