Skip to content
This repository
Browse code

using annotations for catching exceptions in tests

  • Loading branch information...
commit f9f380d4013bf50eddeb501de026e38d1a3db1dd 1 parent d7f93f5
Jorge M. González Martín authored
10  lib/Cake/Test/Case/Network/CakeSocketTest.php
@@ -218,6 +218,7 @@ public function testReset() {
218 218
 /**
219 219
  * testEncrypt
220 220
  * 
  221
+ * @expectedException SocketException
221 222
  * @return void
222 223
  */	
223 224
 	public function testEnableCryptoSocketExceptionNoSsl() {
@@ -226,13 +227,13 @@ public function testEnableCryptoSocketExceptionNoSsl() {
226 227
 		// testing exception on no ssl socket server for ssl and tls methods
227 228
 		$this->Socket = new CakeSocket($configNoSslOrTls);
228 229
 		$this->Socket->connect();
229  
-		$this->setExpectedException('SocketException');
230 230
 		$this->Socket->enableCrypto('sslv3', 'client');
231 231
 	}
232 232
 
233 233
 /**
234 234
  * testEnableCryptoSocketExceptionNoTls
235 235
  * 
  236
+ * @expectedException SocketException
236 237
  * @return void
237 238
  */	
238 239
 	public function testEnableCryptoSocketExceptionNoTls() {
@@ -241,7 +242,6 @@ public function testEnableCryptoSocketExceptionNoTls() {
241 242
 		// testing exception on no ssl socket server for ssl and tls methods
242 243
 		$this->Socket = new CakeSocket($configNoSslOrTls);
243 244
 		$this->Socket->connect();
244  
-		$this->setExpectedException('SocketException');
245 245
 		$this->Socket->enableCrypto('tls', 'client');
246 246
 	}
247 247
 
@@ -259,12 +259,12 @@ protected function _connectSocketToSslTls() {
259 259
 /**
260 260
  * testEnableCryptoBadMode
261 261
  * 
  262
+ * @expectedException InvalidArgumentException
262 263
  * @return void
263 264
  */	
264 265
 	public function testEnableCryptoBadMode() {
265 266
 		// testing wrong encryption mode
266 267
 		$this->_connectSocketToSslTls();
267  
-		$this->setExpectedException('InvalidArgumentException');
268 268
 		$this->Socket->enableCrypto('doesntExistMode', 'server');
269 269
 		$this->Socket->disconnect();
270 270
 	}
@@ -289,25 +289,25 @@ public function testEnableCrypto() {
289 289
 /**
290 290
  * testEnableCryptoExceptionEnableTwice
291 291
  * 
  292
+ * @expectedException SocketException
292 293
  * @return void
293 294
  */	
294 295
 	public function testEnableCryptoExceptionEnableTwice() {
295 296
 		// testing on tls server
296 297
 		$this->_connectSocketToSslTls();
297 298
 		$this->Socket->enableCrypto('tls', 'client');
298  
-		$this->setExpectedException('SocketException');
299 299
 		$this->Socket->enableCrypto('tls', 'client');
300 300
 	}
301 301
 
302 302
 /**
303 303
  * testEnableCryptoExceptionDisableTwice
304 304
  * 
  305
+ * @expectedException SocketException
305 306
  * @return void
306 307
  */	
307 308
 	public function testEnableCryptoExceptionDisableTwice() {
308 309
 		// testing on tls server
309 310
 		$this->_connectSocketToSslTls();
310  
-		$this->setExpectedException('SocketException');
311 311
 		$this->Socket->enableCrypto('tls', 'client', false);
312 312
 	}	
313 313
 
4  lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php
@@ -131,6 +131,7 @@ public function testConnectEhloTls() {
131 131
 /**
132 132
  * testConnectEhloTlsOnNonTlsServer method
133 133
  *
  134
+ * @expectedException SocketException
134 135
  * @return void
135 136
  */
136 137
 	public function testConnectEhloTlsOnNonTlsServer() {
@@ -144,13 +145,13 @@ public function testConnectEhloTlsOnNonTlsServer() {
144 145
 		$this->socket->expects($this->at(5))->method('write')->with("STARTTLS\r\n");
145 146
 		$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
146 147
 		$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
147  
-		$this->setExpectedException('SocketException');
148 148
 		$this->SmtpTransport->connect();
149 149
 	}
150 150
 	
151 151
 /**
152 152
  * testConnectEhloNoTlsOnRequiredTlsServer method
153 153
  *
  154
+ * @expectedException SocketException
154 155
  * @return void
155 156
  */
156 157
 	public function testConnectEhloNoTlsOnRequiredTlsServer() {
@@ -164,7 +165,6 @@ public function testConnectEhloNoTlsOnRequiredTlsServer() {
164 165
 		$this->socket->expects($this->at(5))->method('read')->with("AUTH LOGIN\r\n");
165 166
 		$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
166 167
 		$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("504 5.7.4 Unrecognized authentication type\r\n"));
167  
-		$this->setExpectedException('SocketException');
168 168
 		$this->SmtpTransport->connect();
169 169
 		$this->SmtpTransport->auth();
170 170
 	}

0 notes on commit f9f380d

Please sign in to comment.
Something went wrong with that request. Please try again.