3
3
namespace Sprain \Tests \SwissQrBill \Constraints ;
4
4
5
5
use PHPUnit \Framework \Attributes \DataProvider ;
6
- use DG \BypassFinals ;
7
6
use Sprain \SwissQrBill \Constraint \ValidCreditorInformationPaymentReferenceCombination ;
8
7
use Sprain \SwissQrBill \Constraint \ValidCreditorInformationPaymentReferenceCombinationValidator ;
9
8
use Sprain \SwissQrBill \DataGroup \Element \CreditorInformation ;
@@ -34,59 +33,59 @@ public function testRandomClassIsValid()
34
33
}
35
34
36
35
#[DataProvider('emptyQrBillMocksProvider ' )]
37
- public function testEmptyQrBillValuesAreValid (QrBill $ qrBillMock )
36
+ public function testEmptyQrBillValuesAreValid (bool $ createCreditorInformationMock , bool $ createPaymentReferenceMock )
38
37
{
38
+ $ qrBillMock = $ this ->getQrBillMock (
39
+ ($ createCreditorInformationMock ) ? $ this ->getCreditorInformationMock () : null ,
40
+ ($ createPaymentReferenceMock ) ? $ this ->getPaymentReferenceMock () : null ,
41
+ );
42
+
39
43
$ this ->validator ->validate ($ qrBillMock , new ValidCreditorInformationPaymentReferenceCombination ());
40
44
41
45
$ this ->assertNoViolation ();
42
46
}
43
47
44
- public function emptyQrBillMocksProvider (): array
48
+ public static function emptyQrBillMocksProvider (): array
45
49
{
46
- BypassFinals::enable ();
47
-
48
50
return [
49
- [$ this ->getQrBillMock ()],
50
- [$ this ->getQrBillMock (
51
- $ this ->getCreditorInformationMock (),
52
- null
53
- )],
54
- [$ this ->getQrBillMock (
55
- null ,
56
- $ this ->getPaymentReferenceMock ()
57
- )]
51
+ // createCreditorInformationMock, createPaymentReferenceMock
52
+ [false , false ,],
53
+ [true , false ,],
54
+ [false , true ,],
58
55
];
59
56
}
60
57
61
58
#[DataProvider('validCombinationsQrBillMocksProvider ' )]
62
- public function testValidCombinations (QrBill $ qrBillMock )
59
+ public function testValidCombinations (bool $ containsQrIban , string $ paymentReferenceType )
63
60
{
61
+ $ qrBillMock = $ this ->getQrBillMock (
62
+ $ this ->getCreditorInformationMock ('any-iban ' , $ containsQrIban ),
63
+ $ this ->getPaymentReferenceMock ($ paymentReferenceType )
64
+ );
65
+
64
66
$ this ->validator ->validate ($ qrBillMock , new ValidCreditorInformationPaymentReferenceCombination ());
65
67
66
68
$ this ->assertNoViolation ();
67
69
}
68
70
69
- public function validCombinationsQrBillMocksProvider (): array
71
+ public static function validCombinationsQrBillMocksProvider (): array
70
72
{
71
73
return [
72
- [$ this ->getQrBillMock (
73
- $ this ->getCreditorInformationMock ('any-iban ' , true ),
74
- $ this ->getPaymentReferenceMock (PaymentReference::TYPE_QR )
75
- )],
76
- [$ this ->getQrBillMock (
77
- $ this ->getCreditorInformationMock ('any-iban ' , false ),
78
- $ this ->getPaymentReferenceMock (PaymentReference::TYPE_SCOR )
79
- )],
80
- [$ this ->getQrBillMock (
81
- $ this ->getCreditorInformationMock ('any-iban ' , false ),
82
- $ this ->getPaymentReferenceMock (PaymentReference::TYPE_NON )
83
- )],
74
+ // containsQrIban, paymentReferenceType
75
+ [true , PaymentReference::TYPE_QR ,],
76
+ [false , PaymentReference::TYPE_SCOR ,],
77
+ [false , PaymentReference::TYPE_NON ,],
84
78
];
85
79
}
86
80
87
81
#[DataProvider('invalidCombinationsQrBillMocksProvider ' )]
88
- public function testInvalidCombinations (QrBill $ qrBillMock )
82
+ public function testInvalidCombinations (bool $ containsQrIban , string $ paymentReferenceType )
89
83
{
84
+ $ qrBillMock = $ this ->getQrBillMock (
85
+ $ this ->getCreditorInformationMock ('any-iban ' , $ containsQrIban ),
86
+ $ this ->getPaymentReferenceMock ($ paymentReferenceType )
87
+ );
88
+
90
89
$ this ->validator ->validate ($ qrBillMock , new ValidCreditorInformationPaymentReferenceCombination ([
91
90
'message ' => 'myMessage ' ,
92
91
]));
@@ -97,21 +96,13 @@ public function testInvalidCombinations(QrBill $qrBillMock)
97
96
->assertRaised ();
98
97
}
99
98
100
- public function invalidCombinationsQrBillMocksProvider (): array
99
+ public static function invalidCombinationsQrBillMocksProvider (): array
101
100
{
102
101
return [
103
- [$ this ->getQrBillMock (
104
- $ this ->getCreditorInformationMock ('any-iban ' , false ),
105
- $ this ->getPaymentReferenceMock (PaymentReference::TYPE_QR )
106
- )],
107
- [$ this ->getQrBillMock (
108
- $ this ->getCreditorInformationMock ('any-iban ' , true ),
109
- $ this ->getPaymentReferenceMock (PaymentReference::TYPE_SCOR )
110
- )],
111
- [$ this ->getQrBillMock (
112
- $ this ->getCreditorInformationMock ('any-iban ' , true ),
113
- $ this ->getPaymentReferenceMock (PaymentReference::TYPE_NON )
114
- )],
102
+ // containsQrIban, paymentReferenceType
103
+ [false , PaymentReference::TYPE_QR ,],
104
+ [true , PaymentReference::TYPE_SCOR ,],
105
+ [true , PaymentReference::TYPE_NON ,],
115
106
];
116
107
}
117
108
0 commit comments