<?php

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

namespace Piwik\Plugins\CorePluginsAdmin\tests\Fixtures;

use Piwik\Tests\Framework\Fixture;

/**
 * Fixture that fakes plugin updates to be available
 */
class PluginUpdatesFixture extends Fixture
{
    public $idSite = 1;
    public function setUp(): void
    {
        Fixture::createSuperUser();
        $this->setUpWebsites();
    }

    private function setUpWebsites()
    {
        if (!self::siteCreated($idSite = 1)) {
            self::createWebsite('2024-01-01');
        }
    }

    public function provideContainerConfig()
    {
        $updates = <<<JSON
{"DeviceDetectorCache":{"name":"DeviceDetectorCache","displayName":"Device Detector Cache","owner":"matomo-org","description":"Makes tracking faster by detecting many devices, operating systems, bots, and browsers from a cache.","homepage":"https:\/\/matomo.org","createdDateTime":"2019-10-23 20:14:04","donate":[],"support":[{"name":"Issues \/ Bugs","key":"issues","value":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/issues","type":"url"}],"isTheme":false,"keywords":["performance","tracking","device","detector"],"basePrice":0,"authors":[{"name":"Matomo","email":"hello@matomo.org","homepage":"https:\/\/matomo.org"}],"repositoryUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache","lastUpdated":"2024-04-22 05:58:02","latestVersion":"5.0.3","numDownloads":22896,"screenshots":[],"coverImage":"https:\/\/plugins.matomo.org\/img\/categories\/database.png","previews":[],"activity":{"numCommits":"148","numContributors":"20","lastCommitDate":"2024-08-15 06:18:49"},"featured":false,"isFree":true,"isPaid":false,"isBundle":false,"isCustomPlugin":false,"shop":null,"bundle":{"plugins":[]},"specialOffer":"","category":"database","versions":[{"name":"5.0.0","release":"2023-05-05 00:28:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":67,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.0\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.0-b1","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.0"},{"name":"5.0.1","release":"2023-10-03 04:32:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":96,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.1\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.1","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.1"},{"name":"5.0.2","release":"2023-11-21 00:40:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2058,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.2\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.2","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.2"},{"name":"5.0.3","release":"2024-04-22 05:58:02","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2403,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.3\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.3","readmeHtml":{"description":"Dummy Plugin Description"},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.3"}],"isDownloadable":true,"changelog":{"url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/changelog?matomoversion=5"},"consumer":{"license":null},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/compare\/5.0.2...5.0.3","currentVersion":"5.0.2","isActivated":false,"missingRequirements":[]},"QueuedTracking":{"name":"QueuedTracking","displayName":"Queued Tracking","owner":"matomo-org","description":"Scale your large traffic Matomo service by queuing tracking requests in Redis or MySQL for better performance and reliability when experiencing peaks.","homepage":"https:\/\/matomo.org","createdDateTime":"2015-01-05 23:28:04","donate":[],"support":[{"name":"Wiki","key":"wiki","value":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/wiki","type":"url"},{"name":"Forum","key":"forum","value":"https:\/\/forum.matomo.org","type":"url"},{"name":"Email","key":"email","value":"hello@matomo.org","type":"email"},{"name":"Issues \/ Bugs","key":"issues","value":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/issues","type":"url"},{"name":"Source","key":"source","value":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking","type":"url"}],"isTheme":false,"keywords":["tracker","tracking","queue","redis"],"basePrice":0,"authors":[{"name":"Matomo","email":"hello@matomo.org","homepage":"https:\/\/matomo.org"}],"repositoryUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking","lastUpdated":"2024-08-26 04:30:04","latestVersion":"5.0.7","numDownloads":603565,"screenshots":["https:\/\/plugins.matomo.org\/QueuedTracking\/images\/5.0.7\/Settings.png"],"coverImage":"https:\/\/plugins.matomo.org\/img\/categories\/development.png","previews":[],"activity":{"numCommits":"362","numContributors":"38","lastCommitDate":"2024-08-26 04:29:16"},"featured":false,"isFree":true,"isPaid":false,"isBundle":false,"isCustomPlugin":false,"shop":null,"bundle":{"plugins":[]},"specialOffer":"","category":"development","versions":[{"name":"5.0.0","release":"2023-05-05 05:36:06","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2237,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.0\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.0-b1","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.0"},{"name":"5.0.1","release":"2023-08-08 22:40:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":0,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.1\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.0-b2","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.1"},{"name":"5.0.2","release":"2023-08-09 02:24:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":107207,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.2\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.0-b2","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.2"},{"name":"5.0.3","release":"2024-03-11 04:08:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2329,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.3\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.3","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.3"},{"name":"5.0.4","release":"2024-04-22 07:14:04","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":3560,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.4\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.4","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.4"},{"name":"5.0.5","release":"2024-06-27 06:50:49","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":1305,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.5\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.5","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.5"},{"name":"5.0.6","release":"2024-07-31 02:46:04","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":1447,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.6\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.6","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.6"},{"name":"5.0.7","release":"2024-08-26 04:30:04","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":227,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.7\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.7","readmeHtml":{"description":"Dummy README content"},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.7"}],"isDownloadable":true,"changelog":{"url":"https:\/\/plugins.matomo.org\/QueuedTracking\/changelog?matomoversion=5"},"consumer":{"license":null},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/compare\/5.0.6...5.0.7","currentVersion":"5.0.6","isActivated":false,"missingRequirements":[{"requirement":"php","actualVersion":"7.2.24","requiredVersion":">=7.3.0","causedBy":">=7.3.0"}]}}
JSON;

        return [
            'dev.forced_plugin_update_result' => json_decode($updates, true),
        ];
    }
}
