Changeset 1291
- Timestamp:
- 01/23/08 23:27:41 (10 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/util/net/http/stubHTTPURL.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/util/UtilTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/util/net/http/stubHTTPURLTestCase.php (modified) (12 diffs)
- trunk/src/test/php/net/stubbles/util/net/stubHeaderListTestCase.php (modified) (11 diffs)
- trunk/src/test/php/net/stubbles/util/net/stubSocketTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/util/net/stubURLTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubAndValidatorTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubContainsValidatorTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubEqualValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubExtFilterValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubIpValidatorTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubMailValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubMaxLengthValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubMaxNumberValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubMinLengthValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubMinNumberValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubOrValidatorTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubPreSelectValidatorTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubRegexValidatorTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/util/validators/stubXorValidatorTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/util/xjconf/stubXJConfProxyTestCase.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/util/net/http/stubHTTPURL.php
r1232 r1291 84 84 { 85 85 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.'); 87 87 } 88 88 89 89 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.'); 91 91 } 92 92 trunk/src/test/php/net/stubbles/util/UtilTestSuite.php
r1288 r1291 49 49 50 50 // 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'); 54 54 55 55 // net_http classes 56 #$suite->addTestFile($dir . '/net/http/stubHTTPURLTestCase.php');56 $suite->addTestFile($dir . '/net/http/stubHTTPURLTestCase.php'); 57 57 58 58 // 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'); 73 73 74 74 // xjconf 75 #$suite->addTestFile($dir . '/xjconf/stubXJConfProxyTestCase.php');75 $suite->addTestFile($dir . '/xjconf/stubXJConfProxyTestCase.php'); 76 76 return $suite; 77 77 } trunk/src/test/php/net/stubbles/util/net/http/stubHTTPURLTestCase.php
r1230 r1291 8 8 */ 9 9 stubClassLoader::load('net::stubbles::util::net::http::stubHTTPURL'); 10 Mock::generate('stubSession');11 10 /** 12 11 * Test for net::stubbles::util::net::http::stubHTTPURL. … … 15 14 * @subpackage util_net_http_test 16 15 */ 17 class stubHTTPURLTestCase extends UnitTestCase16 class stubHTTPURLTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** 20 19 * assure that values are returned the expected way 21 */ 22 public function testValue() 20 * 21 * @test 22 */ 23 public function value() 23 24 { 24 25 $http = stubHTTPURL::fromString('http://example.com/'); 25 26 $this->assertTrue($http->isValid()); 26 27 $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()); 32 34 $this->assertFalse($http->hasQuery()); 33 35 $this->assertTrue($http->checkDNS()); … … 36 38 $this->assertTrue($http->isValid()); 37 39 $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() 52 56 { 53 57 $http = stubHTTPURL::fromString('http://eXAMPle.com:80/index.php?content=features#top'); 54 58 $this->assertTrue($http->isValid()); 55 59 $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() 68 74 { 69 75 $http = stubHTTPURL::fromString('http://localhost:125/'); 70 76 $this->assertTrue($http->isValid()); 71 77 $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() 84 93 { 85 94 $http = stubHTTPURL::fromString('http://127.0.0.1/'); 86 95 $this->assertTrue($http->isValid()); 87 96 $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(), '/'); 92 102 $this->assertFalse($http->hasQuery()); 93 103 $this->assertTrue($http->checkDNS()); … … 96 106 /** 97 107 * 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'); 102 114 $url = stubHTTPURL::fromString('blubber'); 103 115 } … … 105 117 /** 106 118 * 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() 109 123 { 110 124 $this->assertNull(stubHTTPURL::fromString('')); … … 113 127 /** 114 128 * 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'); 119 135 $url = stubHTTPURL::fromString('ftp://user:password@auxiliary.kl-s.com/'); 120 136 } … … 122 138 /** 123 139 * assure that added parameters are correct in complete url and path 124 */ 125 public function testParams() 140 * 141 * @test 142 */ 143 public function params() 126 144 { 127 145 $http = stubHTTPURL::fromString('http://example.org/'); … … 130 148 $http->addParam('test', 'hello'); 131 149 $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()); 134 152 135 153 $http->addParam('test2', 538); 136 154 $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()); 139 157 140 158 $http->addParam('test3', array(1, 2, 3)); 141 159 $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()); 144 162 145 163 $http->addParam('test3', array('one' => 1, 'two' => 2, 'three' => 3)); 146 164 $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()); 149 167 150 168 $http->addParam('test3', array('one' => 1, 'two' => 2, 3)); 151 169 $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()); 154 172 155 173 $http->addParam('test3', null); 156 174 $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()); 159 177 160 178 $http->addParam('test3', true); 161 179 $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()); 164 182 165 183 $http->addParam('test3', false); 166 184 $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()); 169 187 } 170 188 … … 172 190 * assure that paramter without value is valid 173 191 * 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() 177 197 { 178 198 $http = stubHTTPURL::fromString('http://example.org/'); … … 180 200 $http->addParam('key1', ''); 181 201 $this->assertTrue($http->hasQuery()); 182 $this->assertEqual ($http->get(),'http://example.org/?key1');202 $this->assertEquals('http://example.org/?key1', $http->get()); 183 203 $http->addParam('foo', 'bar'); 184 204 $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()); 186 206 } 187 207 188 208 /** 189 209 * 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'); 195 217 $http->addParam('test', new stdClass()); 196 218 } … … 198 220 /** 199 221 * 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'); 205 230 $http->addParam(435, 'test'); 206 231 } … … 208 233 /** 209 234 * assure getting a connection works as expected 210 */ 211 public function testConnection() 235 * 236 * @test 237 */ 238 public function connection() 212 239 { 213 240 $http = stubHTTPURL::fromString('http://example.com/'); 214 241 $httpconnection = $http->getConnection(); 215 $this->assert IsA($httpconnection, 'stubHTTPConnection');242 $this->assertType('stubHTTPConnection', $httpconnection); 216 243 } 217 244 } trunk/src/test/php/net/stubbles/util/net/stubHeaderListTestCase.php
r1230 r1291 8 8 */ 9 9 stubClassLoader::load('net::stubbles::util::net::stubHeaderList'); 10 Mock::generate('stubSession');11 10 /** 12 11 * Test for net::stubbles::util::net::stubHeaderList. … … 15 14 * @subpackage util_net_test 16 15 */ 17 class stubHeaderListTestCase extends UnitTestCase16 class stubHeaderListTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** … … 34 33 /** 35 34 * assure that the headerlist is established correct 35 * 36 * @test 36 37 */ 37 public function testEstablish()38 public function establish() 38 39 { 39 $this->assertEqual ($this->headerList->size(), 0);40 $this->assertEquals(0, $this->headerList->size()); 40 41 } 41 42 42 43 /** 43 44 * assure that the headerlist gets values and returns them correct 45 * 46 * @test 44 47 */ 45 public function testPut()48 public function put() 46 49 { 47 50 $this->headerList->put('Binford', 6100); 48 $this->assertEqual ($this->headerList->size(), 1);51 $this->assertEquals(1, $this->headerList->size()); 49 52 $this->assertTrue($this->headerList->containsKey('Binford')); 50 $this->assertEqual ($this->headerList->get('Binford'), '6100');53 $this->assertEquals('6100', $this->headerList->get('Binford')); 51 54 } 52 55 53 56 /** 54 57 * assure that the headerlist throws an IllegalArgumentException when putting an array as value 58 * 59 * @test 60 * @expectedException stubIllegalArgumentException 55 61 */ 56 public function testPutArray()62 public function putArray() 57 63 { 58 $this->expectException('stubIllegalArgumentException');59 64 $this->headerList->put('Binford', array(6100)); 60 65 } … … 62 67 /** 63 68 * assure that the headerlist throws an IllegalArgumentException when putting an object as value 69 * 70 * @test 71 * @expectedException stubIllegalArgumentException 64 72 */ 65 public function testPutObject()73 public function putObject() 66 74 { 67 $this->expectException('stubIllegalArgumentException');68 75 $this->headerList->put('Binford', new stdClass()); 69 76 } … … 71 78 /** 72 79 * assure that the headerlist throws an IllegalArgumentException when putting a non-string as key 80 * 81 * @test 82 * @expectedException stubIllegalArgumentException 73 83 */ 74 public function testPutUnusualKey()84 public function putUnusualKey() 75 85 { 76 $this->expectException('stubIllegalArgumentException');77 86 $this->headerList->put(6100, new stdClass()); 78 87 } … … 80 89 /** 81 90 * assure that the headerlist removes values correct 91 * 92 * @test 82 93 */ 83 public function testRemove()94 public function remove() 84 95 { 85 96 $this->headerList->put('Binford', '6100'); … … 90 101 /** 91 102 * assure that the headerlist puts predefined keys and values correctly 103 * 104 * @test 92 105 */ 93 public function testPutX()106 public function putX() 94 107 { 95 108 $this->headerList->putUserAgent('Binford 6100'); … … 102 115 103 116 $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')); 105 118 $this->assertTrue($this->headerList->containsKey('Referer')); 106 $this->assertEqual ($this->headerList->get('Referer'), 'Home Improvement');119 $this->assertEquals('Home Improvement', $this->headerList->get('Referer')); 107 120 $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')); 109 122 $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')); 111 124 $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')); 113 126 $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')); 115 128 116 $this->assertEqual ($this->headerList->size(), 6);129 $this->assertEquals(6, $this->headerList->size()); 117 130 } 118 131 119 132 /** 120 133 * assure that the headerlist clears correctly 134 * 135 * @test 121 136 */ 122 public function testClear()137 public function clear() 123 138 { 124 139 $this->headerList->putUserAgent('Binford 6100'); … … 129 144 $this->headerList->enablePower(); 130 145 131 $this->assertEqual ($this->headerList->size(), 6);146 $this->assertEquals(6, $this->headerList->size()); 132 147 $this->headerList->clear(); 133 $this->assertEqual ($this->headerList->size(), 0);148 $this->assertEquals(0, $this->headerList->size()); 134 149 } 135 150 136 151 /** 137 152 * assure that the headerlist parses a string of headers correctly 153 * 154 * @test 138 155 */ 139 public function testParseString()156 public function parseString() 140 157 { 141 158 $headerlist = stubHeaderList::fromString("Binford: 6100\r\nX-Power: More power!"); 142 $this->assert IsA($headerlist, 'stubHeaderList');159 $this->assertType('stubHeaderList', $headerlist); 143 160 $this->assertTrue($headerlist->containsKey('Binford')); 144 161 $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')); 148 165 } 149 166 150 167 /** 151 168 * assure that an empty headerlist generates an empty iterator 169 * 170 * @test 152 171 */ 153 public function testEmptyIterator()172 public function emptyIterator() 154 173 { 155 174 $counter = 0; … … 158 177 } 159 178 160 $this->assertEqual ($counter, 0);179 $this->assertEquals(0, $counter); 161 180 } 162 181 163 182 /** 164 183 * assure that a filled headerlist generates a non-empty iterator 184 * 185 * @test 165 186 */ 166 public function testNonEmptyIterator()187 public function nonEmptyIterator() 167 188 { 168 189 $counter = 0; … … 173 194 } 174 195 175 $this->assertEqual ($counter, 2);196 $this->assertEquals(2, $counter); 176 197 } 177 198 } trunk/src/test/php/net/stubbles/util/net/stubSocketTestCase.php
r1230 r1291 8 8 */ 9 9 stubClassLoader::load('net::stubbles::util::net::stubSocket'); 10 Mock::generate('stubSession');11 10 /** 12 11 * Test for net::stubbles::util::net::stubSocket. … … 15 14 * @subpackage util_net_test 16 15 */ 17 class stubSocketTestCase extends UnitTestCase16 class stubSocketTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** 20 19 * assure that values are returned the expected way 20 * 21 * @test 21 22 */ 22 public function testValues()23 public function values() 23 24 { 24 25 $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()); 28 29 $socket->setTimeout(60); 29 $this->assertEqual ($socket->getTimeout(), 60);30 $this->assertEquals(60, $socket->getTimeout()); 30 31 $this->assertFalse($socket->isConnected()); 31 32 $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 { 33 42 $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()); 37 46 $socket->setTimeout(60); 38 $this->assertEqual ($socket->getTimeout(), 60);47 $this->assertEquals(60, $socket->getTimeout()); 39 48 $this->assertFalse($socket->isConnected()); 40 49 $this->assertTrue($socket->eof()); … … 43 52 /** 44 53 * assure that trying to read on an unconnected socket throws an IllegalStateException 54 * 55 * @test 56 * @expectedException stubIllegalStateException 45 57 */ 46 public function testReadOnUnconnected()58 public function readOnUnconnected() 47 59 { 48 60 $socket = new stubSocket('example.com'); 49 $this->expectException('stubIllegalStateException');50 61 $data = $socket->read(); 51 62 } … … 53 64 /** 54 65 * assure that trying to read on an unconnected socket throws an IllegalStateException 66 * 67 * @test 68 * @expectedException stubIllegalStateException 55 69 */ 56 public function testReadLineOnUnconnected()70 public function readLineOnUnconnected() 57 71 { 58 72 $socket = new stubSocket('example.com'); 59 $this->expectException('stubIllegalStateException');60 73 $data = $socket->readLine(); 61 74 } … … 63 76 /** 64 77 * assure that trying to write on an unconnected socket throws an IllegalStateException 78 * 79 * @test 80 * @expectedException stubIllegalStateException 65 81 */ 66 public function testWriteOnUnconnected()82 public function writeOnUnconnected() 67 83 { 68 84 $socket = new stubSocket('example.com'); 69 $this->expectException('stubIllegalStateException'); 70 $data = $socket->write(); 85 $data = $socket->write('data'); 71 86 } 72 87 } trunk/src/test/php/net/stubbles/util/net/stubURLTestCase.php
r1230 r1291 8 8 */ 9 9 stubClassLoader::load('net::stubbles::util::net::stubURL'); 10 Mock::generate('stubSession');11 10 /** 12 11 * Test for net::stubbles::util::net::stubURL. … … 15 14 * @subpackage util_net_test 16 15 */ 17 class stubURLTestCase extends UnitTestCase16 class stubURLTestCase extends PHPUnit_Framework_TestCase 18 17 { 19 18 /** 20 19 * assure that values are returned the expected way 21 */ 22 public function testValue() 20 * 21 * @test 22 */ 23 public function value() 23 24 { 24 25 $url = stubURL::fromString('http://example.com/'); 25 26 $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)); 35 36 $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() 47 50 { 48 51 $url = stubURL::fromString('http://exAmpLe.com:80/index.php?content=features#top'); 49 52 $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'); 59 62 $this->assertTrue($url->hasQuery()); 60 63 $this->assertTrue($url->checkDNS()); … … 63 66 /** 64 67 * assure that values are returned the expected way 65 */ 66 public function testValueFTPComplete() 68 * 69 * @test 70 */ 71 public function valueFTPComplete() 67 72 { 68 73 $url = stubURL::fromString('ftp://user:password@example.com/'); 69 74 $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() 88 95 { 89 96 $url = stubURL::fromString('ftp://user@example.com/'); 90 97 $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 }
