Changeset 1291

Show
Ignore:
Timestamp:
01/23/08 23:27:41 (10 months ago)
Author:
mikey
Message:

continued refactoring #118: converted tests for net::stubbles::util

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/net/http/stubHTTPURL.php

    r1232 r1291  
    8484    { 
    8585        if (is_string($key) == false) { 
    86             throw new stubIllegalArgumentException('Argument 1 passed to ' . __METHOD__ . ' must be an instance of string.'); 
     86            throw new stubIllegalArgumentException('Argument 1 passed to ' . __METHOD__ . '() must be an instance of string.'); 
    8787        } 
    8888         
    8989        if (null !== $value && is_array($value) == false && is_scalar($value) == false) { 
    90             throw new stubIllegalArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be an instance of string, array or any other scalar value or null.'); 
     90            throw new stubIllegalArgumentException('Argument 2 passed to ' . __METHOD__ . '() must be an instance of string, array or any other scalar value or null.'); 
    9191        } 
    9292         
  • trunk/src/test/php/net/stubbles/util/UtilTestSuite.php

    r1288 r1291  
    4949 
    5050        // net classes 
    51         #$suite->addTestFile($dir . '/net/stubHeaderListTestCase.php'); 
    52         #$suite->addTestFile($dir . '/net/stubSocketTestCase.php'); 
    53         #$suite->addTestFile($dir . '/net/stubURLTestCase.php'); 
     51        $suite->addTestFile($dir . '/net/stubHeaderListTestCase.php'); 
     52        $suite->addTestFile($dir . '/net/stubSocketTestCase.php'); 
     53        $suite->addTestFile($dir . '/net/stubURLTestCase.php'); 
    5454 
    5555        // net_http classes 
    56         #$suite->addTestFile($dir . '/net/http/stubHTTPURLTestCase.php'); 
     56        $suite->addTestFile($dir . '/net/http/stubHTTPURLTestCase.php'); 
    5757 
    5858        // now all the validators 
    59         #$suite->addTestFile($dir . '/validators/stubAndValidatorTestCase.php'); 
    60         #$suite->addTestFile($dir . '/validators/stubContainsValidatorTestCase.php'); 
    61         #$suite->addTestFile($dir . '/validators/stubEqualValidatorTestCase.php'); 
    62         #$suite->addTestFile($dir . '/validators/stubExtFilterValidatorTestCase.php'); 
    63         #$suite->addTestFile($dir . '/validators/stubIpValidatorTestCase.php'); 
    64         #$suite->addTestFile($dir . '/validators/stubMailValidatorTestCase.php'); 
    65         #$suite->addTestFile($dir . '/validators/stubMaxLengthValidatorTestCase.php'); 
    66         #$suite->addTestFile($dir . '/validators/stubMaxNumberValidatorTestCase.php'); 
    67         #$suite->addTestFile($dir . '/validators/stubMinLengthValidatorTestCase.php'); 
    68         #$suite->addTestFile($dir . '/validators/stubMinNumberValidatorTestCase.php'); 
    69         #$suite->addTestFile($dir . '/validators/stubOrValidatorTestCase.php'); 
    70         #$suite->addTestFile($dir . '/validators/stubPreSelectValidatorTestCase.php'); 
    71         #$suite->addTestFile($dir . '/validators/stubRegexValidatorTestCase.php'); 
    72         #$suite->addTestFile($dir . '/validators/stubXorValidatorTestCase.php'); 
     59        $suite->addTestFile($dir . '/validators/stubAndValidatorTestCase.php'); 
     60        $suite->addTestFile($dir . '/validators/stubContainsValidatorTestCase.php'); 
     61        $suite->addTestFile($dir . '/validators/stubEqualValidatorTestCase.php'); 
     62        $suite->addTestFile($dir . '/validators/stubExtFilterValidatorTestCase.php'); 
     63        $suite->addTestFile($dir . '/validators/stubIpValidatorTestCase.php'); 
     64        $suite->addTestFile($dir . '/validators/stubMailValidatorTestCase.php'); 
     65        $suite->addTestFile($dir . '/validators/stubMaxLengthValidatorTestCase.php'); 
     66        $suite->addTestFile($dir . '/validators/stubMaxNumberValidatorTestCase.php'); 
     67        $suite->addTestFile($dir . '/validators/stubMinLengthValidatorTestCase.php'); 
     68        $suite->addTestFile($dir . '/validators/stubMinNumberValidatorTestCase.php'); 
     69        $suite->addTestFile($dir . '/validators/stubOrValidatorTestCase.php'); 
     70        $suite->addTestFile($dir . '/validators/stubPreSelectValidatorTestCase.php'); 
     71        $suite->addTestFile($dir . '/validators/stubRegexValidatorTestCase.php'); 
     72        $suite->addTestFile($dir . '/validators/stubXorValidatorTestCase.php'); 
    7373 
    7474        // xjconf 
    75         #$suite->addTestFile($dir . '/xjconf/stubXJConfProxyTestCase.php'); 
     75        $suite->addTestFile($dir . '/xjconf/stubXJConfProxyTestCase.php'); 
    7676        return $suite; 
    7777    } 
  • trunk/src/test/php/net/stubbles/util/net/http/stubHTTPURLTestCase.php

    r1230 r1291  
    88 */ 
    99stubClassLoader::load('net::stubbles::util::net::http::stubHTTPURL'); 
    10 Mock::generate('stubSession'); 
    1110/** 
    1211 * Test for net::stubbles::util::net::http::stubHTTPURL. 
     
    1514 * @subpackage  util_net_http_test 
    1615 */ 
    17 class stubHTTPURLTestCase extends UnitTestCase 
     16class stubHTTPURLTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
    2019     * assure that values are returned the expected way 
    21      */ 
    22     public function testValue() 
     20     * 
     21     * @test 
     22     */ 
     23    public function value() 
    2324    { 
    2425        $http = stubHTTPURL::fromString('http://example.com/'); 
    2526        $this->assertTrue($http->isValid()); 
    2627        $this->assertTrue($http->hasDefaultPort()); 
    27         $this->assertEqual($http->get(), 'http://example.com/'); 
    28         $this->assertEqual($http->getScheme(), 'http'); 
    29         $this->assertEqual($http->getHost(), 'example.com'); 
    30         $this->assertEqual($http->getPort(), 80); 
    31         $this->assertEqual($http->getPath(), '/'); 
     28        $this->assertEquals('http://example.com/', $http->get()); 
     29        $this->assertEquals('http://example.com:80/', $http->get(true)); 
     30        $this->assertEquals('http', $http->getScheme()); 
     31        $this->assertEquals('example.com', $http->getHost()); 
     32        $this->assertEquals(80, $http->getPort()); 
     33        $this->assertEquals('/', $http->getPath()); 
    3234        $this->assertFalse($http->hasQuery()); 
    3335        $this->assertTrue($http->checkDNS()); 
     
    3638        $this->assertTrue($http->isValid()); 
    3739        $this->assertTrue($http->hasDefaultPort()); 
    38         $this->assertEqual($http->get(), 'https://example.com/'); 
    39         $this->assertEqual($http->get(true), 'https://example.com:143/'); 
    40         $this->assertEqual($http->getScheme(), 'https'); 
    41         $this->assertEqual($http->getHost(), 'example.com'); 
    42         $this->assertEqual($http->getPort(), 143); 
    43         $this->assertEqual($http->getPath(), '/'); 
    44         $this->assertFalse($http->hasQuery()); 
    45         $this->assertTrue($http->checkDNS()); 
    46     } 
    47  
    48     /** 
    49      * assure that values are returned the expected way 
    50      */ 
    51     public function testValueComplete() 
     40        $this->assertEquals('https://example.com/', $http->get()); 
     41        $this->assertEquals('https://example.com:143/', $http->get(true)); 
     42        $this->assertEquals('https', $http->getScheme()); 
     43        $this->assertEquals('example.com', $http->getHost()); 
     44        $this->assertEquals(143, $http->getPort()); 
     45        $this->assertEquals('/', $http->getPath()); 
     46        $this->assertFalse($http->hasQuery()); 
     47        $this->assertTrue($http->checkDNS()); 
     48    } 
     49 
     50    /** 
     51     * assure that values are returned the expected way 
     52     * 
     53     * @test 
     54     */ 
     55    public function valueComplete() 
    5256    {     
    5357        $http = stubHTTPURL::fromString('http://eXAMPle.com:80/index.php?content=features#top'); 
    5458        $this->assertTrue($http->isValid()); 
    5559        $this->assertTrue($http->hasDefaultPort()); 
    56         $this->assertEqual($http->get(true), 'http://example.com:80/index.php?content=features#top'); 
    57         $this->assertEqual($http->getHost(), 'example.com'); 
    58         $this->assertEqual($http->getPort(), 80); 
    59         $this->assertEqual($http->getPath(), '/index.php?content=features'); 
    60         $this->assertTrue($http->hasQuery()); 
    61         $this->assertTrue($http->checkDNS()); 
    62     } 
    63  
    64     /** 
    65      * assure that values are returned the expected way 
    66      */ 
    67     public function testValueLocalhost() 
     60        $this->assertEquals('http://example.com:80/index.php?content=features#top', $http->get(true)); 
     61        $this->assertEquals('example.com', $http->getHost()); 
     62        $this->assertEquals(80, $http->getPort()); 
     63        $this->assertEquals('/index.php?content=features', $http->getPath()); 
     64        $this->assertTrue($http->hasQuery()); 
     65        $this->assertTrue($http->checkDNS()); 
     66    } 
     67 
     68    /** 
     69     * assure that values are returned the expected way 
     70     * 
     71     * @test 
     72     */ 
     73    public function valueLocalhost() 
    6874    { 
    6975        $http = stubHTTPURL::fromString('http://localhost:125/'); 
    7076        $this->assertTrue($http->isValid()); 
    7177        $this->assertFalse($http->hasDefaultPort()); 
    72         $this->assertEqual($http->get(), 'http://localhost/'); 
    73         $this->assertEqual($http->getHost(), 'localhost'); 
    74         $this->assertEqual($http->getPort(), 125); 
    75         $this->assertEqual($http->getPath(), '/'); 
    76         $this->assertFalse($http->hasQuery()); 
    77         $this->assertTrue($http->checkDNS()); 
    78     } 
    79  
    80     /** 
    81      * assure that values are returned the expected way 
    82      */ 
    83     public function testValueIP() 
     78        $this->assertEquals('http://localhost/', $http->get()); 
     79        $this->assertEquals('http://localhost:125/', $http->get(true)); 
     80        $this->assertEquals('localhost', $http->getHost()); 
     81        $this->assertEquals(125, $http->getPort()); 
     82        $this->assertEquals('/', $http->getPath()); 
     83        $this->assertFalse($http->hasQuery()); 
     84        $this->assertTrue($http->checkDNS()); 
     85    } 
     86 
     87    /** 
     88     * assure that values are returned the expected way 
     89     * 
     90     * @test 
     91     */ 
     92    public function valueIP() 
    8493    { 
    8594        $http = stubHTTPURL::fromString('http://127.0.0.1/'); 
    8695        $this->assertTrue($http->isValid()); 
    8796        $this->assertTrue($http->hasDefaultPort()); 
    88         $this->assertEqual($http->get(), 'http://127.0.0.1/'); 
    89         $this->assertEqual($http->getHost(), '127.0.0.1'); 
    90         $this->assertEqual($http->getPort(), 80); 
    91         $this->assertEqual($http->getPath(), '/'); 
     97        $this->assertEquals('http://127.0.0.1/', $http->get()); 
     98        $this->assertEquals('http://127.0.0.1:80/', $http->get(true)); 
     99        $this->assertEquals('127.0.0.1', $http->getHost()); 
     100        $this->assertEquals(80, $http->getPort()); 
     101        $this->assertEquals($http->getPath(), '/'); 
    92102        $this->assertFalse($http->hasQuery()); 
    93103        $this->assertTrue($http->checkDNS()); 
     
    96106    /** 
    97107     * assure that wrong values trigger an exception 
    98      */ 
    99     public function testWrongValue() 
    100     { 
    101         $this->expectException('stubMalformedURLException'); 
     108     * 
     109     * @test 
     110     */ 
     111    public function wrongValue() 
     112    { 
     113        $this->setExpectedException('stubMalformedURLException'); 
    102114        $url = stubHTTPURL::fromString('blubber'); 
    103115    } 
     
    105117    /** 
    106118     * assure that an empty string does not generate an instance of stubURL 
    107      */ 
    108     public function testEmptyString() 
     119     * 
     120     * @test 
     121     */ 
     122    public function emptyString() 
    109123    { 
    110124        $this->assertNull(stubHTTPURL::fromString('')); 
     
    113127    /** 
    114128     * assure that wrong scheme triggers an exception 
    115      */ 
    116     public function testWrongScheme() 
    117     { 
    118         $this->expectException('stubMalformedURLException'); 
     129     * 
     130     * @test 
     131     */ 
     132    public function wrongScheme() 
     133    { 
     134        $this->setExpectedException('stubMalformedURLException'); 
    119135        $url = stubHTTPURL::fromString('ftp://user:password@auxiliary.kl-s.com/'); 
    120136    } 
     
    122138    /** 
    123139     * assure that added parameters are correct in complete url and path 
    124      */ 
    125     public function testParams() 
     140     * 
     141     * @test 
     142     */ 
     143    public function params() 
    126144    { 
    127145        $http = stubHTTPURL::fromString('http://example.org/'); 
     
    130148        $http->addParam('test', 'hello'); 
    131149        $this->assertTrue($http->hasQuery()); 
    132         $this->assertEqual($http->get(), 'http://example.org/?test=hello'); 
    133         $this->assertEqual($http->getPath(), '/?test=hello'); 
     150        $this->assertEquals('http://example.org/?test=hello', $http->get()); 
     151        $this->assertEquals('/?test=hello', $http->getPath()); 
    134152         
    135153        $http->addParam('test2', 538); 
    136154        $this->assertTrue($http->hasQuery()); 
    137         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538'); 
    138         $this->assertEqual($http->getPath(), '/?test=hello&test2=538'); 
     155        $this->assertEquals('http://example.org/?test=hello&test2=538', $http->get()); 
     156        $this->assertEquals('/?test=hello&test2=538', $http->getPath()); 
    139157         
    140158        $http->addParam('test3', array(1, 2, 3)); 
    141159        $this->assertTrue($http->hasQuery()); 
    142         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538&test3[]=1&test3[]=2&test3[]=3'); 
    143         $this->assertEqual($http->getPath(), '/?test=hello&test2=538&test3[]=1&test3[]=2&test3[]=3'); 
     160        $this->assertEquals('http://example.org/?test=hello&test2=538&test3[]=1&test3[]=2&test3[]=3', $http->get()); 
     161        $this->assertEquals('/?test=hello&test2=538&test3[]=1&test3[]=2&test3[]=3', $http->getPath()); 
    144162         
    145163        $http->addParam('test3', array('one' => 1, 'two' => 2, 'three' => 3)); 
    146164        $this->assertTrue($http->hasQuery()); 
    147         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[three]=3'); 
    148         $this->assertEqual($http->getPath(), '/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[three]=3'); 
     165        $this->assertEquals('http://example.org/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[three]=3', $http->get()); 
     166        $this->assertEquals('/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[three]=3', $http->getPath()); 
    149167         
    150168        $http->addParam('test3', array('one' => 1, 'two' => 2, 3)); 
    151169        $this->assertTrue($http->hasQuery()); 
    152         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[]=3'); 
    153         $this->assertEqual($http->getPath(), '/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[]=3'); 
     170        $this->assertEquals('http://example.org/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[]=3', $http->get()); 
     171        $this->assertEquals('/?test=hello&test2=538&test3[one]=1&test3[two]=2&test3[]=3', $http->getPath()); 
    154172         
    155173        $http->addParam('test3', null); 
    156174        $this->assertTrue($http->hasQuery()); 
    157         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538'); 
    158         $this->assertEqual($http->getPath(), '/?test=hello&test2=538'); 
     175        $this->assertEquals('http://example.org/?test=hello&test2=538', $http->get()); 
     176        $this->assertEquals('/?test=hello&test2=538', $http->getPath()); 
    159177         
    160178        $http->addParam('test3', true); 
    161179        $this->assertTrue($http->hasQuery()); 
    162         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538&test3=1'); 
    163         $this->assertEqual($http->getPath(), '/?test=hello&test2=538&test3=1'); 
     180        $this->assertEquals('http://example.org/?test=hello&test2=538&test3=1', $http->get()); 
     181        $this->assertEquals('/?test=hello&test2=538&test3=1', $http->getPath()); 
    164182         
    165183        $http->addParam('test3', false); 
    166184        $this->assertTrue($http->hasQuery()); 
    167         $this->assertEqual($http->get(), 'http://example.org/?test=hello&test2=538&test3=0'); 
    168         $this->assertEqual($http->getPath(), '/?test=hello&test2=538&test3=0'); 
     185        $this->assertEquals('http://example.org/?test=hello&test2=538&test3=0', $http->get()); 
     186        $this->assertEquals('/?test=hello&test2=538&test3=0', $http->getPath()); 
    169187    } 
    170188 
     
    172190     * assure that paramter without value is valid 
    173191     * e.g.: http://example.org?wsdl  
    174      *       http://example.org?key1&foo=bar&key2  
    175      */ 
    176     public function testKeyWithoutParam() 
     192     *       http://example.org?key1&foo=bar&key2 
     193     * 
     194     * @test 
     195     */ 
     196    public function keyWithoutParam() 
    177197    { 
    178198        $http = stubHTTPURL::fromString('http://example.org/'); 
     
    180200        $http->addParam('key1', ''); 
    181201        $this->assertTrue($http->hasQuery()); 
    182         $this->assertEqual($http->get(),'http://example.org/?key1'); 
     202        $this->assertEquals('http://example.org/?key1', $http->get()); 
    183203        $http->addParam('foo', 'bar'); 
    184204        $http->addParam('key2', ''); 
    185         $this->assertEqual($http->get(),'http://example.org/?key1&foo=bar&key2'); 
     205        $this->assertEquals('http://example.org/?key1&foo=bar&key2', $http->get()); 
    186206    } 
    187207     
    188208    /** 
    189209     * assure that wrong parameters throw an exception 
    190      */ 
    191     public function testWrongParams() 
    192     { 
    193         $http = stubHTTPURL::fromString('http://example.org/'); 
    194         $this->expectException('stubIllegalArgumentException'); 
     210     * 
     211     * @test 
     212     */ 
     213    public function wrongParams() 
     214    { 
     215        $http = stubHTTPURL::fromString('http://example.org/'); 
     216        $this->setExpectedException('stubIllegalArgumentException'); 
    195217        $http->addParam('test', new stdClass()); 
    196218    } 
     
    198220    /** 
    199221     * assure that wrong keys throw an exception 
    200      */ 
    201     public function testWrongKeyForParams() 
    202     { 
    203         $http = stubHTTPURL::fromString('http://example.org/'); 
    204         $this->expectException('stubIllegalArgumentException'); 
     222     * 
     223     * @test 
     224     * @expectedException  stubIllegalArgumentException 
     225     */ 
     226    public function wrongKeyForParams() 
     227    { 
     228        $http = stubHTTPURL::fromString('http://example.org/'); 
     229        $this->setExpectedException('stubIllegalArgumentException'); 
    205230        $http->addParam(435, 'test'); 
    206231    } 
     
    208233    /** 
    209234     * assure getting a connection works as expected 
    210      */ 
    211     public function testConnection() 
     235     * 
     236     * @test 
     237     */ 
     238    public function connection() 
    212239    { 
    213240        $http = stubHTTPURL::fromString('http://example.com/'); 
    214241        $httpconnection = $http->getConnection(); 
    215         $this->assertIsA($httpconnection, 'stubHTTPConnection'); 
     242        $this->assertType('stubHTTPConnection', $httpconnection); 
    216243    } 
    217244} 
  • trunk/src/test/php/net/stubbles/util/net/stubHeaderListTestCase.php

    r1230 r1291  
    88 */ 
    99stubClassLoader::load('net::stubbles::util::net::stubHeaderList'); 
    10 Mock::generate('stubSession'); 
    1110/** 
    1211 * Test for net::stubbles::util::net::stubHeaderList. 
     
    1514 * @subpackage  util_net_test 
    1615 */ 
    17 class stubHeaderListTestCase extends UnitTestCase 
     16class stubHeaderListTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
     
    3433    /** 
    3534     * assure that the headerlist is established correct 
     35     * 
     36     * @test 
    3637     */ 
    37     public function testEstablish() 
     38    public function establish() 
    3839    { 
    39         $this->assertEqual($this->headerList->size(), 0); 
     40        $this->assertEquals(0, $this->headerList->size()); 
    4041    } 
    4142 
    4243    /** 
    4344     * assure that the headerlist gets values and returns them correct 
     45     * 
     46     * @test 
    4447     */ 
    45     public function testPut() 
     48    public function put() 
    4649    {     
    4750        $this->headerList->put('Binford', 6100); 
    48         $this->assertEqual($this->headerList->size(), 1); 
     51        $this->assertEquals(1, $this->headerList->size()); 
    4952        $this->assertTrue($this->headerList->containsKey('Binford')); 
    50         $this->assertEqual($this->headerList->get('Binford'), '6100'); 
     53        $this->assertEquals('6100', $this->headerList->get('Binford')); 
    5154    } 
    5255 
    5356    /** 
    5457     * assure that the headerlist throws an IllegalArgumentException when putting an array as value 
     58     * 
     59     * @test 
     60     * @expectedException  stubIllegalArgumentException 
    5561     */ 
    56     public function testPutArray() 
     62    public function putArray() 
    5763    { 
    58         $this->expectException('stubIllegalArgumentException'); 
    5964        $this->headerList->put('Binford', array(6100)); 
    6065    } 
     
    6267    /** 
    6368     * assure that the headerlist throws an IllegalArgumentException when putting an object as value 
     69     * 
     70     * @test 
     71     * @expectedException  stubIllegalArgumentException 
    6472     */ 
    65     public function testPutObject() 
     73    public function putObject() 
    6674    { 
    67         $this->expectException('stubIllegalArgumentException'); 
    6875        $this->headerList->put('Binford', new stdClass()); 
    6976    } 
     
    7178    /** 
    7279     * assure that the headerlist throws an IllegalArgumentException when putting a non-string as key 
     80     * 
     81     * @test 
     82     * @expectedException  stubIllegalArgumentException 
    7383     */ 
    74     public function testPutUnusualKey() 
     84    public function putUnusualKey() 
    7585    { 
    76         $this->expectException('stubIllegalArgumentException'); 
    7786        $this->headerList->put(6100, new stdClass()); 
    7887    } 
     
    8089    /** 
    8190     * assure that the headerlist removes values correct 
     91     * 
     92     * @test 
    8293     */ 
    83     public function testRemove() 
     94    public function remove() 
    8495    { 
    8596        $this->headerList->put('Binford', '6100'); 
     
    90101    /** 
    91102     * assure that the headerlist puts predefined keys and values correctly 
     103     * 
     104     * @test 
    92105     */ 
    93     public function testPutX() 
     106    public function putX() 
    94107    { 
    95108        $this->headerList->putUserAgent('Binford 6100'); 
     
    102115         
    103116        $this->assertTrue($this->headerList->containsKey('User-Agent')); 
    104         $this->assertEqual($this->headerList->get('User-Agent'), 'Binford 6100'); 
     117        $this->assertEquals('Binford 6100', $this->headerList->get('User-Agent')); 
    105118        $this->assertTrue($this->headerList->containsKey('Referer')); 
    106         $this->assertEqual($this->headerList->get('Referer'), 'Home Improvement'); 
     119        $this->assertEquals('Home Improvement', $this->headerList->get('Referer')); 
    107120        $this->assertTrue($this->headerList->containsKey('Cookie')); 
    108         $this->assertEqual($this->headerList->get('Cookie'), 'testcookie1=' . urlencode('testvalue1 %&') . ';'); 
     121        $this->assertEquals('testcookie1=' . urlencode('testvalue1 %&') . ';', $this->headerList->get('Cookie')); 
    109122        $this->assertTrue($this->headerList->containsKey('Authorization')); 
    110         $this->assertEqual($this->headerList->get('Authorization'), 'BASIC ' . base64_encode('user:pass')); 
     123        $this->assertEquals('BASIC ' . base64_encode('user:pass'), $this->headerList->get('Authorization')); 
    111124        $this->assertTrue($this->headerList->containsKey('Date')); 
    112         $this->assertEqual($this->headerList->get('Date'), gmdate('D, d M Y H:i:s', $time) . ' GMT'); 
     125        $this->assertEquals(gmdate('D, d M Y H:i:s', $time) . ' GMT', $this->headerList->get('Date')); 
    113126        $this->assertTrue($this->headerList->containsKey('X-Binford')); 
    114         $this->assertEqual($this->headerList->get('X-Binford'), 'More power!'); 
     127        $this->assertEquals('More power!', $this->headerList->get('X-Binford')); 
    115128         
    116         $this->assertEqual($this->headerList->size(), 6); 
     129        $this->assertEquals(6, $this->headerList->size()); 
    117130    } 
    118131 
    119132    /** 
    120133     * assure that the headerlist clears correctly 
     134     * 
     135     * @test 
    121136     */ 
    122     public function testClear() 
     137    public function clear() 
    123138    { 
    124139        $this->headerList->putUserAgent('Binford 6100'); 
     
    129144        $this->headerList->enablePower(); 
    130145         
    131         $this->assertEqual($this->headerList->size(), 6); 
     146        $this->assertEquals(6, $this->headerList->size()); 
    132147        $this->headerList->clear(); 
    133         $this->assertEqual($this->headerList->size(), 0); 
     148        $this->assertEquals(0, $this->headerList->size()); 
    134149    } 
    135150 
    136151    /** 
    137152     * assure that the headerlist parses a string of headers correctly 
     153     * 
     154     * @test 
    138155     */ 
    139     public function testParseString() 
     156    public function parseString() 
    140157    { 
    141158        $headerlist = stubHeaderList::fromString("Binford: 6100\r\nX-Power: More power!"); 
    142         $this->assertIsA($headerlist, 'stubHeaderList'); 
     159        $this->assertType('stubHeaderList', $headerlist); 
    143160        $this->assertTrue($headerlist->containsKey('Binford')); 
    144161        $this->assertTrue($headerlist->containsKey('X-Power')); 
    145         $this->assertEqual($headerlist->size(), 2); 
    146         $this->assertEqual($headerlist->get('Binford'), '6100'); 
    147         $this->assertEqual($headerlist->get('X-Power'), 'More power!'); 
     162        $this->assertEquals(2, $headerlist->size()); 
     163        $this->assertEquals('6100', $headerlist->get('Binford')); 
     164        $this->assertEquals('More power!', $headerlist->get('X-Power')); 
    148165    } 
    149166 
    150167    /** 
    151168     * assure that an empty headerlist generates an empty iterator 
     169     * 
     170     * @test 
    152171     */ 
    153     public function testEmptyIterator() 
     172    public function emptyIterator() 
    154173    { 
    155174        $counter = 0; 
     
    158177        } 
    159178         
    160         $this->assertEqual($counter, 0); 
     179        $this->assertEquals(0, $counter); 
    161180    } 
    162181 
    163182    /** 
    164183     * assure that a filled headerlist generates a non-empty iterator 
     184     * 
     185     * @test 
    165186     */ 
    166     public function testNonEmptyIterator() 
     187    public function nonEmptyIterator() 
    167188    { 
    168189        $counter = 0; 
     
    173194        } 
    174195         
    175         $this->assertEqual($counter, 2); 
     196        $this->assertEquals(2, $counter); 
    176197    } 
    177198} 
  • trunk/src/test/php/net/stubbles/util/net/stubSocketTestCase.php

    r1230 r1291  
    88 */ 
    99stubClassLoader::load('net::stubbles::util::net::stubSocket'); 
    10 Mock::generate('stubSession'); 
    1110/** 
    1211 * Test for net::stubbles::util::net::stubSocket. 
     
    1514 * @subpackage  util_net_test 
    1615 */ 
    17 class stubSocketTestCase extends UnitTestCase 
     16class stubSocketTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
    2019     * assure that values are returned the expected way 
     20     * 
     21     * @test 
    2122     */ 
    22     public function testValues() 
     23    public function values() 
    2324    { 
    2425        $socket = new stubSocket('example.com'); 
    25         $this->assertEqual($socket->getHost(), 'example.com'); 
    26         $this->assertEqual($socket->getPort(), 80); 
    27         $this->assertEqual($socket->getTimeout(), 30); 
     26        $this->assertEquals('example.com', $socket->getHost()); 
     27        $this->assertEquals(80, $socket->getPort()); 
     28        $this->assertEquals(30, $socket->getTimeout()); 
    2829        $socket->setTimeout(60); 
    29         $this->assertEqual($socket->getTimeout(), 60); 
     30        $this->assertEquals(60, $socket->getTimeout()); 
    3031        $this->assertFalse($socket->isConnected()); 
    3132        $this->assertTrue($socket->eof()); 
    32                  
     33    } 
     34 
     35    /** 
     36     * assure that values are returned the expected way 
     37     * 
     38     * @test 
     39     */ 
     40    public function valuesWithSocket() 
     41    { 
    3342        $socket = new stubSocket('example.com', 21); 
    34         $this->assertEqual($socket->getHost(), 'example.com'); 
    35         $this->assertEqual($socket->getPort(), 21); 
    36         $this->assertEqual($socket->getTimeout(), 30); 
     43        $this->assertEquals('example.com', $socket->getHost()); 
     44        $this->assertEquals(21, $socket->getPort()); 
     45        $this->assertEquals(30, $socket->getTimeout()); 
    3746        $socket->setTimeout(60); 
    38         $this->assertEqual($socket->getTimeout(), 60); 
     47        $this->assertEquals(60, $socket->getTimeout()); 
    3948        $this->assertFalse($socket->isConnected()); 
    4049        $this->assertTrue($socket->eof()); 
     
    4352    /** 
    4453     * assure that trying to read on an unconnected socket throws an IllegalStateException 
     54     * 
     55     * @test 
     56     * @expectedException  stubIllegalStateException 
    4557     */ 
    46     public function testReadOnUnconnected() 
     58    public function readOnUnconnected() 
    4759    {     
    4860        $socket = new stubSocket('example.com'); 
    49         $this->expectException('stubIllegalStateException'); 
    5061        $data = $socket->read(); 
    5162    } 
     
    5364    /** 
    5465     * assure that trying to read on an unconnected socket throws an IllegalStateException 
     66     * 
     67     * @test 
     68     * @expectedException  stubIllegalStateException 
    5569     */ 
    56     public function testReadLineOnUnconnected() 
     70    public function readLineOnUnconnected() 
    5771    { 
    5872        $socket = new stubSocket('example.com'); 
    59         $this->expectException('stubIllegalStateException'); 
    6073        $data = $socket->readLine(); 
    6174    } 
     
    6376    /** 
    6477     * assure that trying to write on an unconnected socket throws an IllegalStateException 
     78     * 
     79     * @test 
     80     * @expectedException  stubIllegalStateException 
    6581     */ 
    66     public function testWriteOnUnconnected() 
     82    public function writeOnUnconnected() 
    6783    { 
    6884        $socket = new stubSocket('example.com'); 
    69         $this->expectException('stubIllegalStateException'); 
    70         $data = $socket->write(); 
     85        $data = $socket->write('data'); 
    7186    } 
    7287} 
  • trunk/src/test/php/net/stubbles/util/net/stubURLTestCase.php

    r1230 r1291  
    88 */ 
    99stubClassLoader::load('net::stubbles::util::net::stubURL'); 
    10 Mock::generate('stubSession'); 
    1110/** 
    1211 * Test for net::stubbles::util::net::stubURL. 
     
    1514 * @subpackage  util_net_test 
    1615 */ 
    17 class stubURLTestCase extends UnitTestCase 
     16class stubURLTestCase extends PHPUnit_Framework_TestCase 
    1817{ 
    1918    /** 
    2019     * assure that values are returned the expected way 
    21      */ 
    22     public function testValue() 
     20     * 
     21     * @test 
     22     */ 
     23    public function value() 
    2324    { 
    2425        $url = stubURL::fromString('http://example.com/'); 
    2526        $this->assertTrue($url->isValid()); 
    26         $this->assertEqual($url->get(), 'http://example.com/'); 
    27         $this->assertEqual($url->getScheme(), 'http'); 
    28         $this->assertNull($url->getUser()); 
    29         $this->assertEqual($url->getUser('foo'), 'foo'); 
    30         $this->assertNull($url->getPassword()); 
    31         $this->assertEqual($url->getPassword('foo'), 'foo'); 
    32         $this->assertEqual($url->getHost(), 'example.com'); 
    33         $this->assertNull($url->getPort()); 
    34         $this->assertEqual($url->getPort(313), 313); 
     27        $this->assertEquals('http://example.com/', $url->get()); 
     28        $this->assertEquals('http', $url->getScheme()); 
     29        $this->assertNull($url->getUser()); 
     30        $this->assertEquals('foo', $url->getUser('foo')); 
     31        $this->assertNull($url->getPassword()); 
     32        $this->assertEquals('foo', $url->getPassword('foo')); 
     33        $this->assertEquals('example.com', $url->getHost()); 
     34        $this->assertNull($url->getPort()); 
     35        $this->assertEquals(313, $url->getPort(313)); 
    3536        $url->setPort(303); 
    36         $this->assertEqual($url->getPort(), 303); 
    37         $this->assertEqual($url->getPort(313), 303); 
    38         $this->assertEqual($url->getPath(), '/'); 
    39         $this->assertFalse($url->hasQuery()); 
    40         $this->assertTrue($url->checkDNS()); 
    41     } 
    42  
    43     /** 
    44      * assure that values are returned the expected way 
    45      */ 
    46     public function testValueComplete() 
     37        $this->assertEquals(303, $url->getPort()); 
     38        $this->assertEquals(303, $url->getPort(313)); 
     39        $this->assertEquals('/', $url->getPath()); 
     40        $this->assertFalse($url->hasQuery()); 
     41        $this->assertTrue($url->checkDNS()); 
     42    } 
     43 
     44    /** 
     45     * assure that values are returned the expected way 
     46     * 
     47     * @test 
     48     */ 
     49    public function valueComplete() 
    4750    {     
    4851        $url = stubURL::fromString('http://exAmpLe.com:80/index.php?content=features#top'); 
    4952        $this->assertTrue($url->isValid()); 
    50         $this->assertEqual($url->get(TRUE), 'http://example.com:80/index.php?content=features#top'); 
    51         $this->assertEqual($url->getScheme(), 'http'); 
    52         $this->assertNull($url->getUser()); 
    53         $this->assertEqual($url->getUser('foo'), 'foo'); 
    54         $this->assertNull($url->getPassword()); 
    55         $this->assertEqual($url->getPassword('foo'), 'foo'); 
    56         $this->assertEqual($url->getHost(), 'example.com'); 
    57         $this->assertEqual($url->getPort(), 80); 
    58         $this->assertEqual($url->getPath(), '/index.php?content=features'); 
     53        $this->assertEquals('http://example.com:80/index.php?content=features#top', $url->get(true)); 
     54        $this->assertEquals('http', $url->getScheme()); 
     55        $this->assertNull($url->getUser()); 
     56        $this->assertEquals('foo', $url->getUser('foo')); 
     57        $this->assertNull($url->getPassword()); 
     58        $this->assertEquals('foo', $url->getPassword('foo')); 
     59        $this->assertEquals('example.com', $url->getHost()); 
     60        $this->assertEquals($url->getPort(), 80); 
     61        $this->assertEquals($url->getPath(), '/index.php?content=features'); 
    5962        $this->assertTrue($url->hasQuery()); 
    6063        $this->assertTrue($url->checkDNS()); 
     
    6366    /** 
    6467     * assure that values are returned the expected way 
    65      */ 
    66     public function testValueFTPComplete() 
     68     * 
     69     * @test 
     70     */ 
     71    public function valueFTPComplete() 
    6772    { 
    6873        $url = stubURL::fromString('ftp://user:password@example.com/'); 
    6974        $this->assertTrue($url->isValid()); 
    70         $this->assertEqual($url->get(TRUE), 'ftp://user:password@example.com/'); 
    71         $this->assertEqual($url->getScheme(), 'ftp'); 
    72         $this->assertEqual($url->getUser(), 'user'); 
    73         $this->assertEqual($url->getUser('foo'), 'user'); 
    74         $this->assertEqual($url->getPassword(), 'password'); 
    75         $this->assertEqual($url->getPassword('foo'), 'password'); 
    76         $this->assertEqual($url->getHost(), 'example.com'); 
    77         $this->assertNull($url->getPort()); 
    78         $this->assertEqual($url->getPort(313), 313); 
    79         $this->assertEqual($url->getPath(), '/'); 
    80         $this->assertFalse($url->hasQuery()); 
    81         $this->assertTrue($url->checkDNS()); 
    82     } 
    83  
    84     /** 
    85      * assure that values are returned the expected way 
    86      */ 
    87     public function testValueFTPWithoutPass() 
     75        $this->assertEquals('ftp://user:password@example.com/', $url->get(true)); 
     76        $this->assertEquals('ftp', $url->getScheme()); 
     77        $this->assertEquals('user', $url->getUser()); 
     78        $this->assertEquals('user', $url->getUser('foo')); 
     79        $this->assertEquals('password', $url->getPassword()); 
     80        $this->assertEquals('password', $url->getPassword('foo')); 
     81        $this->assertEquals('example.com', $url->getHost()); 
     82        $this->assertNull($url->getPort()); 
     83        $this->assertEquals(313, $url->getPort(313)); 
     84        $this->assertEquals('/', $url->getPath()); 
     85        $this->assertFalse($url->hasQuery()); 
     86        $this->assertTrue($url->checkDNS()); 
     87    } 
     88 
     89    /** 
     90     * assure that values are returned the expected way 
     91     * 
     92     * @test 
     93     */ 
     94    public function valueFTPWithoutPass() 
    8895    { 
    8996        $url = stubURL::fromString('ftp://user@example.com/'); 
    9097        $this->assertTrue($url->isValid()); 
    91         $this->assertEqual($url->get(), 'ftp://user@example.com/'); 
    92         $this->assertEqual($url->getScheme(), 'ftp'); 
    93         $this->assertEqual($url->getUser(), 'user'); 
    94         $this->assertEqual($url->getUser('foo'), 'user'); 
    95         $this->assertNull($url->getPassword()); 
    96         $this->assertEqual($url->getPassword('foo'), 'foo'); 
    97         $this->assertEqual($url->getHost(), 'example.com'); 
    98         $this->assertNull($url->getPort()); 
    99         $this->assertEqual($url->getPort(313), 313); 
    100         $this->assertEqual($url->getPath(), '/'); 
    101         $this->assertFalse($url->hasQuery()); 
    102         $this->assertTrue($url->checkDNS()); 
    103     }