tests/UnitTests/POData/UriProcessor/UriProcessorTest.php
/**
     * Test uri prcoessor for $skip and $top options
     */
Test uri prcoessor for $skip and $top options
Test uri prcoessor for $skip and $top options
public function testUriProcessorForSkipAndTop()
    {
        $baseUri = 'http://localhost:8083/NorthWindDataService.svc/';
        $resourcePath = 'Orders';
        $hostInfo = array(
            'AbsoluteRequestUri' => new Url($baseUri . $resourcePath),
            'AbsoluteServiceUri' => new Url($baseUri),
            'QueryString' => '$top=\'ABC\'',
            'DataServiceVersion' => new Version(2, 0),
            'MaxDataServiceVersion' => new Version(2, 0),
        );
        $host = new ServiceHostTestFake($hostInfo);
        $dataService = new NorthWindService2();
        $dataService->setHost($host);
        try {
            $dataService->handleRequest();
            $this->fail('An expected ODataException for incorrect $top value has not been thrown');
        } catch (ODataException $ex) {
            $this->assertStringStartsWith("Incorrect format for \$top", $ex->getMessage());
        }
        $baseUri = 'http://localhost:8083/NorthWindDataService.svc/';
        $resourcePath = 'Orders';
        $hostInfo = array(
            'AbsoluteRequestUri' => new Url($baseUri . $resourcePath),
            'AbsoluteServiceUri' => new Url($baseUri),
            'QueryString' => '$top=-123',
            'DataServiceVersion' => new Version(2, 0),
            'MaxDataServiceVersion' => new Version(2, 0),
        );
        $host = new ServiceHostTestFake($hostInfo);
        $dataService = new NorthWindService2();
        $dataService->setHost($host);
        try {
            $dataService->handleRequest();
            $this->fail('An expected ODataException for incorrect $top value has not been thrown');
        } catch (ODataException $ex) {
            $this->assertStringStartsWith('Incorrect format for $top', $ex->getMessage());
        }
        $baseUri = 'http://localhost:8083/NorthWindDataService.svc/';
        $resourcePath = 'Orders';
        $hostInfo = array(
            'AbsoluteRequestUri' => new Url($baseUri . $resourcePath),
            'AbsoluteServiceUri' => new Url($baseUri),
            'QueryString' => '$skip=\'ABC\'',
            'DataServiceVersion' => new Version(2, 0),
            'MaxDataServiceVersion' => new Version(2, 0),
        );
        $host = new ServiceHostTestFake($hostInfo);
        $dataService = new NorthWindService2();
        $dataService->setHost($host);
        try {
            $dataService->handleRequest();
            $this->fail('An expected ODataException for incorrect $skip value has not been thrown');
        } catch (ODataException $ex) {
            $this->assertStringStartsWith("Incorrect format for \$skip", $ex->getMessage());
        }
        $baseUri = 'http://localhost:8083/NorthWindDataService.svc/';
        $resourcePath = 'Orders';
        $hostInfo = array(
            'AbsoluteRequestUri' => new Url($baseUri . $resourcePath),
            'AbsoluteServiceUri' => new Url($baseUri),
            'QueryString' => '$skip=-123',
            'DataServiceVersion' => new Version(2, 0),
            'MaxDataServiceVersion' => new Version(2, 0),
        );
        $host = new ServiceHostTestFake($hostInfo);
        $dataService = new NorthWindService2();
        $dataService->setHost($host);
        try {
            $dataService->handleRequest();
            $this->fail('An expected ODataException for incorrect $skip value has not been thrown');
        } catch (ODataException $ex) {
            $this->assertStringStartsWith('Incorrect format for $skip', $ex->getMessage());
        }
    }
