Update Tests to supports namespaces
This commit is contained in:
79
Tests/TcpclientTest.php
Normal file
79
Tests/TcpclientTest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
/** Test the TCP client */
|
||||
class tcpclientTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_GoogleIPv4 ()
|
||||
{
|
||||
$tcpclient = new \tcpclient ("www.google.fr", 80);
|
||||
$tcpclient->preferIPv4 (true);
|
||||
$tcpclient->connect ();
|
||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||
"Host: www.google.fr\r\n".
|
||||
"User-Agent: DomFramework\r\n".
|
||||
"Accept: *"."/*\r\n".
|
||||
"\r\n");
|
||||
$res = "";
|
||||
while (($read = $tcpclient->read ()) !== "")
|
||||
$res .= $read."\r\n";
|
||||
$tcpclient->disconnect ();
|
||||
$this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
|
||||
}
|
||||
|
||||
public function test_GoogleIPv4orIpv6 ()
|
||||
{
|
||||
$tcpclient = new \tcpclient ("www.google.fr", 80);
|
||||
$tcpclient->connect ();
|
||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||
"Host: www.google.fr\r\n".
|
||||
"User-Agent: DomFramework\r\n".
|
||||
"Accept: *"."/*\r\n".
|
||||
"\r\n");
|
||||
$res = "";
|
||||
while (($read = $tcpclient->read ()) !== "")
|
||||
$res .= $read."\r\n";
|
||||
$tcpclient->disconnect ();
|
||||
$this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
|
||||
}
|
||||
|
||||
public function test_GoogleSSL ()
|
||||
{
|
||||
$tcpclient = new \tcpclient ("www.google.fr", 443);
|
||||
$tcpclient->connect ();
|
||||
$tcpclient->cryptoEnable (true);
|
||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||
"Host: www.google.fr\r\n".
|
||||
"User-Agent: DomFramework\r\n".
|
||||
"Accept: *"."/*\r\n".
|
||||
"\r\n");
|
||||
$res = "";
|
||||
while (($read = $tcpclient->read ()) !== "")
|
||||
$res .= $read."\r\n";
|
||||
$tcpclient->disconnect ();
|
||||
$this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
|
||||
}
|
||||
|
||||
public function test_GoogleSSLIPv6 ()
|
||||
{
|
||||
$tcpclient = new \tcpclient ("ipv6.google.com", 443);
|
||||
$tcpclient->connect ();
|
||||
$tcpclient->cryptoEnable (true);
|
||||
$tcpclient->send ("GET / HTTP/1.1\r\n".
|
||||
"Host: www.google.fr\r\n".
|
||||
"User-Agent: DomFramework\r\n".
|
||||
"Accept: *"."/*\r\n".
|
||||
"\r\n");
|
||||
$res = "";
|
||||
while (($read = $tcpclient->read ()) !== "")
|
||||
$res .= $read."\r\n";
|
||||
$tcpclient->disconnect ();
|
||||
$this->assertSame (substr ($res, 0, 15), "HTTP/1.1 200 OK");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user