Skip to content

Commit

Permalink
Fix test for > PHP 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
lstrojny committed Dec 13, 2015
1 parent 0678fdb commit 203ae0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/Util/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@ public function __construct($streamContext = null)
if (is_resource($streamContext) && get_resource_type($streamContext) === 'stream-context') {
$this->streamContext = $streamContext;
} else {
// Since PHP 5.6, CN_match is deprecated
$is56 = version_compare(PHP_VERSION, '5.6') === 1;
$peerNameKey = $is56 ? 'peer_name' : 'CN_match';
$peerName = $is56 ? 'raw.githubusercontent.com' : 'www.github.com';
$this->streamContext = stream_context_create(
array(
'ssl' => array(
'verify_peer' => true,
'verify_depth' => 10,
'cafile' => __DIR__ . '/../../resources/ca-bundle.crt',
$peerNameKey => $peerName,
'disable_compression' => true,
'verify_peer' => true,
'verify_depth' => 10,
'cafile' => __DIR__ . '/../../resources/ca-bundle.crt',
static::getPeerNameKey() => 'www.github.com',
'disable_compression' => true,
)
)
);
Expand All @@ -53,4 +49,9 @@ public function fetch()

return $result;
}

public static function getPeerNameKey()
{
return version_compare(PHP_VERSION, '5.6') === 1 ? 'peer_name' : 'CN_match';
}
}
4 changes: 2 additions & 2 deletions tests/Util/FetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function testFetchError()
stream_context_create(
array(
'ssl' => array(
'verify_peer' => true,
'CN_match' => 'invalid.com',
'verify_peer' => true,
Fetcher::getPeerNameKey() => 'invalid.com',
)
)
)
Expand Down

0 comments on commit 203ae0e

Please sign in to comment.