Changeset 1105

Show
Ignore:
Timestamp:
12/04/07 11:29:10 (7 months ago)
Author:
mikey
Message:

added net::stubbles::ipo.request::stubRequest::acceptsCookies()
Warning! Default implementation of detection is based on the amount of cookie values returned by the user agent. If the user agent did not send any cookies this does not necessarily mean that the user agent will not accept cookies.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ipo/request/stubAbstractRequest.php

    r1034 r1105  
    8686 
    8787    /** 
     88     * checks if requestor accepts cookies 
     89     * 
     90     * Warning! Detection is based on the amount of cookie values returned by 
     91     * the user agent. If the user agent did not send any cookies this does not 
     92     * necessarily mean that the user agent will not accept cookies. 
     93     * 
     94     * @return  bool 
     95     */ 
     96    public function acceptsCookies() 
     97    { 
     98        return (count($this->unsecureCookies) > 0); 
     99    } 
     100 
     101    /** 
    88102     * checks whether a request value is set or not 
    89103     * 
  • trunk/src/main/php/net/stubbles/ipo/request/stubRequest.php

    r1036 r1105  
    4343 
    4444    /** 
     45     * checks if requestor accepts cookies 
     46     * 
     47     * @return  bool 
     48     */ 
     49    public function acceptsCookies(); 
     50 
     51    /** 
    4552     * checks whether a request value is set or not 
    4653     * 
  • trunk/src/main/php/net/stubbles/ipo/request/stubRequestPrefixDecorator.php

    r1036 r1105  
    7070 
    7171    /** 
     72     * checks if requestor accepts cookies 
     73     * 
     74     * @return  bool 
     75     */ 
     76    public function acceptsCookies() 
     77    { 
     78        return $this->request->acceptsCookies(); 
     79    } 
     80 
     81    /** 
    7282     * checks whether a request value is set or not 
    7383     * 
  • trunk/src/test/php/net/stubbles/ipo/request/stubAbstractRequestTestCase.php

    r1040 r1105  
    11<?php 
    22/** 
    3  * Tests for net.stubbles.ipo.request.stubAbstractRequest 
     3 * Tests for net::stubbles::ipo::request::stubAbstractRequest. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    3131    } 
    3232 
     33    public function removeCookieValues() 
     34    { 
     35        $this->unsecureCookies = array(); 
     36    } 
     37 
    3338    public function getMethod() 
    3439    { 
     
    5257} 
    5358/** 
    54  * Tests for net.stubbles.ipo.request.stubAbstractRequest 
     59 * Tests for net::stubbles::ipo::request::stubAbstractRequest. 
    5560 * 
    5661 * @package     stubbles 
     
    7277    { 
    7378        $this->request = new stubTestRequest(); 
     79    } 
     80 
     81    /** 
     82     * test whether cookies are accepted or not 
     83     * 
     84     */ 
     85    public function testAcceptsCookies() 
     86    { 
     87        $this->assertTrue($this->request->acceptsCookies()); 
     88        $this->request->removeCookieValues(); 
     89        $this->assertFalse($this->request->acceptsCookies()); 
    7490    } 
    7591 
  • trunk/src/test/php/net/stubbles/ipo/request/stubRequestPrefixDecoratorTestCase.php

    r1036 r1105  
    11<?php 
    22/** 
    3  * Tests for ipo.request.stubRequestPrefixDecorator 
     3 * Tests for net::stubbles::ipo::request::stubRequestPrefixDecorator. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
    66 * @package     stubbles 
    7  * @subpackage  ipo_test 
     7 * @subpackage  ipo_request_test 
    88 */ 
    99stubClassLoader::load('net.stubbles.ipo.request.stubRequestPrefixDecorator'); 
     
    1212Mock::generate('stubFilter'); 
    1313/** 
    14  * Tests for ipo.request.stubRequestPrefixDecorator 
     14 * Tests for net::stubbles::ipo::request::stubRequestPrefixDecorator. 
    1515 * 
    1616 * @package     stubbles 
    17  * @subpackage  ipo_test 
     17 * @subpackage  ipo_request_test 
    1818 */ 
    1919class stubRequestPrefixDecoratorTestCase extends UnitTestCase 
     
    3939        $this->mockRequest = new MockStubRequest(); 
    4040        $this->request     = new stubRequestPrefixDecorator($this->mockRequest, 'test'); 
     41    } 
     42 
     43    /** 
     44     * test that acceptCookies() returns correct answer 
     45     */ 
     46    public function testAcceptsCookies() 
     47    { 
     48        $this->mockRequest->setReturnValueAt(0, 'acceptsCookies', true); 
     49        $this->mockRequest->setReturnValueAt(1, 'acceptsCookies', false); 
     50        $this->assertTrue($this->request->acceptsCookies()); 
     51        $this->assertFalse($this->request->acceptsCookies()); 
    4152    } 
    4253