EnableCheckTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 34
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A data() 0 6 1
A testConfiguration() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lochmueller\LanguageDetection\Tests\Unit\Check;
6
7
use Lochmueller\LanguageDetection\Check\EnableCheck;
8
use Lochmueller\LanguageDetection\Event\CheckLanguageDetectionEvent;
9
use Lochmueller\LanguageDetection\Service\SiteConfigurationService;
10
use Lochmueller\LanguageDetection\Tests\Unit\AbstractUnitTest;
11
use Psr\Http\Message\ServerRequestInterface;
12
use TYPO3\CMS\Core\Site\Entity\Site;
13
14
/**
15
 * @internal
16
 *
17
 * @coversNothing
18
 */
19
class EnableCheckTest extends AbstractUnitTest
20
{
21
    /**
22
     * @covers \Lochmueller\LanguageDetection\Check\EnableCheck
23
     * @covers \Lochmueller\LanguageDetection\Domain\Model\Dto\SiteConfiguration
24
     * @covers \Lochmueller\LanguageDetection\Event\CheckLanguageDetectionEvent
25
     * @covers \Lochmueller\LanguageDetection\Service\SiteConfigurationService
26
     *
27
     * @dataProvider data
28
     *
29
     * @param array<string, bool>|array<string, false>|mixed[] $configuration
30
     */
31
    public function testConfiguration(array $configuration, bool $result): void
32
    {
33
        $site = $this->createStub(Site::class);
34
        $site->method('getConfiguration')->willReturn($configuration);
35
        $request = $this->createMock(ServerRequestInterface::class);
36
        $event = new CheckLanguageDetectionEvent($site, $request);
37
38
        $enableCheck = new EnableCheck(new SiteConfigurationService());
39
        $enableCheck($event);
40
41
        self::assertEquals($result, $event->isLanguageDetectionEnable());
42
    }
43
44
    /**
45
     * @return array<string, mixed[]>
46
     */
47
    public static function data(): array
48
    {
49
        return [
50
            'Explicit enabled' => [['enableLanguageDetection' => true], true],
51
            'Explicit disabled' => [['enableLanguageDetection' => false], false],
52
            'Without configuration' => [[], true],
53
        ];
54
    }
55
}
56