Skip to content

Commit 88fbc46

Browse files
committed
Added test for Currency Admin Controller
1 parent 379155e commit 88fbc46

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/*
3+
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
4+
*
5+
* Copyright (C) 2019 - 2025 Jan Böhmer (https://github.com/jbtronics)
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as published
9+
* by the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
24+
namespace App\DataFixtures;
25+
26+
use App\Entity\PriceInformations\Currency;
27+
use Brick\Math\BigDecimal;
28+
use Doctrine\Bundle\FixturesBundle\Fixture;
29+
use Doctrine\Persistence\ObjectManager;
30+
31+
class CurrencyFixtures extends Fixture
32+
{
33+
public function load(ObjectManager $manager): void
34+
{
35+
$currency1 = new Currency();
36+
$currency1->setName('US-Dollar');
37+
$currency1->setIsoCode('USD');
38+
$manager->persist($currency1);
39+
40+
$currency2 = new Currency();
41+
$currency2->setName('Swiss Franc');
42+
$currency2->setIsoCode('CHF');
43+
$currency2->setExchangeRate(BigDecimal::of('0.91'));
44+
$manager->persist($currency2);
45+
46+
$currency3 = new Currency();
47+
$currency3->setName('Great British Pound');
48+
$currency3->setIsoCode('GBP');
49+
$currency3->setExchangeRate(BigDecimal::of('0.78'));
50+
$manager->persist($currency3);
51+
52+
$currency7 = new Currency();
53+
$currency7->setName('Test Currency with long name');
54+
$currency7->setIsoCode('CHY');
55+
$manager->persist($currency7);
56+
57+
$manager->flush();
58+
59+
60+
//Ensure that currency 7 gets ID 7
61+
$manager->getRepository(Currency::class)->changeID($currency7, 7);
62+
$manager->flush();
63+
}
64+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
4+
*
5+
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as published
9+
* by the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
namespace App\Tests\Controller\AdminPages;
24+
25+
use App\Entity\PriceInformations\Currency;
26+
use PHPUnit\Framework\Attributes\Group;
27+
use App\Entity\Parts\Manufacturer;
28+
29+
#[Group('slow')]
30+
#[Group('DB')]
31+
class CurrencyController extends AbstractAdminController
32+
{
33+
protected static string $base_path = '/en/currency';
34+
protected static string $entity_class = Currency::class;
35+
}

0 commit comments

Comments
 (0)