Passed
Branch master (350f1b)
by Jan
04:53
created

AbstractElementProviderTest::testReplace()

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
7
 *
8
 * Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as published
12
 * by the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
22
 */
23
24
namespace App\Tests\Services\LabelSystem\PlaceholderProviders;
25
26
use App\Entity\Base\AbstractDBElement;
27
use App\Services\LabelSystem\PlaceholderProviders\AbstractDBElementProvider;
28
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
29
30
class AbstractElementProviderTest extends WebTestCase
31
{
32
    /**
33
     * @var AbstractDBElementProvider
34
     */
35
    protected $service;
36
37
    protected $target;
38
39
    protected function setUp(): void
40
    {
41
        self::bootKernel();
42
        $this->service = self::$container->get(AbstractDBElementProvider::class);
43
        $this->target = new class() extends AbstractDBElement {
44
            protected $id = 123;
45
        };
46
    }
47
48
    public function dataProvider(): array
49
    {
50
        return [
51
            ['123', '[[ID]]'],
52
        ];
53
    }
54
55
    /**
56
     * @dataProvider dataProvider
57
     */
58
    public function testReplace(string $expected, string $placeholder): void
59
    {
60
        $this->assertSame($expected, $this->service->replace($placeholder, $this->target));
61
    }
62
}
63