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\Services\Parts; |
||
24 | |||
25 | use App\Entity\Parts\Part; |
||
26 | use App\Entity\PriceInformations\Orderdetail; |
||
27 | use App\Entity\PriceInformations\Pricedetail; |
||
28 | use App\Services\Formatters\AmountFormatter; |
||
29 | use App\Services\Parts\PricedetailHelper; |
||
30 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
||
31 | |||
32 | class PricedetailHelperTest extends WebTestCase |
||
33 | { |
||
34 | /** |
||
35 | * @var AmountFormatter |
||
36 | */ |
||
37 | protected $service; |
||
38 | |||
39 | protected function setUp(): void |
||
40 | { |
||
41 | parent::setUp(); |
||
42 | //Get an service instance. |
||
43 | self::bootKernel(); |
||
44 | $this->service = self::getContainer()->get(PricedetailHelper::class); |
||
45 | } |
||
46 | |||
47 | public function maxDiscountAmountDataProvider(): ?\Generator |
||
48 | { |
||
49 | $part = new Part(); |
||
50 | yield [$part, null, 'Part without any orderdetails failed!']; |
||
51 | |||
52 | //Part with empty orderdetails |
||
53 | $part = new Part(); |
||
54 | $orderdetail = new Orderdetail(); |
||
55 | $part->addOrderdetail($orderdetail); |
||
56 | yield [$part, null, 'Part with one empty orderdetail failed!']; |
||
57 | |||
58 | $part = new Part(); |
||
59 | $orderdetail = new Orderdetail(); |
||
60 | $part->addOrderdetail($orderdetail); |
||
61 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(1)); |
||
62 | yield [$part, 1.0, 'Part with one pricedetail failed!']; |
||
63 | |||
64 | $part = new Part(); |
||
65 | $orderdetail = new Orderdetail(); |
||
66 | $part->addOrderdetail($orderdetail); |
||
67 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(1)); |
||
68 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(2)); |
||
69 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(1.5)); |
||
70 | yield [$part, 2.0, 'Part with multiple pricedetails failed!']; |
||
71 | |||
72 | $part = new Part(); |
||
73 | $orderdetail = new Orderdetail(); |
||
74 | $orderdetail2 = new Orderdetail(); |
||
75 | $part->addOrderdetail($orderdetail); |
||
76 | $part->addOrderdetail($orderdetail2); |
||
77 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(1)); |
||
78 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(2)); |
||
79 | $orderdetail->addPricedetail((new Pricedetail())->setMinDiscountQuantity(1.5)); |
||
80 | $orderdetail2->addPricedetail((new Pricedetail())->setMinDiscountQuantity(10)); |
||
81 | |||
82 | yield [$part, 10.0, 'Part with multiple orderdetails failed']; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @dataProvider maxDiscountAmountDataProvider |
||
87 | */ |
||
88 | public function testGetMaxDiscountAmount(Part $part, ?float $expected_result, string $message): void |
||
89 | { |
||
90 | $this->assertSame($expected_result, $this->service->getMaxDiscountAmount($part), $message); |
||
0 ignored issues
–
show
|
|||
91 | } |
||
92 | } |
||
93 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.