Exemplo n.º 1
0
 public function testWriteAndRead()
 {
     $stream = new Curl($this->_testConfig);
     $this->assertTrue(is_resource($stream->open()));
     $this->assertTrue(is_resource($stream->resource()));
     $stream->set(CURLOPT_URL, $this->_testUrl);
     $this->assertTrue($stream->write(null));
     $this->assertTrue($stream->read());
     $response = $stream->send(new Request(), array('response' => 'lithium\\net\\http\\Response'));
     $this->assertEqual(trim(file_get_contents($this->_testUrl)), trim($response->body()));
     $this->assertNull($stream->eof());
 }
Exemplo n.º 2
0
 public function testCurlAdapter()
 {
     $socket = new Curl($this->_testConfig);
     $this->assertTrue($socket->open());
     $response = $socket->send();
     $this->assertTrue($response instanceof \lithium\net\http\Response);
     $expected = 'www.google.com';
     $result = $response->host;
     $this->assertEqual($expected, $result);
     $result = $response->body();
     $this->assertPattern("/<title[^>]*>Google<\\/title>/im", (string) $result);
 }
Exemplo n.º 3
0
 public function testCurlAdapter()
 {
     $message = 'Your PHP installation was not compiled with curl support.';
     $this->skipIf(!function_exists('curl_init'), $message);
     $socket = new Curl($this->_testConfig);
     $this->assertTrue($socket->open());
     $response = $socket->send();
     $this->assertTrue($response instanceof Response);
     $expected = 'google.com';
     $result = $response->host;
     $this->assertEqual($expected, $result);
     $result = $response->body();
     $this->assertPattern("/<title[^>]*>.*<\\/title>/im", (string) $result);
 }
Exemplo n.º 4
0
 public function testSendWithObject()
 {
     $stream = new Curl($this->_testConfig);
     $this->assertTrue(is_resource($stream->open()));
     $result = $stream->send(new Request($this->_testConfig), array('response' => 'lithium\\net\\http\\Response'));
     $this->assertTrue($result instanceof \lithium\net\http\Response);
     $this->assertPattern("/^HTTP/", (string) $result);
 }
Exemplo n.º 5
0
 public function testCurlAdapter()
 {
     $socket = new Curl($this->_testConfig);
     $this->assertNotEmpty($socket->open());
     $response = $socket->send();
     $this->assertInstanceOf('lithium\\net\\http\\Response', $response);
     $expected = 'example.org';
     $result = $response->host;
     $this->assertEqual($expected, $result);
     $result = $response->body();
     $this->assertPattern("/<title[^>]*>Example Domain<\\/title>/im", (string) $result);
 }