summaryrefslogtreecommitdiffstats
path: root/test/PCurlTest.php
diff options
context:
space:
mode:
authorpurplecode <niespammnie@gmail.com>2013-12-06 18:05:25 +0100
committerpurplecode <niespammnie@gmail.com>2013-12-06 18:05:25 +0100
commit8b2f3b2789c55fd9ad631924636f84633f2dd1a9 (patch)
tree7f9d2e4c8bf50be7bb536aab29df41b4928c484f /test/PCurlTest.php
parentc4f9330d8609a9474cfe5f48b0a5d1655b812044 (diff)
downloadphp.curl-8b2f3b2789c55fd9ad631924636f84633f2dd1a9.zip
php.curl-8b2f3b2789c55fd9ad631924636f84633f2dd1a9.tar.gz
php.curl-8b2f3b2789c55fd9ad631924636f84633f2dd1a9.tar.bz2
ssl verification tests
Diffstat (limited to 'test/PCurlTest.php')
-rw-r--r--test/PCurlTest.php31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/PCurlTest.php b/test/PCurlTest.php
index 08d191a..b0531a0 100644
--- a/test/PCurlTest.php
+++ b/test/PCurlTest.php
@@ -6,15 +6,42 @@ use PurpleCode\PCurl;
class PCurlTest extends PHPUnit_Framework_TestCase {
- public function testShouldGetGooglePage() {
+ private function getCACertBundlePath() {
+ return __DIR__.'\ca-cert.crt';
+ }
+
+ public function testShouldGetGooglePageViaHttp() {
// given
- $cut = new PCurl('https://www.google.com');
+ $cut = new PCurl('http://www.google.pl');
+
+ // when
+ $response = $cut->get('/');
+
+ // then
+ $this->assertSelectRegExp('title', '/Google/', 1, $response);
+ }
+
+ public function testShouldGetGooglePageAndCheckHttpsCertificate() {
+ // given
+ $cut = new PCurl('https://www.google.pl');
+ $cut->useSSLCertificate($this->getCACertBundlePath());
// when
$response = $cut->get('/');
// then
$this->assertSelectRegExp('title', '/Google/', 1, $response);
+ }
+
+ public function testShouldGetGooglePageAndThrowExceptionOnMissingCertificate() {
+ // given
+ $cut = new PCurl('https://www.google.com');
+
+ // then
+ $this->setExpectedException('PurpleCode\PCurlException');
+
+ // when
+ $response = $cut->get('/');
}
} \ No newline at end of file