1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\DataFixtures; |
4
|
|
|
|
5
|
|
|
use App\Entity\PaymentOrder; |
6
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture; |
7
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
8
|
|
|
use Doctrine\Persistence\ObjectManager; |
9
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile; |
10
|
|
|
|
11
|
|
|
class PaymentOrderFixture extends Fixture |
12
|
|
|
{ |
13
|
|
|
protected $em; |
14
|
|
|
|
15
|
|
|
public function __construct(EntityManagerInterface $entityManager) |
16
|
|
|
{ |
17
|
|
|
$this->em = $entityManager; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function load(ObjectManager $manager) |
21
|
|
|
{ |
22
|
|
|
//Reset autoincrement |
23
|
|
|
$this->em->getConnection() |
|
|
|
|
24
|
|
|
->exec('ALTER TABLE `payment_orders` AUTO_INCREMENT = 1;'); |
25
|
|
|
//ALTER TABLE does an implicit commit and PHP 8 throws if commit is called later internally without active transactions |
26
|
|
|
$this->em->getConnection()->beginTransaction(); |
27
|
|
|
|
28
|
|
|
$payment_order = new PaymentOrder(); |
29
|
|
|
$payment_order->setFirstName('John'); |
30
|
|
|
$payment_order->setLastName('Doe'); |
31
|
|
|
$payment_order->setContactEmail('[email protected]'); |
32
|
|
|
$payment_order->setFundingId('M-123-2020'); |
33
|
|
|
$payment_order->setProjectName('Test'); |
34
|
|
|
$payment_order->setFsrKomResolution(true); |
35
|
|
|
$payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT3_REFERENCE)); |
36
|
|
|
$payment_order->setAmount(12340); |
37
|
|
|
$payment_order->setComment('Test'); |
38
|
|
|
$payment_order->setConfirm1Token(password_hash('token1', PASSWORD_DEFAULT)); |
39
|
|
|
$payment_order->setConfirm2Token(password_hash('token2', PASSWORD_DEFAULT)); |
40
|
|
|
$payment_order->getBankInfo() |
41
|
|
|
->setAccountOwner('John Doe'); |
42
|
|
|
$payment_order->getBankInfo() |
43
|
|
|
->setIban('DE98 5001 0517 4783 9248 44'); |
44
|
|
|
$payment_order->getBankInfo() |
45
|
|
|
->setStreet('Street 1'); |
46
|
|
|
$payment_order->getBankInfo() |
47
|
|
|
->setZipCode('12345'); |
48
|
|
|
$payment_order->getBankInfo() |
49
|
|
|
->setCity('Jena'); |
50
|
|
|
|
51
|
|
|
$this->addFiles($payment_order); |
52
|
|
|
$manager->persist($payment_order); |
53
|
|
|
|
54
|
|
|
$payment_order = new PaymentOrder(); |
55
|
|
|
$payment_order->setFirstName('John'); |
56
|
|
|
$payment_order->setLastName('Doe'); |
57
|
|
|
$payment_order->setContactEmail('[email protected]'); |
58
|
|
|
$payment_order->setFundingId(''); |
59
|
|
|
$payment_order->setProjectName('Test'); |
60
|
|
|
$payment_order->setFsrKomResolution(false); |
61
|
|
|
$payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT2_REFERENCE)); |
62
|
|
|
$payment_order->setAmount(12340); |
63
|
|
|
$payment_order->setComment('Test'); |
64
|
|
|
$payment_order->setConfirm1Token(password_hash('token1', PASSWORD_DEFAULT)); |
65
|
|
|
$payment_order->setConfirm2Token(null); |
66
|
|
|
$payment_order->getBankInfo() |
67
|
|
|
->setAccountOwner('John Doe'); |
68
|
|
|
$payment_order->getBankInfo() |
69
|
|
|
->setIban('DE98 5001 0517 4783 9248 44'); |
70
|
|
|
$payment_order->getBankInfo() |
71
|
|
|
->setStreet('Street 1'); |
72
|
|
|
$payment_order->getBankInfo() |
73
|
|
|
->setZipCode('12345'); |
74
|
|
|
$payment_order->getBankInfo() |
75
|
|
|
->setCity('Jena'); |
76
|
|
|
|
77
|
|
|
$this->addFiles($payment_order); |
78
|
|
|
$manager->persist($payment_order); |
79
|
|
|
|
80
|
|
|
$payment_order = new PaymentOrder(); |
81
|
|
|
$payment_order->setFirstName('John'); |
82
|
|
|
$payment_order->setLastName('Doe'); |
83
|
|
|
$payment_order->setContactEmail('[email protected]'); |
84
|
|
|
$payment_order->setFundingId(''); |
85
|
|
|
$payment_order->setProjectName('Test23'); |
86
|
|
|
$payment_order->setFsrKomResolution(false); |
87
|
|
|
$payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT4_REFERENCE)); |
88
|
|
|
$payment_order->setAmount(100); |
89
|
|
|
$payment_order->setComment('Test'); |
90
|
|
|
$payment_order->getBankInfo() |
91
|
|
|
->setAccountOwner('John Doe'); |
92
|
|
|
$payment_order->getBankInfo() |
93
|
|
|
->setIban('DE98500105174783924844'); |
94
|
|
|
$payment_order->getBankInfo() |
95
|
|
|
->setBic('INGDDEFFXXX'); |
96
|
|
|
$payment_order->getBankInfo() |
97
|
|
|
->setStreet('Street 1'); |
98
|
|
|
$payment_order->getBankInfo() |
99
|
|
|
->setZipCode('12345'); |
100
|
|
|
$payment_order->getBankInfo() |
101
|
|
|
->setCity('Jena'); |
102
|
|
|
|
103
|
|
|
$this->addFiles($payment_order); |
104
|
|
|
$manager->persist($payment_order); |
105
|
|
|
|
106
|
|
|
$payment_order = new PaymentOrder(); |
107
|
|
|
$payment_order->setFirstName('John'); |
108
|
|
|
$payment_order->setLastName('Doe'); |
109
|
|
|
$payment_order->setContactEmail('[email protected]'); |
110
|
|
|
$payment_order->setFundingId(''); |
111
|
|
|
$payment_order->setProjectName('Test23'); |
112
|
|
|
$payment_order->setFsrKomResolution(true); |
113
|
|
|
$payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT5_REFERENCE)); |
114
|
|
|
$payment_order->setAmount(10000); |
115
|
|
|
$payment_order->setComment(''); |
116
|
|
|
$payment_order->getBankInfo() |
117
|
|
|
->setAccountOwner('John Doe'); |
118
|
|
|
$payment_order->getBankInfo() |
119
|
|
|
->setIban('DE98 5001 0517 4783 9248 44'); |
120
|
|
|
$payment_order->getBankInfo() |
121
|
|
|
->setStreet('Street 1'); |
122
|
|
|
$payment_order->getBankInfo() |
123
|
|
|
->setZipCode('12345'); |
124
|
|
|
$payment_order->getBankInfo() |
125
|
|
|
->setCity('Jena'); |
126
|
|
|
|
127
|
|
|
$this->addFiles($payment_order); |
128
|
|
|
$manager->persist($payment_order); |
129
|
|
|
|
130
|
|
|
$manager->flush(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
private function addFiles(PaymentOrder $paymentOrder): void |
134
|
|
|
{ |
135
|
|
|
$source_file = realpath(__DIR__.'/../../tests/data/form/upload.pdf'); |
136
|
|
|
//We have to create a copy of our source, or the file will be deleted when the files are uploaded... |
137
|
|
|
$target_file = tempnam(sys_get_temp_dir(), 'stura'); |
138
|
|
|
copy($source_file, $target_file); |
139
|
|
|
|
140
|
|
|
$file = new UploadedFile($target_file, 'form.pdf', null, null, true); |
141
|
|
|
$paymentOrder->setPrintedFormFile($file); |
142
|
|
|
|
143
|
|
|
//Do the same thing for References |
144
|
|
|
|
145
|
|
|
$source_file = realpath(__DIR__.'/../../tests/data/form/upload.pdf'); |
146
|
|
|
//We have to create a copy of our source, or the file will be deleted when the files are uploaded... |
147
|
|
|
$target_file = tempnam(sys_get_temp_dir(), 'stura'); |
148
|
|
|
copy($source_file, $target_file); |
149
|
|
|
|
150
|
|
|
$file = new UploadedFile($target_file, 'form.pdf', null, null, true); |
151
|
|
|
$paymentOrder->setReferencesFile($file); |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.