Skip to content

Commit

Permalink
Merge pull request #16 from peter279k/test_enhancement
Browse files Browse the repository at this point in the history
Test enhancement
  • Loading branch information
scheb committed Aug 27, 2018
2 parents 75e03f6 + 9d19035 commit 80f56ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
"guzzlehttp/guzzle": "^6.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^5.7 || ^6.5",
"satooshi/php-coveralls": "^1.0"
},
"autoload": {
Expand Down
23 changes: 22 additions & 1 deletion tests/ApiClientIntegrationTest.php
Expand Up @@ -6,8 +6,9 @@
use Scheb\YahooFinanceApi\Results\HistoricalData;
use Scheb\YahooFinanceApi\Results\Quote;
use Scheb\YahooFinanceApi\Results\SearchResult;
use PHPUnit\Framework\TestCase;

class ApiClientIntegrationTest extends \PHPUnit_Framework_TestCase
class ApiClientIntegrationTest extends TestCase
{
const APPLE_NAME = 'Apple';
const APPLE_SYMBOL = 'AAPL';
Expand Down Expand Up @@ -92,6 +93,26 @@ public function getHistoricalData_valuesForInterval_returnHistoricalData($interv
$this->assertInternalType('int', $historicalData->getVolume());
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Interval must be one of: 1d, 1wk, 1mo
*/
public function getHistoricalData_valuesForInvalidInterval_throwInvalidArgumentException()
{
$this->client->getHistoricalData(self::APPLE_SYMBOL, 'invalid_interval', new \DateTime('-7 days'), new \DateTime('today'));
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Start date must be before end date
*/
public function getHistoricalData_startDateIsGreaterThanEndDate_throwInvalidArgumentException()
{
$this->client->getHistoricalData(self::APPLE_SYMBOL, ApiClient::INTERVAL_1_DAY, new \DateTime('7 days'), new \DateTime('today'));
}

public function getTestDataForHistoricalData()
{
return [
Expand Down
3 changes: 2 additions & 1 deletion tests/ResultDecoderTest.php
Expand Up @@ -5,8 +5,9 @@
use Scheb\YahooFinanceApi\Results\HistoricalData;
use Scheb\YahooFinanceApi\Results\Quote;
use Scheb\YahooFinanceApi\Results\SearchResult;
use PHPUnit\Framework\TestCase;

class ResultDecoderTest extends \PHPUnit_Framework_TestCase
class ResultDecoderTest extends TestCase
{
/**
* @var ResultDecoder
Expand Down

0 comments on commit 80f56ab

Please sign in to comment.