Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CreateChanges.php « Fixtures « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6e60f0f2d7ad4522e2115a5a1374a3605007c62 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
namespace Piwik\Tests\Fixtures;

use Piwik\Changes\Model as ChangesModel;
use Piwik\Tests\Framework\Fixture;

class CreateChanges extends Fixture
{

    private $file;

    public function setUp(): void
    {
        parent::setUp();
        Fixture::createSuperUser();
        if (!self::siteCreated($idSite = 1)) {
            self::createWebsite('2021-01-01');
        }

        $this->file = PIWIK_DOCUMENT_ROOT . '/plugins/CoreAdminHome/changes.json';
        $this->createChanges();
    }

    public function tearDown(): void
    {
        parent::tearDown();
        self::cleanup();
    }

    protected function cleanup(): void
    {
        if (file_exists($this->file)) {
            unlink($this->file);
        }
    }

    private function createChanges()
    {

        $changes = [
            [
             'version' => '4.6.0b5',
             'title' => 'New feature x added',
             'description' => 'Now you can do a with b like this',
             'link_name' => 'For more information go here',
             'link' => 'https://www.matomo.org',
            ],
            [
             'version' => '4.5.0',
             'title' => 'New feature y added',
             'description' => 'Now you can do c with d like this',
            ],
            [
             'version' => '4.4.0',
             'title' => 'New feature z added',
             'description' => 'Now you can do e with f like this',
             'link_name' => 'For more information go here',
             'link' => 'https://www.matomo.org',
            ],
        ];

        $changes = array_reverse($changes);
        $changesModel = new ChangesModel();
        foreach ($changes as $change) {
            $changesModel->addChange('CoreHome', $change);
        }

    }
}