Skip to content

Commit

Permalink
Adding test response with single transaction type result
Browse files Browse the repository at this point in the history
  • Loading branch information
rojtjo committed Sep 12, 2023
1 parent 0948339 commit bcbbf66
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ApiConnectors/TransactionTypeApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public function listAll(
$transactionTypes = [];
foreach ($response->data->Items->ArrayOfString as $transactionTypeArray) {
$transactionType = new TransactionType();
if(is_array($transactionTypeArray)) {

if (is_array($transactionTypeArray)) {
$transactionType->setCode($transactionTypeArray[0]);
$transactionType->setName($transactionTypeArray[1]);
} else {
Expand Down
26 changes: 21 additions & 5 deletions tests/IntegrationTests/TransactionTypesIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ protected function setUp(): void
$this->transactionTypeApiConnector = new TransactionTypeApiConnector($this->connection);
}

public function testListAllWorks()
public function testListAllWithMultipleResults()
{
$response = require __DIR__ . '/resources/transactionTypesListAllResponse.php';
$response = require __DIR__ . '/resources/transactionTypesListAllWithMultipleResultsResponse.php';

$this->finderService
->expects($this->once())
Expand All @@ -47,6 +47,22 @@ public function testListAllWorks()
$this->assertSame('Verkoopfactuur', $transactionTypes[4]->getName());
}

public function testListAllWithSingleResult()
{
$response = require __DIR__ . '/resources/transactionTypesListAllWithSingleResultResponse.php';

$this->finderService
->expects($this->once())
->method("searchFinder")
->with(FinderService::TYPE_TRANSACTION_TYPES, '*', 0, 1, 100, [])
->willReturn($response);

$transactionTypes = $this->transactionTypeApiConnector->listAll();

$this->assertSame('BEGINBALANS', $transactionTypes[0]->getCode());
$this->assertSame('Beginbalans', $transactionTypes[0]->getName());
}

public function testListAllTheIcOptionCannotBeUsedInCombinationWithTheHiddenOption()
{
$this->expectException(\InvalidArgumentException::class);
Expand All @@ -56,7 +72,7 @@ public function testListAllTheIcOptionCannotBeUsedInCombinationWithTheHiddenOpti

public function testListAllWithCategory()
{
$response = require __DIR__ . '/resources/transactionTypesListAllResponse.php';
$response = require __DIR__ . '/resources/transactionTypesListAllWithMultipleResultsResponse.php';

$this->finderService
->expects($this->once())
Expand All @@ -71,7 +87,7 @@ public function testListAllWithCategory()

public function testListAllWithTheIcOption()
{
$response = require __DIR__ . '/resources/transactionTypesListAllResponse.php';
$response = require __DIR__ . '/resources/transactionTypesListAllWithMultipleResultsResponse.php';

$this->finderService
->expects($this->once())
Expand All @@ -86,7 +102,7 @@ public function testListAllWithTheIcOption()

public function testListAllWithTheHiddenOption()
{
$response = require __DIR__ . '/resources/transactionTypesListAllResponse.php';
$response = require __DIR__ . '/resources/transactionTypesListAllWithMultipleResultsResponse.php';

$this->finderService
->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

return (object) array(
'SearchResult' =>
(object) array(
),
'data' =>
(object) array(
'TotalRows' => 5,
'Columns' =>
(object) array(
'string' =>
array (
0 => 'Code',
1 => 'Naam',
),
),
'Items' =>
(object) array(
'ArrayOfString' =>
array (
0 =>
array (
0 => 'BEGINBALANS',
1 => 'Beginbalans',
),
),
),
),
);

0 comments on commit bcbbf66

Please sign in to comment.