Skip to content

Commit

Permalink
Minor adjust for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
minchao committed Sep 5, 2018
1 parent 7f8b190 commit fef39ba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
38 changes: 19 additions & 19 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,6 @@ public function setBaseURL(UriInterface $baseURL)
return $this;
}

/**
* @param bool $enable
* @return $this
*/
public function useSecureBaseURL($enable = true)
{
if ($enable) {
$this->baseURL = new Uri(self::DEFAULT_BASE_URL);
$this->longMessageBaseURL = new Uri(self::DEFAULT_LONG_MESSAGE_BASE_URL);

return $this;
}

$this->baseURL = new Uri(self::DEFAULT_HTTP_BASE_URL);
$this->longMessageBaseURL = new Uri(self::DEFAULT_LONG_MESSAGE_HTTP_BASE_URL);

return $this;
}

/**
* @return UriInterface
*/
Expand All @@ -195,6 +176,25 @@ public function setLongMessageBaseURL(UriInterface $longMessageBaseURL)
return $this;
}

/**
* @param bool $enable
* @return $this
*/
public function useSecureBaseURL($enable = true)
{
if ($enable) {
$this->baseURL = new Uri(self::DEFAULT_BASE_URL);
$this->longMessageBaseURL = new Uri(self::DEFAULT_LONG_MESSAGE_BASE_URL);

return $this;
}

$this->baseURL = new Uri(self::DEFAULT_HTTP_BASE_URL);
$this->longMessageBaseURL = new Uri(self::DEFAULT_LONG_MESSAGE_HTTP_BASE_URL);

return $this;
}

/**
* Send an API request
*
Expand Down
16 changes: 7 additions & 9 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,17 @@ public function testBuildUriWithQuery($uri, $queryParams, $expected)
$this->assertEquals($expected, $actual);
}

public function testUseSecureBaseURL()
{
$client = $this->createClient();
$client->useSecureBaseURL();

$this->assertEquals(Client::DEFAULT_BASE_URL, $client->getBaseURL());
}

public function testNoUseSecureBaseURL()
public function testShouldBeOkWhenUseSecureBaseURL()
{
$client = $this->createClient();
$client->useSecureBaseURL(false);

$this->assertEquals(Client::DEFAULT_HTTP_BASE_URL, $client->getBaseURL());
$this->assertEquals(Client::DEFAULT_LONG_MESSAGE_HTTP_BASE_URL, $client->getLongMessageBaseURL());

$client->useSecureBaseURL();

$this->assertEquals(Client::DEFAULT_BASE_URL, $client->getBaseURL());
$this->assertEquals(Client::DEFAULT_LONG_MESSAGE_BASE_URL, $client->getLongMessageBaseURL());
}
}

0 comments on commit fef39ba

Please sign in to comment.