Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit a0ac892

Browse files
committed
Merge pull request #3 from jwage/fix/connect-exception
Allow ErrorException to be thrown when stream_socket_client() fails to c...
2 parents f948adb + ba03d83 commit a0ac892

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/JWage/APNS/SocketClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function createStreamClient()
106106
{
107107
$address = $this->getSocketAddress();
108108

109-
$client = stream_socket_client(
109+
$client = @stream_socket_client(
110110
$address,
111111
$this->error,
112112
$this->errorString,

tests/JWage/APNS/Tests/SocketClientTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ public function testGetSocketAddress()
7474
{
7575
$this->assertEquals('ssl://host:1234', $this->socketClient->getTestSocketAddress());
7676
}
77+
78+
/**
79+
* @expectedException ErrorException
80+
* @expectedExceptionMessage Failed to create stream socket client to "ssl://somethingthatdoesnotexist:100". php_network_getaddresses: getaddrinfo failed: Name or service not known
81+
*/
82+
public function testConnectThrowsException()
83+
{
84+
$socketClient = new SocketClient($this->certificate, 'somethingthatdoesnotexist', 100);
85+
$socketClient->write('test');
86+
}
7787
}
7888

7989
class SocketClientStub extends SocketClient

0 commit comments

Comments
 (0)