public function testClose() { $stream = new Curl($this->_testConfig); $result = $stream->open(); $this->assertTrue($result); $result = $stream->close(); $this->assertTrue($result); $result = $stream->resource(); $this->assertFalse(is_resource($result)); }
public function testSendDeleteThenGet() { $postConfig = array('method' => 'DELETE', 'body' => ''); $stream = new Curl($this->_testConfig); $this->assertInternalType('resource', $stream->open()); $this->assertTrue($stream->write(new Request($postConfig + $this->_testConfig))); $this->assertTrue(isset($stream->options[CURLOPT_CUSTOMREQUEST])); $this->assertEqual($stream->options[CURLOPT_CUSTOMREQUEST], 'DELETE'); $this->assertTrue(isset($stream->options[CURLOPT_POSTFIELDS])); $this->assertEqual($stream->options[CURLOPT_POSTFIELDS], $postConfig['body']); $this->assertTrue($stream->close()); $this->assertInternalType('resource', $stream->open()); $this->assertTrue($stream->write(new Request($this->_testConfig))); $this->assertFalse(isset($stream->options[CURLOPT_CUSTOMREQUEST])); $this->assertTrue($stream->close()); }
public function close() { $this->closed = parent::close(); return true; }
public function testSendPostThenGet() { $postConfig = array('method' => 'POST', 'body' => '{"body"}'); $stream = new Curl($this->_testConfig); $this->assertTrue(is_resource($stream->open())); $this->assertTrue($stream->write(new Request($postConfig + $this->_testConfig))); $this->assertTrue(isset($stream->options[CURLOPT_POST])); $this->assertTrue($stream->close()); $this->assertTrue(is_resource($stream->open())); $this->assertTrue($stream->write(new Request($this->_testConfig))); $this->assertFalse(isset($stream->options[CURLOPT_POST])); $this->assertTrue($stream->close()); }
public function testSendPutThenGet() { $postConfig = array('method' => 'PUT', 'body' => '{"body"}'); $stream = new Curl($this->_testConfig); $this->assertTrue(is_resource($stream->open())); $this->assertTrue($stream->write(new Request($postConfig + $this->_testConfig))); $this->assertTrue(isset($stream->options[CURLOPT_CUSTOMREQUEST])); $this->assertEqual($stream->options[CURLOPT_CUSTOMREQUEST], 'PUT'); $this->assertTrue(isset($stream->options[CURLOPT_POSTFIELDS])); $this->assertEqual($stream->options[CURLOPT_POSTFIELDS], $postConfig['body']); $this->assertTrue($stream->close()); $this->assertTrue(is_resource($stream->open())); $this->assertTrue($stream->write(new Request($this->_testConfig))); $this->assertFalse(isset($stream->options[CURLOPT_CUSTOMREQUEST])); $this->assertTrue($stream->close()); }