diff --git a/tests/unit/Curl/TestCurlClient.php b/tests/unit/Curl/TestCurlClient.php new file mode 100644 index 0000000000000000000000000000000000000000..c95b89617e1ffe0833eb4f4aa52fb492a6815720 --- /dev/null +++ b/tests/unit/Curl/TestCurlClient.php @@ -0,0 +1,50 @@ +<?php + +class TestCurlClient extends \PHPUnit\Framework\TestCase +{ + + /** + * Test get method. + */ + public function testGet() + { + $client = new \WPDesk\HttpClient\Curl\CurlClient(); + $response = $client->get('https://www.google.com', '', array(), 15); + $this->assertInstanceOf(\WPDesk\HttpClient\HttpClientResponse::class, $response); + $this->assertEquals(200, $response->getResponseCode()); + } + + /** + * Test post method. + */ + public function testPost() + { + $client = new \WPDesk\HttpClient\Curl\CurlClient(); + $response = $client->post('https://www.google.com', '', array(), 15); + $this->assertInstanceOf(\WPDesk\HttpClient\HttpClientResponse::class, $response); + $this->assertEquals(405, $response->getResponseCode()); + } + + /** + * Test put method. + */ + public function testPut() + { + $client = new \WPDesk\HttpClient\Curl\CurlClient(); + $response = $client->put('https://www.google.com', '', array(), 15); + $this->assertInstanceOf(\WPDesk\HttpClient\HttpClientResponse::class, $response); + $this->assertEquals(405, $response->getResponseCode()); + } + + /** + * Test delete method. + */ + public function testDelete() + { + $client = new \WPDesk\HttpClient\Curl\CurlClient(); + $response = $client->put('https://www.google.com', '', array(), 15); + $this->assertInstanceOf(\WPDesk\HttpClient\HttpClientResponse::class, $response); + $this->assertEquals(405, $response->getResponseCode()); + } + +} \ No newline at end of file diff --git a/tests/unit/TestHttpClientFactory.php b/tests/unit/TestHttpClientFactory.php index 1b835f8f423ca926d7f226d5fd355ea70214ba80..68efad4fa638be30529299f8d385f885dd06fb98 100644 --- a/tests/unit/TestHttpClientFactory.php +++ b/tests/unit/TestHttpClientFactory.php @@ -3,4 +3,19 @@ class TestHttpClientFactory extends \PHPUnit\Framework\TestCase { + /** + * Test createClient method. + */ + public function testCreateClient() + { + $options = Mockery::mock(\WPDesk\HttpClient\HttpClientOptions::class); + $options->shouldReceive('getHttpClientClass') + ->withAnyArgs() + ->andReturn(\WPDesk\HttpClient\Curl\CurlClient::class); + $factory = new \WPDesk\HttpClient\HttpClientFactory(); + $client = $factory->createClient($options); + $this->assertInstanceOf(\WPDesk\HttpClient\Curl\CurlClient::class, $client); + } + + } \ No newline at end of file