Skip to content

Commit

Permalink
Merge pull request #8 from gemal/master
Browse files Browse the repository at this point in the history
Bug fixes and updates
  • Loading branch information
mikebarlow authored Sep 3, 2019
2 parents cf61382 + f1c5969 commit a72f778
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 65 deletions.
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
language: php

php:
- 5.5
- 5.6
- 7.0

matrix:
allow_failures:
- php: 7.0
- 7.1
- 7.2

before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev
- travis_retry composer install --no-interaction --prefer-source

script:
- phpunit
- if [[ "$TRAVIS_PHP_VERSION" == '7.1' ]]; then vendor/bin/phpunit; fi
- if [[ "$TRAVIS_PHP_VERSION" != '7.1' ]]; then phpunit; fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ You can set the account number you wish to use by calling;

You can then also retrieve the currently set account number with:

$Reporter->getAccountNumber();
$Reporter->getAccountNum();

### Vendor Number

Expand Down
3 changes: 2 additions & 1 deletion src/Reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ public function performRequest($endpoint, $jsonRequest)
'headers' => [
'User-Agent' => 'Java/1.8.0_92',
'Accept' => 'text/xml, text/plain'
]
],
'decode_content' => false
]
);

Expand Down
66 changes: 33 additions & 33 deletions tests/ReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function testProcessResponseReturnsCorrectArray()
{
$action = 'Sales.getVendors';

$WorkingResponse = $this->getMock('Psr\Http\Message\ResponseInterface');
$WorkingResponse = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$WorkingResponse->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Vendors><Vendor>1234567</Vendor><Vendor>9876543</Vendor></Vendors>');

Expand All @@ -157,7 +157,7 @@ public function testProcessResponseReturnsCorrectArray()
)
);

$BlankResponse = $this->getMock('Psr\Http\Message\ResponseInterface');
$BlankResponse = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$BlankResponse->method('getBody')
->willReturn('');

Expand All @@ -174,7 +174,7 @@ public function testProcessResponseThrowsExceptionIfInvalidAction()
{
$this->setExpectedException('InvalidArgumentException');

$BlankResponse = $this->getMock('Psr\Http\Message\ResponseInterface');
$BlankResponse = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$BlankResponse->method('getBody')
->willReturn('');

Expand All @@ -187,13 +187,13 @@ public function testProcessResponseThrowsExceptionIfInvalidAction()

public function testPerformRequestCanCheckStatusAndReturnCorrectly()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Vendors><Vendor>1234567</Vendor><Vendor>9876543</Vendor></Vendors>');
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand Down Expand Up @@ -231,13 +231,13 @@ public function testPerformRequestCanCheckStatusAndReturnCorrectly()

public function testPerformRequestWhenResponseHasFailed()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('');
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand Down Expand Up @@ -270,13 +270,13 @@ public function testPerformRequestWhenResponseHasFailed()

public function testGetSalesAccountsReturnsCorrectArray()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Accounts><Account><Name>John Smith</Name><Number>1234567</Number></Account></Accounts>');
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -299,13 +299,13 @@ public function testGetSalesAccountsReturnsCorrectArray()

public function testGetSalesAccountsReturnsBlankArrayOnFail()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('');
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -323,13 +323,13 @@ public function testGetSalesAccountsReturnsBlankArrayOnFail()

public function testGetSalesVendorsReturnsCorrectArray()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Vendors><Vendor>1234567</Vendor><Vendor>9876543</Vendor></Vendors>');
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -350,13 +350,13 @@ public function testGetSalesVendorsReturnsCorrectArray()

public function testGetSalesVendorsReturnsBlankArrayOnFail()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('');
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -374,13 +374,13 @@ public function testGetSalesVendorsReturnsBlankArrayOnFail()

public function testGetFinanceAccountsReturnsCorrectArray()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Accounts><Account><Name>John Smith</Name><Number>1234567</Number></Account></Accounts>');
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -403,13 +403,13 @@ public function testGetFinanceAccountsReturnsCorrectArray()

public function testGetFinanceAccountsReturnsBlankArrayOnFail()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('');
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -427,13 +427,13 @@ public function testGetFinanceAccountsReturnsBlankArrayOnFail()

public function testGetFinanceVendorsReturnsCorrectArray()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><VendorsAndRegions><Vendor><Number>1234567</Number><Region><Code>AE</Code><Reports><Report>Financial</Report></Reports></Region><Region><Code>AU</Code><Reports><Report>Financial</Report><Report>Sale</Report></Reports></Region></Vendor></VendorsAndRegions>');
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand Down Expand Up @@ -470,13 +470,13 @@ public function testGetFinanceVendorsReturnsCorrectArray()

public function testGetFinanceVendorsReturnsBlankArrayOnFail()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('');
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -494,15 +494,15 @@ public function testGetFinanceVendorsReturnsBlankArrayOnFail()

public function testGetSalesReportReturnsCorrectReport()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestSalesReportContent
);
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand Down Expand Up @@ -536,15 +536,15 @@ public function testGetSalesReportReturnsCorrectReport()

