Skip to content

Commit 7056575

Browse files
committed
Migrated non-static DataProviders
1 parent 9f4c126 commit 7056575

File tree

4 files changed

+42
-47
lines changed

4 files changed

+42
-47
lines changed

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
displayDetailsOnTestsThatTriggerWarnings="true"
1010
displayDetailsOnPhpunitDeprecations="true"
1111
>
12+
<extensions>
13+
<bootstrap class="DG\BypassFinals\PHPUnitExtension"/>
14+
</extensions>
15+
1216
<php>
1317
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
1418
</php>

tests/Constraints/ValidCreditorInformationPaymentReferenceCombinationTest.php

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Sprain\Tests\SwissQrBill\Constraints;
44

55
use PHPUnit\Framework\Attributes\DataProvider;
6-
use DG\BypassFinals;
76
use Sprain\SwissQrBill\Constraint\ValidCreditorInformationPaymentReferenceCombination;
87
use Sprain\SwissQrBill\Constraint\ValidCreditorInformationPaymentReferenceCombinationValidator;
98
use Sprain\SwissQrBill\DataGroup\Element\CreditorInformation;
@@ -34,59 +33,59 @@ public function testRandomClassIsValid()
3433
}
3534

3635
#[DataProvider('emptyQrBillMocksProvider')]
37-
public function testEmptyQrBillValuesAreValid(QrBill $qrBillMock)
36+
public function testEmptyQrBillValuesAreValid(bool $createCreditorInformationMock, bool $createPaymentReferenceMock)
3837
{
38+
$qrBillMock = $this->getQrBillMock(
39+
($createCreditorInformationMock) ? $this->getCreditorInformationMock() : null,
40+
($createPaymentReferenceMock) ? $this->getPaymentReferenceMock() : null,
41+
);
42+
3943
$this->validator->validate($qrBillMock, new ValidCreditorInformationPaymentReferenceCombination());
4044

4145
$this->assertNoViolation();
4246
}
4347

44-
public function emptyQrBillMocksProvider(): array
48+
public static function emptyQrBillMocksProvider(): array
4549
{
46-
BypassFinals::enable();
47-
4850
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,],
5855
];
5956
}
6057

6158
#[DataProvider('validCombinationsQrBillMocksProvider')]
62-
public function testValidCombinations(QrBill $qrBillMock)
59+
public function testValidCombinations(bool $containsQrIban, string $paymentReferenceType)
6360
{
61+
$qrBillMock = $this->getQrBillMock(
62+
$this->getCreditorInformationMock('any-iban', $containsQrIban),
63+
$this->getPaymentReferenceMock($paymentReferenceType)
64+
);
65+
6466
$this->validator->validate($qrBillMock, new ValidCreditorInformationPaymentReferenceCombination());
6567

6668
$this->assertNoViolation();
6769
}
6870

69-
public function validCombinationsQrBillMocksProvider(): array
71+
public static function validCombinationsQrBillMocksProvider(): array
7072
{
7173
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,],
8478
];
8579
}
8680

8781
#[DataProvider('invalidCombinationsQrBillMocksProvider')]
88-
public function testInvalidCombinations(QrBill $qrBillMock)
82+
public function testInvalidCombinations(bool $containsQrIban, string $paymentReferenceType)
8983
{
84+
$qrBillMock = $this->getQrBillMock(
85+
$this->getCreditorInformationMock('any-iban', $containsQrIban),
86+
$this->getPaymentReferenceMock($paymentReferenceType)
87+
);
88+
9089
$this->validator->validate($qrBillMock, new ValidCreditorInformationPaymentReferenceCombination([
9190
'message' => 'myMessage',
9291
]));
@@ -97,21 +96,13 @@ public function testInvalidCombinations(QrBill $qrBillMock)
9796
->assertRaised();
9897
}
9998

100-
public function invalidCombinationsQrBillMocksProvider(): array
99+
public static function invalidCombinationsQrBillMocksProvider(): array
101100
{
102101
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,],
115106
];
116107
}
117108

tests/QrCode/QrCodeTest.php

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

tests/TestCompactSvgQrCodeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
trait TestCompactSvgQrCodeTrait
66
{
7-
public function getCompact(): string
7+
public static function getCompact(): string
88
{
99
if (defined('Endroid\QrCode\Writer\SvgWriter::WRITER_OPTION_COMPACT')) {
1010
return '-compact';

0 commit comments

Comments
 (0)