File size: 1,531 Bytes
c938f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

/**
 * Matomo - free/libre analytics platform
 *
 * @link    https://matomo.org
 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

declare(strict_types=1);

namespace Piwik\Plugins\BotTracking\tests\Unit;

use PHPUnit\Framework\TestCase;
use Piwik\Plugins\BotTracking\BotTrackingMethod\BotTrackingMethodAbstract;
use Piwik\Plugins\BotTracking\BotTrackingMethod\Cloudflare;
use Piwik\Plugins\BotTracking\BotTrackingMethod\AmazonCloudFront;
use Piwik\Plugins\BotTracking\BotTrackingMethod\HttpTrackingApi;
use Piwik\Plugins\BotTracking\BotTrackingMethod\MissingOneContactUs;
use Piwik\Plugins\BotTracking\BotTrackingMethod\WordPress;

/**
 * @group BotTracking
 * @group BotTrackingMethod
 * @group Plugins
 */
class BotTrackingMethodTest extends TestCase
{
    /**
     * @dataProvider getBotTrackingMethods
     *
     * @param class-string<BotTrackingMethodAbstract> $method
     */
    public function testSiteContentDetectionSourceExists(string $method): void
    {
        // sanity check to prevent a site content detection
        // class going away without being noticed
        $detectionId = $method::getSiteContentDetectionId();
        self::assertTrue($detectionId === null || is_string($detectionId));
    }

    public function getBotTrackingMethods(): array
    {
        return [
            [AmazonCloudFront::class],
            [Cloudflare::class],
            [HttpTrackingApi::class],
            [MissingOneContactUs::class],
            [WordPress::class],
        ];
    }
}