Skip to content

Commit

Permalink
Fix whitespace and comment errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 10, 2012
1 parent 4487673 commit 6f75578
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 36 deletions.
32 changes: 18 additions & 14 deletions lib/Cake/Network/CakeSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class CakeSocket {
* @var array
*/
protected $_baseConfig = array(
'persistent' => false,
'host' => 'localhost',
'protocol' => 'tcp',
'port' => 80,
'timeout' => 30
'persistent' => false,
'host' => 'localhost',
'protocol' => 'tcp',
'port' => 80,
'timeout' => 30
);

/**
Expand Down Expand Up @@ -78,13 +78,15 @@ class CakeSocket {

/**
* True if the socket stream is encrypted after a CakeSocket::enableCrypto() call
* @var type
*/
*
* @var boolean
*/
public $encrypted = false;

/**
* Contains all the encryption methods available
* @var array
*
* @var array
*/
protected $_encryptMethods = array(
'sslv2_client' => STREAM_CRYPTO_METHOD_SSLv2_CLIENT,
Expand Down Expand Up @@ -300,13 +302,14 @@ public function reset($state = null) {

/**
* Encrypts current stream socket, using one of the defined encryption methods
*
*
* @param string $type can be one of 'ssl2', 'ssl3', 'ssl23' or 'tls'
* @param string $clientOrServer can be one of 'client', 'server'. Default is 'client'
* @param boolean $enable enable or disable encryption. Default is true (enable)
* @return boolean True on success
* @throws SocketException
* @see stream_socket_enable_crypto
* @throws InvalidArgumentException When an invalid encryption scheme is chosen.
* @throws SocketException When attempting to enable SSL/TLS fails
* @see stream_socket_enable_crypto
*/
public function enableCrypto($type, $clientOrServer = 'client', $enable = true) {
if (!array_key_exists($type . '_' . $clientOrServer, $this->_encryptMethods)) {
Expand All @@ -327,5 +330,6 @@ public function enableCrypto($type, $clientOrServer = 'client', $enable = true)
$this->setLastError(null, $errorMessage);
throw new SocketException($errorMessage);
}
}
}
}

}
41 changes: 21 additions & 20 deletions lib/Cake/Test/Case/Network/CakeSocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ public function testReset() {

/**
* testEncrypt
*
*
* @expectedException SocketException
* @return void
*/
*/
public function testEnableCryptoSocketExceptionNoSsl() {
$configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1);

Expand All @@ -232,10 +232,10 @@ public function testEnableCryptoSocketExceptionNoSsl() {

/**
* testEnableCryptoSocketExceptionNoTls
*
*
* @expectedException SocketException
* @return void
*/
*/
public function testEnableCryptoSocketExceptionNoTls() {
$configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1);

Expand All @@ -247,9 +247,9 @@ public function testEnableCryptoSocketExceptionNoTls() {

/**
* _connectSocketToSslTls
*
*
* @return void
*/
*/
protected function _connectSocketToSslTls() {
$configSslTls = array('host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 5);
$this->Socket = new CakeSocket($configSslTls);
Expand All @@ -258,22 +258,22 @@ protected function _connectSocketToSslTls() {

/**
* testEnableCryptoBadMode
*
*
* @expectedException InvalidArgumentException
* @return void
*/
*/
public function testEnableCryptoBadMode() {
// testing wrong encryption mode
$this->_connectSocketToSslTls();
$this->Socket->enableCrypto('doesntExistMode', 'server');
$this->Socket->disconnect();
}

/**
* testEnableCrypto
*
*
* @return void
*/
*/
public function testEnableCrypto() {
// testing on ssl server
$this->_connectSocketToSslTls();
Expand All @@ -285,13 +285,13 @@ public function testEnableCrypto() {
$this->assertTrue($this->Socket->enableCrypto('tls', 'client'));
$this->Socket->disconnect();
}

/**
* testEnableCryptoExceptionEnableTwice
*
*
* @expectedException SocketException
* @return void
*/
*/
public function testEnableCryptoExceptionEnableTwice() {
// testing on tls server
$this->_connectSocketToSslTls();
Expand All @@ -301,26 +301,27 @@ public function testEnableCryptoExceptionEnableTwice() {

/**
* testEnableCryptoExceptionDisableTwice
*
*
* @expectedException SocketException
* @return void
*/
*/
public function testEnableCryptoExceptionDisableTwice() {
// testing on tls server
$this->_connectSocketToSslTls();
$this->Socket->enableCrypto('tls', 'client', false);
}
}

/**
* testEnableCryptoEnableStatus
*
*
* @return void
*/
*/
public function testEnableCryptoEnableStatus() {
// testing on tls server
$this->_connectSocketToSslTls();
$this->assertFalse($this->Socket->encrypted);
$this->Socket->enableCrypto('tls', 'client', true);
$this->assertTrue($this->Socket->encrypted);
}
}

}
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function testConnectEhloTlsOnNonTlsServer() {
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
$this->SmtpTransport->connect();
}

/**
* testConnectEhloNoTlsOnRequiredTlsServer method
*
Expand All @@ -168,7 +168,7 @@ public function testConnectEhloNoTlsOnRequiredTlsServer() {
$this->SmtpTransport->connect();
$this->SmtpTransport->auth();
}

/**
* testConnectHelo method
*
Expand Down

0 comments on commit 6f75578

Please sign in to comment.