Skip to content

Commit 5a52ffe

Browse files
committed
Added fixtures for MyPaymentsOwed
1 parent 7398695 commit 5a52ffe

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\DataFixtures\Modules\Payments;
4+
5+
use App\DataFixtures\Providers\Modules\PaymentsOwed;
6+
use App\Entity\Modules\Payments\MyPaymentsOwed;
7+
use Doctrine\Bundle\FixturesBundle\Fixture;
8+
use Doctrine\Common\Persistence\ObjectManager;
9+
use Faker\Factory;
10+
11+
class MyPaymentsOwedFixtures extends Fixture
12+
{
13+
14+
/**
15+
* Factory $faker
16+
*/
17+
private $faker;
18+
19+
public function __construct() {
20+
$this->faker = Factory::create('en');
21+
}
22+
23+
public function load(ObjectManager $manager)
24+
{
25+
26+
foreach ( PaymentsOwed::ALL_OWED_MONEY as $data ) {
27+
28+
$target = $data[PaymentsOwed::KEY_TARGET];
29+
$amount = $data[PaymentsOwed::KEY_AMOUNT];
30+
$info = $data[PaymentsOwed::KEY_INFO];
31+
$date = $data[PaymentsOwed::KEY_DATE];
32+
$owed_by_me = $data[PaymentsOwed::KEY_OWED_BY_ME];
33+
34+
$money_owed = new MyPaymentsOwed();
35+
$money_owed->setTarget($target);
36+
$money_owed->setAmount($amount);
37+
$money_owed->setInformation($info);
38+
$money_owed->setDate($date);
39+
$money_owed->setOwedByMe($owed_by_me);
40+
41+
$manager->persist($money_owed);
42+
}
43+
44+
$manager->flush();
45+
}
46+
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace App\DataFixtures\Providers\Modules;
3+
4+
class PaymentsOwed {
5+
6+
const KEY_TARGET = 'target';
7+
const KEY_AMOUNT = 'amount';
8+
const KEY_OWED_BY_ME = 'owed_by_me';
9+
const KEY_INFO = 'information';
10+
const KEY_DATE = 'date';
11+
12+
const OWED_TARGET_ERLEN_SERVICE = 'Erlen Service';
13+
const OWED_TARGET_TOMASZ = 'Tomasz Skrzypczyk';
14+
const OWNED_TARGET_BART = 'Bart Ridneck';
15+
const OWNED_TARGET_RORONOA = 'Roronoa';
16+
17+
const ALL_OWED_MONEY = [
18+
[
19+
self::KEY_TARGET => self::OWED_TARGET_ERLEN_SERVICE,
20+
self::KEY_OWED_BY_ME => true,
21+
self::KEY_AMOUNT => 1500,
22+
self::KEY_INFO => 'For the laptop',
23+
self::KEY_DATE => '2017-05-03',
24+
],
25+
[
26+
self::KEY_TARGET => self::OWED_TARGET_TOMASZ,
27+
self::KEY_OWED_BY_ME => false,
28+
self::KEY_AMOUNT => 150,
29+
self::KEY_INFO => 'No idea, he just wanted to borrow',
30+
self::KEY_DATE => '2018-05-03',
31+
],
32+
[
33+
self::KEY_TARGET => self::OWNED_TARGET_BART,
34+
self::KEY_OWED_BY_ME => false,
35+
self::KEY_AMOUNT => 60,
36+
self::KEY_INFO => "Products that I've bought him on Ebay",
37+
self::KEY_DATE => '2018-05-03',
38+
],
39+
[
40+
self::KEY_TARGET => self::OWNED_TARGET_RORONOA,
41+
self::KEY_OWED_BY_ME => false,
42+
self::KEY_AMOUNT => 350,
43+
self::KEY_INFO => "Borrowed for mandate on highway",
44+
self::KEY_DATE => '2019-02-13',
45+
]
46+
];
47+
}

0 commit comments

Comments
 (0)