public function testUriProcessorForSkipAndTop ( ) { $ baseUri = 'http://localhost:8083/NorthWindDataService.svc/' ; $ resourcePath = 'Orders' ; $ hostInfo = array ( 'AbsoluteRequestUri' => new Url ( $ baseUri . $ resourcePath ) , 'AbsoluteServiceUri' => new Url ( $ baseUri ) , 'QueryString' => '$top=\'ABC\'' , 'DataServiceVersion' => new Version ( 2 , 0 ) , 'MaxDataServiceVersion' => new Version ( 2 , 0 ) , ) ; $ host = new ServiceHostTestFake ( $ hostInfo ) ; $ dataService = new NorthWindService2 ( ) ; $ dataService -> setHost ( $ host ) ; try { $ dataService -> handleRequest ( ) ; $ this -> fail ( 'An expected ODataException for incorrect $top value has not been thrown' ) ; } catch ( ODataException $ ex ) { $ this -> assertStringStartsWith ( " Incorrect format for  \$ top " , $ ex -> getMessage ( ) ) ; } $ baseUri = 'http://localhost:8083/NorthWindDataService.svc/' ; $ resourcePath = 'Orders' ; $ hostInfo = array ( 'AbsoluteRequestUri' => new Url ( $ baseUri . $ resourcePath ) , 'AbsoluteServiceUri' => new Url ( $ baseUri ) , 'QueryString' => '$top=-123' , 'DataServiceVersion' => new Version ( 2 , 0 ) , 'MaxDataServiceVersion' => new Version ( 2 , 0 ) , ) ; $ host = new ServiceHostTestFake ( $ hostInfo ) ; $ dataService = new NorthWindService2 ( ) ; $ dataService -> setHost ( $ host ) ; try { $ dataService -> handleRequest ( ) ; $ this -> fail ( 'An expected ODataException for incorrect $top value has not been thrown' ) ; } catch ( ODataException $ ex ) { $ this -> assertStringStartsWith ( 'Incorrect format for $top' , $ ex -> getMessage ( ) ) ; } $ baseUri = 'http://localhost:8083/NorthWindDataService.svc/' ; $ resourcePath = 'Orders' ; $ hostInfo = array ( 'AbsoluteRequestUri' => new Url ( $ baseUri . $ resourcePath ) , 'AbsoluteServiceUri' => new Url ( $ baseUri ) , 'QueryString' => '$skip=\'ABC\'' , 'DataServiceVersion' => new Version ( 2 , 0 ) , 'MaxDataServiceVersion' => new Version ( 2 , 0 ) , ) ; $ host = new ServiceHostTestFake ( $ hostInfo ) ; $ dataService = new NorthWindService2 ( ) ; $ dataService -> setHost ( $ host ) ; try { $ dataService -> handleRequest ( ) ; $ this -> fail ( 'An expected ODataException for incorrect $skip value has not been thrown' ) ; } catch ( ODataException $ ex ) { $ this -> assertStringStartsWith ( " Incorrect format for  \$ skip " , $ ex -> getMessage ( ) ) ; } $ baseUri = 'http://localhost:8083/NorthWindDataService.svc/' ; $ resourcePath = 'Orders' ; $ hostInfo = array ( 'AbsoluteRequestUri' => new Url ( $ baseUri . $ resourcePath ) , 'AbsoluteServiceUri' => new Url ( $ baseUri ) , 'QueryString' => '$skip=-123' , 'DataServiceVersion' => new Version ( 2 , 0 ) , 'MaxDataServiceVersion' => new Version ( 2 , 0 ) , ) ; $ host = new ServiceHostTestFake ( $ hostInfo ) ; $ dataService = new NorthWindService2 ( ) ; $ dataService -> setHost ( $ host ) ; try { $ dataService -> handleRequest ( ) ; $ this -> fail ( 'An expected ODataException for incorrect $skip value has not been thrown' ) ; } catch ( ODataException $ ex ) { $ this -> assertStringStartsWith ( 'Incorrect format for $skip' , $ ex -> getMessage ( ) ) ; } }
Test uri prcoessor for $skip and $top options
Test uri prcoessor for $skip and $top options
//TODO: Break this apart into separate tests