Skip to content

Commit

Permalink
Attempt to get more tests passing on travis ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 20, 2013
1 parent 27dc666 commit 9f25da4
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions lib/Cake/Test/Case/Network/CakeSocketTest.php
Expand Up @@ -158,8 +158,12 @@ public function testSocketHost() {
* @return void
*/
public function testSocketWriting() {
$request = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
$this->assertTrue((bool)$this->Socket->write($request));
try {
$request = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n";
$this->assertTrue((bool)$this->Socket->write($request));
} catch (SocketException $e) {
$this->markTestSkipped('Cannot test network, skipping.');
}
}

/**
Expand All @@ -169,14 +173,18 @@ public function testSocketWriting() {
*/
public function testSocketReading() {
$this->Socket = new CakeSocket(array('timeout' => 5));
$this->Socket->connect();
$this->assertEquals(null, $this->Socket->read(26));
try {
$this->Socket->connect();
$this->assertEquals(null, $this->Socket->read(26));

$config = array('host' => 'google.com', 'port' => 80, 'timeout' => 1);
$this->Socket = new CakeSocket($config);
$this->assertTrue($this->Socket->connect());
$this->assertEquals(null, $this->Socket->read(26));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
$config = array('host' => 'google.com', 'port' => 80, 'timeout' => 1);
$this->Socket = new CakeSocket($config);
$this->assertTrue($this->Socket->connect());
$this->assertEquals(null, $this->Socket->read(26));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
} catch (SocketException $e) {
$this->markTestSkipped('Cannot test network, skipping.');
}
}

/**
Expand All @@ -187,12 +195,16 @@ public function testSocketReading() {
public function testTimeOutConnection() {
$config = array('host' => '127.0.0.1', 'timeout' => 0.5);
$this->Socket = new CakeSocket($config);
$this->assertTrue($this->Socket->connect());
try {
$this->assertTrue($this->Socket->connect());

$config = array('host' => '127.0.0.1', 'timeout' => 0.00001);
$this->Socket = new CakeSocket($config);
$this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
$config = array('host' => '127.0.0.1', 'timeout' => 0.00001);
$this->Socket = new CakeSocket($config);
$this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
} catch (SocketException $e) {
$this->markTestSkipped('Cannot test network, skipping.');
}
}

/**
Expand Down

0 comments on commit 9f25da4

Please sign in to comment.