Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

using annotations for catching exceptions in tests

  • Loading branch information...
commit f9f380d4013bf50eddeb501de026e38d1a3db1dd 1 parent d7f93f5
@steinkel steinkel authored
View
10 lib/Cake/Test/Case/Network/CakeSocketTest.php
@@ -218,6 +218,7 @@ public function testReset() {
/**
* testEncrypt
*
+ * @expectedException SocketException
* @return void
*/
public function testEnableCryptoSocketExceptionNoSsl() {
@@ -226,13 +227,13 @@ public function testEnableCryptoSocketExceptionNoSsl() {
// testing exception on no ssl socket server for ssl and tls methods
$this->Socket = new CakeSocket($configNoSslOrTls);
$this->Socket->connect();
- $this->setExpectedException('SocketException');
$this->Socket->enableCrypto('sslv3', 'client');
}
/**
* testEnableCryptoSocketExceptionNoTls
*
+ * @expectedException SocketException
* @return void
*/
public function testEnableCryptoSocketExceptionNoTls() {
@@ -241,7 +242,6 @@ public function testEnableCryptoSocketExceptionNoTls() {
// testing exception on no ssl socket server for ssl and tls methods
$this->Socket = new CakeSocket($configNoSslOrTls);
$this->Socket->connect();
- $this->setExpectedException('SocketException');
$this->Socket->enableCrypto('tls', 'client');
}
@@ -259,12 +259,12 @@ protected function _connectSocketToSslTls() {
/**
* testEnableCryptoBadMode
*
+ * @expectedException InvalidArgumentException
* @return void
*/
public function testEnableCryptoBadMode() {
// testing wrong encryption mode
$this->_connectSocketToSslTls();
- $this->setExpectedException('InvalidArgumentException');
$this->Socket->enableCrypto('doesntExistMode', 'server');
$this->Socket->disconnect();
}
@@ -289,25 +289,25 @@ public function testEnableCrypto() {
/**
* testEnableCryptoExceptionEnableTwice
*
+ * @expectedException SocketException
* @return void
*/
public function testEnableCryptoExceptionEnableTwice() {
// testing on tls server
$this->_connectSocketToSslTls();
$this->Socket->enableCrypto('tls', 'client');
- $this->setExpectedException('SocketException');
$this->Socket->enableCrypto('tls', 'client');
}
/**
* testEnableCryptoExceptionDisableTwice
*
+ * @expectedException SocketException
* @return void
*/
public function testEnableCryptoExceptionDisableTwice() {
// testing on tls server
$this->_connectSocketToSslTls();
- $this->setExpectedException('SocketException');
$this->Socket->enableCrypto('tls', 'client', false);
}
View
4 lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php
@@ -131,6 +131,7 @@ public function testConnectEhloTls() {
/**
* testConnectEhloTlsOnNonTlsServer method
*
+ * @expectedException SocketException
* @return void
*/
public function testConnectEhloTlsOnNonTlsServer() {
@@ -144,13 +145,13 @@ public function testConnectEhloTlsOnNonTlsServer() {
$this->socket->expects($this->at(5))->method('write')->with("STARTTLS\r\n");
$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
- $this->setExpectedException('SocketException');
$this->SmtpTransport->connect();
}
/**
* testConnectEhloNoTlsOnRequiredTlsServer method
*
+ * @expectedException SocketException
* @return void
*/
public function testConnectEhloNoTlsOnRequiredTlsServer() {
@@ -164,7 +165,6 @@ public function testConnectEhloNoTlsOnRequiredTlsServer() {
$this->socket->expects($this->at(5))->method('read')->with("AUTH LOGIN\r\n");
$this->socket->expects($this->at(6))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("504 5.7.4 Unrecognized authentication type\r\n"));
- $this->setExpectedException('SocketException');
$this->SmtpTransport->connect();
$this->SmtpTransport->auth();
}
Please sign in to comment.
Something went wrong with that request. Please try again.