Skip to content

Commit

Permalink
Added HttpConnector unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Jul 19, 2016
1 parent 629f1c1 commit af34f7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Porter/Net/Http/HttpConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(HttpOptions $options = null)
public function fetchFreshData($source, EncapsulatedOptions $options = null)
{
if ($options && !$options instanceof HttpOptions) {
throw new \RuntimeException('Options must be an instance of HttpOptions.');
throw new \InvalidArgumentException('Options must be an instance of HttpOptions.');
}

return \ScriptFUSION\Retry\retry(5, function () use ($source, $options) {
Expand Down
4 changes: 2 additions & 2 deletions src/Porter/Net/Soap/SoapConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public function __construct($wsdl = null, SoapOptions $options = null)
{
parent::__construct();

$this->client = new \SoapClient($wsdl, $options->extractSoapClientOptions());
$this->client = new \SoapClient($wsdl, $options ? $options->extractSoapClientOptions() : null);
$this->options = $options;
}

public function fetchFreshData($source, EncapsulatedOptions $options = null)
{
if ($options && !$options instanceof SoapOptions) {
throw new \RuntimeException('Options must be an instance of SoapOptions.');
throw new \InvalidArgumentException('Options must be an instance of SoapOptions.');
}

$params = array_merge($this->options->getParameters(), $options ? $options->getParameters() : []);
Expand Down
18 changes: 18 additions & 0 deletions test/Unit/Porter/Net/Http/HttpConnectorTestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace ScriptFUSIONTest\Unit\Porter\Net\Http;

use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use ScriptFUSION\Porter\Net\Http\HttpConnector;
use ScriptFUSION\Porter\Options\EncapsulatedOptions;

final class HttpConnectorTestTest extends \PHPUnit_Framework_TestCase
{
use MockeryPHPUnitIntegration;

public function testInvalidOptionsType()
{
$this->setExpectedException(\InvalidArgumentException::class);

(new HttpConnector)->fetch('foo', \Mockery::mock(EncapsulatedOptions::class));
}
}

0 comments on commit af34f7c

Please sign in to comment.