mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Removing dependancy on Object from CakeSocket. Making tests less dependant on having a network connection.
This commit is contained in:
parent
e8b6d45850
commit
9ddbd6f686
2 changed files with 3 additions and 5 deletions
|
@ -27,7 +27,7 @@ App::import('Core', 'Validation');
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.libs
|
* @subpackage cake.cake.libs
|
||||||
*/
|
*/
|
||||||
class CakeSocket extends Object {
|
class CakeSocket {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object description
|
* Object description
|
||||||
|
@ -90,8 +90,6 @@ class CakeSocket extends Object {
|
||||||
* @see CakeSocket::$_baseConfig
|
* @see CakeSocket::$_baseConfig
|
||||||
*/
|
*/
|
||||||
function __construct($config = array()) {
|
function __construct($config = array()) {
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
$this->config = array_merge($this->_baseConfig, $config);
|
$this->config = array_merge($this->_baseConfig, $config);
|
||||||
if (!is_numeric($this->config['protocol'])) {
|
if (!is_numeric($this->config['protocol'])) {
|
||||||
$this->config['protocol'] = getprotobyname($this->config['protocol']);
|
$this->config['protocol'] = getprotobyname($this->config['protocol']);
|
||||||
|
|
|
@ -145,13 +145,13 @@ class CakeSocketTest extends CakeTestCase {
|
||||||
$this->Socket->connect();
|
$this->Socket->connect();
|
||||||
$this->assertEqual($this->Socket->read(26), null);
|
$this->assertEqual($this->Socket->read(26), null);
|
||||||
|
|
||||||
$config = array('host' => 'www.cakephp.org', 'timeout' => 1);
|
$config = array('host' => '127.0.0.1', 'timeout' => 1);
|
||||||
$this->Socket = new CakeSocket($config);
|
$this->Socket = new CakeSocket($config);
|
||||||
$this->assertTrue($this->Socket->connect());
|
$this->assertTrue($this->Socket->connect());
|
||||||
$this->assertFalse($this->Socket->read(1024 * 1024));
|
$this->assertFalse($this->Socket->read(1024 * 1024));
|
||||||
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out'));
|
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out'));
|
||||||
|
|
||||||
$config = array('host' => 'www.cakephp.org', 'timeout' => 30);
|
$config = array('host' => 'localhost', 'timeout' => 30);
|
||||||
$this->Socket = new CakeSocket($config);
|
$this->Socket = new CakeSocket($config);
|
||||||
$this->assertTrue($this->Socket->connect());
|
$this->assertTrue($this->Socket->connect());
|
||||||
$this->assertEqual($this->Socket->read(26), null);
|
$this->assertEqual($this->Socket->read(26), null);
|
||||||
|
|
Loading…
Add table
Reference in a new issue