Skip to content

Commit

Permalink
Add typehint for test and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and monofone committed Jun 19, 2020
1 parent 0da95b1 commit 1105288
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 132 deletions.
2 changes: 1 addition & 1 deletion src/DomBuilder/CustomerDirectDebitTransferDomBuilder.php
Expand Up @@ -192,7 +192,7 @@ public function visitTransferInformation(TransferInformationInterface $transacti
$directDebitTransactionInformation->appendChild(
$this->getStructuredRemittanceElement($transactionInformation)
);
} else {
} elseif (strlen($transactionInformation->getRemittanceInformation()) > 0) {
$directDebitTransactionInformation->appendChild(
$this->getRemittenceElement($transactionInformation->getRemittanceInformation())
);
Expand Down
12 changes: 6 additions & 6 deletions tests/Functional/CustomerCreditValidationPain00100103Test.php
Expand Up @@ -34,6 +34,9 @@
*/
class CustomerCreditValidationPain00100103Test extends TestCase
{
/**
* @var string
*/
protected $schema;

/**
Expand All @@ -50,7 +53,7 @@ protected function setUp(): void
/**
* Sanity check: test reference file with XSD.
*/
public function testSanity()
public function testSanity(): void
{
$this->dom->load(__DIR__ . '/../fixtures/pain.001.001.03.xml');
$validated = $this->dom->schemaValidate($this->schema);
Expand All @@ -62,7 +65,7 @@ public function testSanity()
*
* @dataProvider scenarios
*/
public function testSinglePaymentSingleTransWithMoreInfo($scenario)
public function testSinglePaymentSingleTransWithMoreInfo(array $scenario): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$groupHeader->setInitiatingPartyId('XXXXXXXXXX');
Expand Down Expand Up @@ -97,10 +100,7 @@ public function testSinglePaymentSingleTransWithMoreInfo($scenario)
$this->assertTrue($validated);
}

/**
* @return array
*/
public function scenarios()
public function scenarios(): iterable
{
return array(
array(
Expand Down
61 changes: 15 additions & 46 deletions tests/Functional/CustomerCreditValidationTest.php
Expand Up @@ -51,11 +51,9 @@ protected function setUp(): void
/**
* Sanity check: test reference file with XSD.
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testSanity($schema)
public function testSanity(string $schema): void
{
$this->dom->load(__DIR__ . '/../fixtures/' . $schema . '.xml');
$validated = $this->dom->schemaValidate(__DIR__ . '/../fixtures/' . $schema . '.xsd');
Expand All @@ -66,11 +64,9 @@ public function testSanity($schema)
/**
* Test a transfer file with one payment and one transaction.
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testSinglePaymentSingleTrans($schema)
public function testSinglePaymentSingleTrans(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -101,11 +97,9 @@ public function testSinglePaymentSingleTrans($schema)
/**
* Test a transfer file with one payment and several transactions.
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testSinglePaymentMultiTrans($schema)
public function testSinglePaymentMultiTrans(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -135,11 +129,9 @@ public function testSinglePaymentMultiTrans($schema)
/**
* Test that a transferfile without Payments throws understandable exception
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testInvalidTransferFileThrowsException($schema)
public function testInvalidTransferFileThrowsException(string $schema): void
{
$this->expectException(InvalidTransferFileConfiguration::class);

Expand All @@ -153,11 +145,9 @@ public function testInvalidTransferFileThrowsException($schema)
/**
* Test correct calulation of controlsum and transaction count
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testControlSumAndTransactionCount($schema)
public function testControlSumAndTransactionCount(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -193,11 +183,9 @@ public function testControlSumAndTransactionCount($schema)
/**
* Test the payment informations in the xml
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testPaymentMetaData($schema)
public function testPaymentMetaData(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -241,11 +229,9 @@ public function testPaymentMetaData($schema)
/**
* Test the payment informations in the xml
*
* @param string[] $schema
*
* @dataProvider provideAddressTests
*/
public function testCreditorAddressGeneration(array $address)
public function testCreditorAddressGeneration(array $address): void
{
$schema = "pain.001.001.03"; // Addresses are only supported using this pain format.

Expand Down Expand Up @@ -305,11 +291,9 @@ public function testCreditorAddressGeneration(array $address)
/**
* Test a transfer file with several payments, several transactions each.
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testMultiPaymentMultiTrans($schema)
public function testMultiPaymentMultiTrans(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -365,11 +349,9 @@ public function testMultiPaymentMultiTrans($schema)
/**
* Test the payment informations in the xml
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testUmlautConversion($schema)
public function testUmlautConversion(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Only A-Z without äöüßÄÖÜ initiatingPartyName');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -412,11 +394,9 @@ public function testUmlautConversion($schema)
* There are different representations possible for IsoDateTime:
* http://www.swift.com/assets/corporates/documents/business_areas/ebam_standards_mx/business/x68910b9357eed3cf49770d42b07d70f1.htm
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testSinglePaymentOtherCreationDateTimeFormat($schema)
public function testSinglePaymentOtherCreationDateTimeFormat(string $schema): void
{
$dateTimeFormat = 'Y-m-d\TH:i:s.000P';

Expand Down Expand Up @@ -456,11 +436,9 @@ public function testSinglePaymentOtherCreationDateTimeFormat($schema)
/**
* Test a transfer file with one payment without remittance information
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testSinglePaymentSingleTransWithoutRemitttanceInformation($schema)
public function testSinglePaymentSingleTransWithoutRemitttanceInformation(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -490,11 +468,9 @@ public function testSinglePaymentSingleTransWithoutRemitttanceInformation($schem
/**
* Test a transfer file with one payment without remittance information
*
* @param string $schema
*
* @dataProvider provideSchema
*/
public function testSinglePaymentSingleTransWithStructuredCreditorReference($schema)
public function testSinglePaymentSingleTransWithStructuredCreditorReference(string $schema): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerCreditTransferFile($groupHeader);
Expand Down Expand Up @@ -536,10 +512,7 @@ public function testSinglePaymentSingleTransWithStructuredCreditorReference($sch

}

/**
* @return array
*/
public function provideSchema()
public function provideSchema(): iterable
{
return array(
array("pain.001.001.03"),
Expand All @@ -548,15 +521,11 @@ public function provideSchema()
);
}

/**
* @return string[]
*/
public function provideAddressTests()
public function provideAddressTests(): iterable
{
return array(
array(array('CH', array('Teststreet 1', '21345 Somewhere'))),
array(array(null, array('Teststreet 2', null))),
array(array('DE', array('Teststreet 3'))),
array(array('DE', array('Teststreet 2'))),
array(array('NL', '21456 Rightthere')),
array(array('NL', array())),
);
Expand Down
Expand Up @@ -32,6 +32,9 @@

class CustomerDirectDebitValidationPain00800302Test extends TestCase
{
/**
* @var string
*/
protected $schema;

/**
Expand All @@ -48,7 +51,7 @@ protected function setUp(): void
/**
* Sanity check: test reference file with XSD.
*/
public function testSanity()
public function testSanity(): void
{
$this->dom->load(__DIR__ . '/../fixtures/pain.008.003.02.xml');
$validated = $this->dom->schemaValidate($this->schema);
Expand All @@ -58,7 +61,7 @@ public function testSanity()
/**
* Test a Transfer file with one payment and one transaction without BIC provided
*/
public function test_given_country_is_returned_For_path()
public function testGivenCountryIsReturnedForPath(): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerDirectDebitTransferFile($groupHeader);
Expand Down Expand Up @@ -104,7 +107,7 @@ public function test_given_country_is_returned_For_path()
/**
* Test a Transfer file with one payment and one transaction without BIC provided
*/
public function test_multiple_address_lines_are_added_with_array()
public function testMultipleAddressLinesAreAddedWithArray(): void
{
$groupHeader = new GroupHeader('transferID', 'Me');
$sepaFile = new CustomerDirectDebitTransferFile($groupHeader);
Expand Down Expand Up @@ -145,7 +148,7 @@ public function test_multiple_address_lines_are_added_with_array()
$this->assertTrue($validated);
}

public function testValidationFailureSeqType()
public function testValidationFailureSeqType(): void
{
$this->expectException(InvalidTransferFileConfiguration::class);
$this->expectExceptionMessage('Payment must contain a SequenceType');
Expand All @@ -164,7 +167,7 @@ public function testValidationFailureSeqType()
$sepaFile->accept($domBuilder);
}

public function testValidationFailureCreditorId()
public function testValidationFailureCreditorId(): void
{
$this->expectException(InvalidTransferFileConfiguration::class);
$this->expectExceptionMessage('Payment must contain a CreditorSchemeId');
Expand Down

0 comments on commit 1105288

Please sign in to comment.