public function testGetSalesReportReturnsBlankArrayWhenNoReport()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestSalesReportNoContent
);
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -562,15 +562,15 @@ public function testGetSalesReportReturnsBlankArrayWhenNoReport()

public function testGetFinanceReportReturnsCorrectReport()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestFinanceReportContent
);
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand Down Expand Up @@ -606,15 +606,15 @@ public function testGetFinanceReportReturnsCorrectReport()

public function testGetFinanceReportReturnsBlankArrayWhenNoReport()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestFinanceReportNoContent
);
$Response->method('getStatusCode')
->willReturn(404);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand All @@ -632,13 +632,13 @@ public function testGetFinanceReportReturnsBlankArrayWhenNoReport()

public function testGetLastResultReturnsCorrectValue()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Vendors><Vendor>1234567</Vendor><Vendor>9876543</Vendor></Vendors>');
$Response->method('getStatusCode')
->willReturn(200);

$GuzzleMock = $this->getMock('GuzzleHttp\ClientInterface');
$GuzzleMock = $this->getMockBuilder('GuzzleHttp\ClientInterface')->getMock();
$GuzzleMock->method('request')
->willReturn(
$Response
Expand Down
8 changes: 4 additions & 4 deletions tests/Responses/FinanceGetAccountsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FinanceGetAccountsTest extends \PHPUnit_Framework_TestCase
{
public function testProcessReturnsCorrectValueForSingleFinanceAccount()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Accounts><Account><Name>John Smith</Name><Number>1234567</Number></Account></Accounts>');

Expand All @@ -28,7 +28,7 @@ public function testProcessReturnsCorrectValueForSingleFinanceAccount()

public function testProcessReturnsCorrectValueForMultipleFinanceAccount()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Accounts><Account><Name>John Smith</Name><Number>1234567</Number></Account><Account><Name>Jane Doe</Name><Number>9876543</Number></Account></Accounts>');

Expand All @@ -53,7 +53,7 @@ public function testProcessReturnsCorrectValueForMultipleFinanceAccount()

public function testProcessReturnsEmptyArrayForInvalidXML()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Accounts><Account><Name>John Smith 1234567</Number></Account><Account><Name>Jane Doe</Name><Number>9876543</Number></Accounts>');

Expand All @@ -69,7 +69,7 @@ public function testProcessReturnsEmptyArrayForInvalidXML()

public function testProcessReturnsEmptyArrayForEmptyContents()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn('');

Expand Down
6 changes: 3 additions & 3 deletions tests/Responses/FinanceGetReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FinanceGetReportTest extends \PHPUnit_Framework_TestCase
{
public function testProcessReturnsReportInArrayFormat()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestFinanceReportContent
Expand Down Expand Up @@ -43,7 +43,7 @@ public function testProcessReturnsReportInArrayFormat()

public function testProcessReturnsEmptyArrayWhenContentsEmpty()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestFinanceReportNoContent
Expand All @@ -61,7 +61,7 @@ public function testProcessReturnsEmptyArrayWhenContentsEmpty()

public function testProcessReturnsEmptyArrayIfFileIsNotGZipped()
{
$Response = $this->getMock('Psr\Http\Message\ResponseInterface');
$Response = $this->getMockBuilder('Psr\Http\Message\ResponseInterface')->getMock();
$Response->method('getBody')
->willReturn(
new TestFinanceReportNoEncoding
Expand Down
Loading

0 comments on commit a72f778

Please sign in to comment.