diff --git a/examples/Activity.php b/examples/Activity.php index ef2f58c1..3fc6453e 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -69,7 +69,7 @@ * */ -//List all with pattern "A*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> accessrules = 0 +//List all with pattern "A*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> accessrules = 0 if ($executeListAllWithFilter) { $options = array('accessrules' => 0); diff --git a/examples/Article.php b/examples/Article.php index ebec6173..da4679fb 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -60,7 +60,7 @@ * */ -//List all with pattern "O*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> vat = 'inclusive' +//List all with pattern "O*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> vat = 'inclusive' if ($executeListAllWithFilter) { $options = array('vat' => 'inclusive'); diff --git a/examples/CashBankBook.php b/examples/CashBankBook.php index 7423faf2..3bb1a3e2 100644 --- a/examples/CashBankBook.php +++ b/examples/CashBankBook.php @@ -45,7 +45,7 @@ * Usage: $options['banktype'] = -1; */ -//List all with pattern "BNK", field 0 (= search code or number), firstRow 1, maxRows 10, options -> banktype = 0 +//List all with pattern "BNK", field 0 (= search code or name), firstRow 1, maxRows 10, options -> banktype = 0 if ($executeListAllWithFilter) { $options = array('banktype' => 0); diff --git a/examples/CostCenter.php b/examples/CostCenter.php index 05e3756e..14f45fb5 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -65,7 +65,7 @@ * Usage: $options['group'] = 'DimensionGroup'; */ -//List all with pattern "Apeldoorn", field 0 (= search code or number), firstRow 1, maxRows 10, options -> modifiedsince = '20190101100000', group = 'DimensionGroup' +//List all with pattern "Apeldoorn", field 0 (= search code or name), firstRow 1, maxRows 10, options -> modifiedsince = '20190101100000', group = 'DimensionGroup' if ($executeListAllWithFilter) { $options = array('modifiedsince' => '20190101100000', 'group' => 'DimensionGroup'); diff --git a/examples/Country.php b/examples/Country.php index ed048ab0..ddd7769d 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -41,7 +41,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "NL", field 0 (= search code or number), firstRow 1, maxRows 10 +//List all with pattern "NL", field 0 (= search code or name), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { $countries = $countryApiConnector->listAll('NL', 0, 1, 10); diff --git a/examples/Currency.php b/examples/Currency.php index 938e8176..f714e86f 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -54,7 +54,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "EUR", field 0 (= search code or number), firstRow 1, maxRows 10, options [] +//List all with pattern "EUR", field 0 (= search code or name), firstRow 1, maxRows 10, options [] if ($executeListAllWithFilter) { try { $currencies = $currencyApiConnector->listAll("EUR", 0, 1, 10); diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index 9a89942e..b7c20f78 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -62,7 +62,7 @@ * */ -//List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> dimtype = 'BAS' +//List all with pattern "*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> dimtype = 'BAS' if ($executeListAllWithFilter) { $options = array('dimtype' => 'BAS'); diff --git a/examples/DimensionType.php b/examples/DimensionType.php index c299076d..0521dbd1 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -60,7 +60,7 @@ * */ -//List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> finlevel = 2 +//List all with pattern "*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> finlevel = 2 if ($executeListAllWithFilter) { $options = array('finlevel' => 2); diff --git a/examples/Invoice.php b/examples/Invoice.php index 0fc7391d..2de30cee 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -64,7 +64,7 @@ * */ -//List all with pattern "2019*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> openvalue = 50.25 +//List all with pattern "2019*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> openvalue = 50.25 if ($executeListAllWithFilter) { $options = array('openvalue' => 50.25); diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php index 1649ebfd..a77182a1 100644 --- a/examples/InvoiceType.php +++ b/examples/InvoiceType.php @@ -35,7 +35,7 @@ * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * Available options: office + * Available options: office, vat * * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; @@ -45,7 +45,7 @@ * Usage: $options['vat'] = 'inclusive'; */ -//List all with pattern "INV*", field 0 (= search code or number), firstRow 1, maxRows 10, options, options -> vat = 'exclusive' +//List all with pattern "INV*", field 0 (= search code or name), firstRow 1, maxRows 10, options, options -> vat = 'exclusive' if ($executeListAllWithFilter) { $options = array('vat' => 'exclusive'); diff --git a/examples/Office.php b/examples/Office.php new file mode 100644 index 00000000..e7e706fa --- /dev/null +++ b/examples/Office.php @@ -0,0 +1,157 @@ +listAllWithoutOfficeCode(); + } catch (ResponseException $e) { + $offices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($offices);
+    echo "
"; +} + +//List all with pattern "NL*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> consolidate = 0 +if ($executeListAllWithFilter) { + $options = array('consolidate' => 0); + + try { + $offices = $officeApiConnector->listAll("NL*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $offices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($offices);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $offices = $officeApiConnector->listAll(); + } catch (ResponseException $e) { + $offices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($offices);
+    echo "
"; +} + +/* Office + * \PhpTwinfield\Office + * Available getters: __toString, getCode, getCountryCode, getCountryCodeToString, getCreated, getCreatedToString, getMessages, getModified, getModifiedToString, getName, getResult, getShortName, getStatus, getTouched, getUser, getUserToString, getVatFirstQuarterStartsIn, getVatPeriod, hasMessages + * Available setters: fromCode, setCode, setCountryCode, setCountryCodeFromString, setName, setShortName, setStatus, setStatusFromString, setVatFirstQuarterStartsIn,setVatPeriod + */ + +if ($executeListAllWithoutOfficeCode || $executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($offices as $key => $office) { + echo "Office {$key}
"; + echo "Code: {$office->getCode()}
"; + echo "Name: {$office->getName()}

"; + echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; + echo "CountryCode (string): {$office->getCountryCodeToString()}
"; + echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; + echo "VatPeriod: {$office->getVatPeriod()}
"; + } +} + +// Read an Office based off the passed in code and optionally the office. +if ($executeRead) { + try { + $office = $officeApiConnector->get("NLA000001", $defaultOffice); + } catch (ResponseException $e) { + $office = $e->getReturnedObject(); + } + + echo "
";
+    print_r($office);
+    echo "
"; + + echo "Office
"; + echo "Code: {$office}
"; // string|null + echo "Code: {$office->getCode()}
"; // string|null + //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null + //echo "CountryCode (string): {$office->getCountryCodeToString()}
"; // string|null + echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the office was created. + echo "Created (string): {$office->getCreatedToString()}
"; // string|null + + if ($office->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // \DateTimeInterface|null The date/time the office was modified. + echo "Modified (string): {$office->getModifiedToString()}
"; // string|null + echo "Name: {$office->getName()}
"; // string|null + echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$office->getShortName()}
"; // string|null + echo "Status: {$office->getStatus()}
"; // Status|null + echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. + echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. + echo "User (string): {$office->getUserToString()}
"; // string|null + //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null + //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null +} \ No newline at end of file diff --git a/examples/PayCode.php b/examples/PayCode.php index 4456fd1f..d20efade 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -45,7 +45,7 @@ * Usage: $options['paytype'] = 'pay'; */ -//List all with pattern "SEPA*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> paytype = pay +//List all with pattern "SEPA*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> paytype = pay if ($executeListAllWithFilter) { $options = array('paytype' => 'pay'); diff --git a/examples/Project.php b/examples/Project.php index e769450c..7e4177cc 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -69,7 +69,7 @@ * */ -//List all with pattern "P*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> accessrules = 0 +//List all with pattern "P*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> accessrules = 0 if ($executeListAllWithFilter) { $options = array('accessrules' => 0); diff --git a/examples/Rate.php b/examples/Rate.php index 80fbeae4..13200e46 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -48,7 +48,7 @@ * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * Available options: office + * Available options: office, ratetype * * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; @@ -58,7 +58,7 @@ * Usage: $options['ratetype'] = 'quantity'; */ -//List all with pattern "DIR*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> ratetype = 'quantity' +//List all with pattern "DIR*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> ratetype = 'quantity' if ($executeListAllWithFilter) { $options = array('ratetype' => 'time'); diff --git a/examples/UserRole.php b/examples/UserRole.php index dfb6f90c..845be5c8 100644 --- a/examples/UserRole.php +++ b/examples/UserRole.php @@ -41,7 +41,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "LVL1*", field 0 (= search code or number), firstRow 1, maxRows 10 +//List all with pattern "LVL1*", field 0 (= search code or name), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { $userRoles = $userRoleApiConnector->listAll("LVL1*", 0, 1, 10); diff --git a/examples/VatCode.php b/examples/VatCode.php index 5bfa0c5b..8a8659bc 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -59,7 +59,7 @@ * */ -//List all with pattern "V*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> vattype = 'sales' +//List all with pattern "V*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> vattype = 'sales' if ($executeListAllWithFilter) { $options = array('vattype' => 'sales'); diff --git a/examples/VatGroup.php b/examples/VatGroup.php index 8e3f705a..01cff0ee 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -41,7 +41,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "1*", field 0 (= search code or number), firstRow 1, maxRows 10 +//List all with pattern "1*", field 0 (= search code or name), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { $vatGroups = $vatGroupApiConnector->listAll("1*", 0, 1, 10); diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index c5f51535..e94dd500 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -44,7 +44,7 @@ * Usage: $options['country'] = 'NL'; */ -//List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> country = NL +//List all with pattern "*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> country = NL if ($executeListAllWithFilter) { $options = array('country' => 'NL'); diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index ca48eeba..db631c82 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -11,10 +11,10 @@ use PhpTwinfield\Fields\FreeText1Field; use PhpTwinfield\Fields\FreeText2Field; use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; use PhpTwinfield\Fields\Transaction\RegimeField; use PhpTwinfield\Fields\Transaction\StatementNumberField; diff --git a/src/Fields/Invoice/InvoiceNumberField.php b/src/Fields/InvoiceNumberField.php similarity index 81% rename from src/Fields/Invoice/InvoiceNumberField.php rename to src/Fields/InvoiceNumberField.php index 5327a8c4..70d09bc5 100644 --- a/src/Fields/Invoice/InvoiceNumberField.php +++ b/src/Fields/InvoiceNumberField.php @@ -1,32 +1,32 @@ -invoiceNumber; - } - - /** - * @param null|string $invoiceNumber - * @return $this - */ - public function setInvoiceNumber(?string $invoiceNumber): self - { - $this->invoiceNumber = $invoiceNumber; - return $this; - } +invoiceNumber; + } + + /** + * @param null|string $invoiceNumber + * @return $this + */ + public function setInvoiceNumber(?string $invoiceNumber): self + { + $this->invoiceNumber = $invoiceNumber; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Transaction/InvoiceNumberField.php b/src/Fields/Transaction/InvoiceNumberField.php deleted file mode 100644 index e341d426..00000000 --- a/src/Fields/Transaction/InvoiceNumberField.php +++ /dev/null @@ -1,32 +0,0 @@ -invoiceNumber; - } - - /** - * @param null|string $invoiceNumber - * @return $this - */ - public function setInvoiceNumber(?string $invoiceNumber): self - { - $this->invoiceNumber = $invoiceNumber; - return $this; - } -} \ No newline at end of file diff --git a/src/Invoice.php b/src/Invoice.php index 5771c268..9466d44a 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -16,12 +16,12 @@ use PhpTwinfield\Fields\Invoice\InvoiceAddressNumberField; use PhpTwinfield\Fields\Invoice\InvoiceAmountField; use PhpTwinfield\Fields\Invoice\InvoiceDateField; -use PhpTwinfield\Fields\Invoice\InvoiceNumberField; use PhpTwinfield\Fields\Invoice\InvoiceTypeField; use PhpTwinfield\Fields\Invoice\PaymentMethodField; use PhpTwinfield\Fields\Invoice\PeriodRaiseWarningField; use PhpTwinfield\Fields\Invoice\RaiseWarningField; use PhpTwinfield\Fields\Invoice\StatusField; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PeriodField; diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index d3f73df5..3fe8e04b 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -6,9 +6,9 @@ use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Enums\MatchStatus; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 10dd6b94..88595386 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -11,10 +11,10 @@ use PhpTwinfield\Fields\FreeText1Field; use PhpTwinfield\Fields\FreeText2Field; use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; use PhpTwinfield\Fields\Transaction\RegimeField; diff --git a/src/PurchaseTransaction.php b/src/PurchaseTransaction.php index 05f6d7fc..cda947ab 100644 --- a/src/PurchaseTransaction.php +++ b/src/PurchaseTransaction.php @@ -3,7 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\DueDateField; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; diff --git a/src/SalesTransaction.php b/src/SalesTransaction.php index b1a547b4..c86d7cac 100644 --- a/src/SalesTransaction.php +++ b/src/SalesTransaction.php @@ -3,7 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\DueDateField; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; diff --git a/tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php b/tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php new file mode 100644 index 00000000..180800d4 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new ActivityApiConnector($connection); + } + + private function createActivity(): Activity + { + $activity = new Activity(); + return $activity; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/activity-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $activity = $this->createActivity(); + + $mapped = $this->apiConnector->send($activity); + + $this->assertInstanceOf(Activity::class, $mapped); + $this->assertEquals("A001", $mapped->getCode()); + $this->assertEquals("Test Activity", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php b/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php new file mode 100644 index 00000000..595b4e2f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new AssetMethodApiConnector($connection); + } + + private function createAssetMethod(): AssetMethod + { + $assetMethod = new AssetMethod(); + return $assetMethod; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/assetmethod-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $assetMethod = $this->createAssetMethod(); + + $mapped = $this->apiConnector->send($assetMethod); + + $this->assertInstanceOf(AssetMethod::class, $mapped); + $this->assertEquals("101", $mapped->getCode()); + $this->assertEquals("Inventaris", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php new file mode 100644 index 00000000..eb9b071e --- /dev/null +++ b/tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new CostCenterApiConnector($connection); + } + + private function createCostCenter(): CostCenter + { + $costCenter = new CostCenter(); + return $costCenter; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/costcenter-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $costCenter = $this->createCostCenter(); + + $mapped = $this->apiConnector->send($costCenter); + + $this->assertInstanceOf(CostCenter::class, $mapped); + $this->assertEquals("00001", $mapped->getCode()); + $this->assertEquals("Hoevelaken", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php index eb7e875d..5ac98ae2 100644 --- a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php @@ -49,7 +49,7 @@ private function createCustomer(): Customer public function testSendAllReturnsMappedObjects() { $response = Response::fromString(file_get_contents( - __DIR__."/resources/customers-response.xml" + __DIR__."/resources/customer-response.xml" )); $this->processXmlService->expects($this->once()) diff --git a/tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php b/tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php new file mode 100644 index 00000000..3b0eceb4 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new DimensionGroupApiConnector($connection); + } + + private function createDimensionGroup(): DimensionGroup + { + $dimensionGroup = new DimensionGroup(); + return $dimensionGroup; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/dimensiongroup-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $dimensionGroup = $this->createDimensionGroup(); + + $mapped = $this->apiConnector->send($dimensionGroup); + + $this->assertInstanceOf(DimensionGroup::class, $mapped); + $this->assertEquals("TSTDIMGRP", $mapped->getCode()); + $this->assertEquals("Test Dimension Group", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php b/tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php new file mode 100644 index 00000000..bd074fe0 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new DimensionTypeApiConnector($connection); + } + + private function createDimensionType(): DimensionType + { + $dimensionType = new DimensionType(); + return $dimensionType; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/dimensiontype-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $dimensionType = $this->createDimensionType(); + + $mapped = $this->apiConnector->send($dimensionType); + + $this->assertInstanceOf(DimensionType::class, $mapped); + $this->assertEquals("DEB", $mapped->getCode()); + $this->assertEquals("Debiteuren", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php new file mode 100644 index 00000000..7fda71d7 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new FixedAssetApiConnector($connection); + } + + private function createFixedAsset(): FixedAsset + { + $fixedAsset = new FixedAsset(); + return $fixedAsset; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/fixedasset-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $fixedAsset = $this->createFixedAsset(); + + $mapped = $this->apiConnector->send($fixedAsset); + + $this->assertInstanceOf(FixedAsset::class, $mapped); + $this->assertEquals("60000", $mapped->getCode()); + $this->assertEquals("Afschrijving Computer", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php new file mode 100644 index 00000000..1329bca9 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new GeneralLedgerApiConnector($connection); + } + + private function createGeneralLedger(): GeneralLedger + { + $generalLedger = new GeneralLedger(); + return $generalLedger; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/generalledger-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $generalLedger = $this->createGeneralLedger(); + + $mapped = $this->apiConnector->send($generalLedger); + + $this->assertInstanceOf(GeneralLedger::class, $mapped); + $this->assertEquals("4004", $mapped->getCode()); + $this->assertEquals("Bonussen/gratificaties", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php new file mode 100644 index 00000000..9be43557 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new InvoiceApiConnector($connection); + } + + private function createInvoice(): Invoice + { + $invoice = new Invoice(); + return $invoice; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/invoice-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $invoice = $this->createInvoice(); + + $mapped = $this->apiConnector->send($invoice); + + $this->assertInstanceOf(Invoice::class, $mapped); + $this->assertEquals("10", $mapped->getInvoiceNumber()); + $this->assertEquals("20190410", $mapped->getInvoiceDateToString()); + } +} diff --git a/tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php b/tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php new file mode 100644 index 00000000..9d531398 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new ProjectApiConnector($connection); + } + + private function createProject(): Project + { + $project = new Project(); + return $project; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/project-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $project = $this->createProject(); + + $mapped = $this->apiConnector->send($project); + + $this->assertInstanceOf(Project::class, $mapped); + $this->assertEquals("P0000", $mapped->getCode()); + $this->assertEquals("Project direct", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php b/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php new file mode 100644 index 00000000..fc1025b0 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new RateApiConnector($connection); + } + + private function createRate(): Rate + { + $rate = new Rate(); + return $rate; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/rate-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $rate = $this->createRate(); + + $mapped = $this->apiConnector->send($rate); + + $this->assertInstanceOf(Rate::class, $mapped); + $this->assertEquals("DIRECT", $mapped->getCode()); + $this->assertEquals("Direct rate", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php b/tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php new file mode 100644 index 00000000..8fb73c1c --- /dev/null +++ b/tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new SupplierApiConnector($connection); + } + + private function createSupplier(): Supplier + { + $supplier = new Supplier(); + return $supplier; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/supplier-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $supplier = $this->createSupplier(); + + $mapped = $this->apiConnector->send($supplier); + + $this->assertInstanceOf(Supplier::class, $mapped); + $this->assertEquals("2000", $mapped->getCode()); + $this->assertEquals("Smits", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index d4be823e..e6c7ba6a 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\UnitTests; -use Money\Currency; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BaseTransaction; use PhpTwinfield\Enums\Destiny; diff --git a/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php new file mode 100644 index 00000000..cd63624b --- /dev/null +++ b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new VatCodeApiConnector($connection); + } + + private function createVatCode(): VatCode + { + $vatCode = new VatCode(); + return $vatCode; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/vatcode-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $vatCode = $this->createVatCode(); + + $mapped = $this->apiConnector->send($vatCode); + + $this->assertInstanceOf(VatCode::class, $mapped); + $this->assertEquals("VH", $mapped->getCode()); + $this->assertEquals("VAT Sales High", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml b/tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml deleted file mode 100644 index 848ba3d8..00000000 --- a/tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml +++ /dev/null @@ -1,178 +0,0 @@ - - - -
- BNK - OFFICE001 - 2017/06 - 20170901 - EUR - 0.00 - 0.00 - import - CHUCK-NORRIS - generic - 0 -
- - - 1100 - credit - 0.01 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.01 - 1 - 0.01 - notmatchable - - - 1800 - credit - 12.90 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 12.90 - 1 - 12.90 - - notmatchable - - - 4700 - debit - 12.90 - 2017.123456 - Some description - Some comment - 1 - 12.90 - 1 - 12.90 - - notmatchable - - -
- -
- BNK - OFFICE001 - 2017/07 - 20170901 - EUR - 0.00 - 0.00 - import - CHUCK-NORRIS - generic - 0 -
- - - 1100 - credit - 0.01 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.01 - 1 - 0.01 - notmatchable - - - 1800 - credit - 5.15 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 5.15 - 1 - 5.15 - - notmatchable - - - 4700 - debit - 5.15 - 2017.123456 - Some other description - Some other comment - 1 - 5.15 - 1 - 5.15 - - notmatchable - - -
- -
- BNK - OFFICE001 - 2017/08 - 20170901 - EUR - 0.00 - 0.00 - import - CHUCK-NORRIS - generic - 0 - 201700334 -
- - - 1100 - debit - 0.00 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.00 - 1 - 0.00 - notmatchable - - - 1800 - debit - 0.87 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.87 - 1 - 0.87 - - notmatchable - - - 8000 - credit - 0.87 - 2017.123456 - Last description - Last comment - 1 - 0.87 - 1 - 0.87 - - notmatchable - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/activity-response.xml b/tests/UnitTests/ApiConnectors/resources/activity-response.xml new file mode 100644 index 00000000..116f75d2 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/activity-response.xml @@ -0,0 +1,63 @@ + + + DEV1000 + ACT + A001 + 149e5dcb-8b37-446b-b865-f3928572618f + Test Activity + TstAct + falsenormal + 1 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + inherit + false + 0 + 4 + false + none + + false + + 0 + + + + + false + + + A001 + + + + core + + PRJ + + + + ToFileManager + + + + + + + + + + true + + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/article-response.xml b/tests/UnitTests/ApiConnectors/resources/article-response.xml new file mode 100644 index 00000000..6de9f20f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/article-response.xml @@ -0,0 +1,36 @@ + +
+
+ DEV1000 + 9060 + normal + Test Article + TstArt + Test Article + Test Articles + VN + false + + false + false + true + true + true +
+ + + 0.00 + 0.00 + 1 + Test SubArticle + TstSubArt + 9060 + 9060 + + + + + + + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml b/tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml new file mode 100644 index 00000000..d4103ae9 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml @@ -0,0 +1,36 @@ + + + DEV1000 + 101 + Inventaris + Inv + 20190426120347 + 20190501092003 + 10 + API000001 + 0 + 10 + from_purchase_date + linearpercentage + + + 0155 + + 0150 + + + + + + 4750 + + + + + 1 + 2 + 3 + 4 + 5 + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml b/tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml deleted file mode 100644 index 7c03cb95..00000000 --- a/tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - -
- BNK - OFFICE001 - 2017/09 - 20170901 - EUR - 0.00 - 121.00 - import - USER - generic - 0 - 201700001 -
- - - 1100 - debit - 121.00 - 1 - 121.00 - 1 - 121.00 - notmatchable - - - 2200 - credit - 100.00 - My transaction - VH - 21.00 - 1 - 100.00 - 1 - 100.00 - - - 21.00 - notmatchable - - - credit - 21.00 - VH - 1 - 21.00 - 1 - 21.00 - 1 - 100.00 - 100.00 - 1502 - notmatchable - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/costcenter-response.xml b/tests/UnitTests/ApiConnectors/resources/costcenter-response.xml new file mode 100644 index 00000000..5e8782fe --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/costcenter-response.xml @@ -0,0 +1,50 @@ + + + DEV1000 + KPL + 00001 + 149e5dcb-8b37-446b-b865-f3928572618f + Hoevelaken + + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + inherit + maybe + 0 + 2 + false + none + + false + + 0 + + + + + false + + + 00001 + + + + core + + + ToFileManager + + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/customer-response.xml b/tests/UnitTests/ApiConnectors/resources/customer-response.xml new file mode 100644 index 00000000..d60118e8 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/customer-response.xml @@ -0,0 +1,80 @@ + + + D1001 + Hr E G H Küppers en/of MW M.J. Küppers-Veeneman + DEB + DEV1000 + +
+ + + BE + + + + + + + + + BE0123456789 + + +
+
+ 149e5dcb-8b37-446b-b865-f3928572618f + true + + normal + 4 + 0 + 0 + 0 + 0 + + + + true + + customersupplier + inherit + false + 30 + 2 + false + none + + false + + 1 + + 130000 + + + + + false + + + D1001 + + + + core + + 130000 + + + + + 0.00 + true + + false + + + + + + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/customers-response.xml b/tests/UnitTests/ApiConnectors/resources/customers-response.xml deleted file mode 100644 index c1e8ae7b..00000000 --- a/tests/UnitTests/ApiConnectors/resources/customers-response.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - D1001 - Hr E G H Küppers en/of MW M.J. Küppers-Veeneman - DEB - DEV1000 - -
- - - BE - - - - - - - - - BE0123456789 - - -
-
- 149e5dcb-8b37-446b-b865-f3928572618f - true - - normal - 4 - 0 - 0 - 0 - 0 - - - - true - - customersupplier - inherit - false - 30 - 2 - false - none - - false - - 1 - - 130000 - - - - - false - - - D1001 - - - - core - - 130000 - - - - - 0.00 - true - - false - - - - - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml b/tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml new file mode 100644 index 00000000..c839dd4c --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml @@ -0,0 +1,18 @@ + + + DEV1000 + TSTDIMGRP + Test Dimension Group + TstDimGrp + 35 + + + BAS + 0100 + + + BAS + 0105 + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml b/tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml new file mode 100644 index 00000000..a5f966ae --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml @@ -0,0 +1,23 @@ + + + DEV1000 + DEB + Debiteuren + Debiteuren + 1[0-9][0-9][0-9] + 8 + + 2 + + 0 + 0 + +
+ Tav + Adres + Postadres + BTW nummer + KVK nummer + +
+
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml b/tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml deleted file mode 100644 index 9e197dcd..00000000 --- a/tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - -
- BNK_CODE_123 - 450 - 20170901 - 321 - EUR - 0.00 - 126.17 - import -
- - - 123456 - credit - 126.17 - - - 654321 - credit - 126.17 - description - comment - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml b/tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml new file mode 100644 index 00000000..113993d3 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml @@ -0,0 +1,68 @@ + + + DEV1000 + AST + 60000 + 149e5dcb-8b37-446b-b865-f3928572618f + Afschrijving Computer + + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + inherit + false + 30 + 3 + false + none + + false + + 2 + 00001 + + + + false + + + 60000 + + + + core + + + ToFileManager + + + + + active + 500.00 + 0.00 + 100 + 2019/01 + 20180401 + + + + + + + + 0 + 10 + 2019/12 + + diff --git a/tests/UnitTests/ApiConnectors/resources/generalledger-response.xml b/tests/UnitTests/ApiConnectors/resources/generalledger-response.xml new file mode 100644 index 00000000..dc20cf53 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/generalledger-response.xml @@ -0,0 +1,53 @@ + + + DEV1000 + PNL + 4004 + 149e5dcb-8b37-446b-b865-f3928572618f + Bonussen/gratificaties + Bonussen/gratificati + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + profitandloss + maybe + 0 + 1 + false + none + + false + + 0 + + + + + false + + + + + + + core + + KPL + + + + ToFileManager + + + + diff --git a/tests/UnitTests/ApiConnectors/resources/invoice-response.xml b/tests/UnitTests/ApiConnectors/resources/invoice-response.xml new file mode 100644 index 00000000..5e4e710e --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/invoice-response.xml @@ -0,0 +1,51 @@ + + +
+ DEV1000 + INVOICE + 10 + 20190410 + 20190510 + BNK + 1 + 1 + 1000 + 2019/4 + EUR + concept + cash + Headertext + Footertext +
+ + +
9060
+ 9060 + 1 + 1 + true + Afronding + 0.00 + 0.00 + 0.00 + 0.00 + + + + 9060 + EXP-BUI-EU +
+
+ + + EXP-BUI-EU + 0.00 + + + + + + 0.00 + 0.00 + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/project-response.xml b/tests/UnitTests/ApiConnectors/resources/project-response.xml new file mode 100644 index 00000000..6c501905 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/project-response.xml @@ -0,0 +1,71 @@ + + + DEV1000 + PRJ + P0000 + 149e5dcb-8b37-446b-b865-f3928572618f + Project direct + Project directK + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + matchable + inherit + maybe + 0 + 3 + false + none + + false + + 2 + 09999 + + + + false + + + P0000 + + + + core + + KPL + ACT + + + + ToFileManager + + + + + Project direct invoice description + + + + + + + + + + KILOMETERS + true + false + + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/rate-response.xml b/tests/UnitTests/ApiConnectors/resources/rate-response.xml new file mode 100644 index 00000000..6b9dc82a --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/rate-response.xml @@ -0,0 +1,22 @@ + + + DEV1000 + DIRECT + Direct rate + DirectK + 20161223182142 + 20161223182142 + 0 + SUPER + time + 60 + EUR + + + 20100101 + 20991231 + 60.0000 + 120.0000 + + + diff --git a/tests/UnitTests/ApiConnectors/resources/supplier-response.xml b/tests/UnitTests/ApiConnectors/resources/supplier-response.xml new file mode 100644 index 00000000..cfd908da --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/supplier-response.xml @@ -0,0 +1,116 @@ + + + DEV1000 + CRD + 2000 + 149e5dcb-8b37-446b-b865-f3928572618f + Smits + + true + normal + 6 + 0 + 0 + 0 + 0 + http://www.test.com + + + true + + customersupplier + inherit + false + 30 + 2 + true + paymentfile + SEPANLCT + false + + 1 + 1600 + L2000 + + IH + false + + + 2000 + + + + core + + 1600 + + + + ByEmail + test@test.nl + + +
+ BDRNAAM + NL + Utrecht + Postcode + Telefoon + Fax + test@test.com + + TAV + ADRESRGL1 + ADRESRGL2 + NL854800219B01 + KVK + +
+
+ + + Smits + 417164300 +
+ Testadres + 10 +
+ ABN + ABNANL2A + Utrecht + NL + NL91ABNA0417164300 + NL + 1234AB + Teststraat +
+
+ + + EUR + 100.00 + Test + + + + 0100 + 00001 + 60010 + 23 + # + Test + + + + + + + 14 + 10.00 + + + + 20.00 + true + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/vatcode-response.xml b/tests/UnitTests/ApiConnectors/resources/vatcode-response.xml new file mode 100644 index 00000000..9967ae7f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/vatcode-response.xml @@ -0,0 +1,33 @@ + + + VH + VAT Sales High + VATSlsHigh + 149e5dcb-8b37-446b-b865-f3928572618f + 20041027101342 + 20190410185128 + 0 + TWINAPPS + sales + + + 20121001 + 21.000000000 + 20171016135323 + VAT Sales High + VATSlsHigh + SUPER + + + + + 1530 + NL + NL1A + 100.0 + vat + + + + + diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index d5923a2a..ece6f3dd 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -34,14 +34,14 @@ public function testXmlIsCreatedPerSpec() $customer->setOffice(Office::fromCode("DEV-10000")); $customer->setStatusFromString('active'); - $financials = new CustomerFinancials(); + $financials = new CustomerFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); $financials->setPayCodeFromString('pay-code'); $financials->setVatCodeFromString('vat-code'); $financials->setEBilling(true); $financials->setEBillMail('ebillingmail@mail.com'); - $customer->setFinancials($financials); + $customer->setFinancials($financials); $customer->setCreditManagement( (new CustomerCreditManagement()) @@ -54,6 +54,7 @@ public function testXmlIsCreatedPerSpec() ->setFreeText2('free2') ->setComment('comment comment') ); + $customer->addAddress( (new CustomerAddress()) ->setDefault(true) @@ -72,6 +73,7 @@ public function testXmlIsCreatedPerSpec() ->setField5('field 5') ->setField6('field 6') ); + $customer->addBank( (new CustomerBank()) ->setDefault(true) diff --git a/tests/UnitTests/Supplier/OfficeTest.php b/tests/UnitTests/Supplier/OfficeTest.php deleted file mode 100644 index 98befed6..00000000 --- a/tests/UnitTests/Supplier/OfficeTest.php +++ /dev/null @@ -1,54 +0,0 @@ -office = Office::fromCode('TEST-001'); - } - - /** - * @covers \PhpTwinfield\Supplier::setOffice() - * @todo Implement testSetOffice(). - */ - public function testSetOffice() - { - $customer = new Supplier; - - $customer->setOffice($this->office); - - $this->assertEquals($this->office, $customer->getOffice()); - - return $customer; - } - - /** - * Checks if the office field is correctly serialized - * - * @depends testSetOffice - */ - public function testSetOfficeAndSerializes(Supplier $customer) - { - $document = new SuppliersDocument; - - $document->addSupplier($customer); - - $this->assertEquals($document->getElementsByTagName('office')->item(0)->nodeValue, $this->office); - } -} diff --git a/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php b/tests/UnitTests/Transactions/ValueFieldsUnitTest.php similarity index 99% rename from tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php rename to tests/UnitTests/Transactions/ValueFieldsUnitTest.php index 9f32d6f7..f5d0275b 100644 --- a/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php +++ b/tests/UnitTests/Transactions/ValueFieldsUnitTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; /** - * @covers \PhpTwinfield\Transactions\TransactionLineFields\ValueFields + * @covers \PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields */ class ValueFieldsUnitTest extends TestCase {