LTSVersionServiceTest.php 4.93 KB
Newer Older
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
<?php
namespace T3o\TerFe2\Tests\Service;

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

use Nimut\TestingFramework\TestCase\UnitTestCase;
use T3o\TerFe2\Service\LTSVersionService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
 * Class LTSVersionService
 */
class LTSVersionServiceTest extends UnitTestCase
{

    /**
     * @var LTSVersionService
     */
    protected $subject;

    protected function setUp()
    {
        $this->subject = GeneralUtility::makeInstance(LTSVersionService::class);
35
        $this->subject->coreData = $this->getSampleData();
36 37 38 39 40 41 42
    }

    /**
     * @test
     */
    public function getCurrentStableVersions()
    {
43 44 45 46 47 48 49 50 51
        self::assertSame([8, 9], $this->subject->getCurrentStableVersions());
    }

    /**
     * @test
     */
    public function getCurrentStableVersionsAsFullVersionNumber()
    {
        self::assertSame([8007009, 9005005], $this->subject->getCurrentStableVersions(true));
52 53 54 55 56 57 58
    }

    /**
     * @test
     */
    public function getAllMaintainedVersions()
    {
59 60 61 62 63 64 65 66 67
        self::assertSame([8, 9, 10], $this->subject->getAllMaintainedVersions());
    }

    /**
     * @test
     */
    public function getAllMaintainedVersionsAsFullVersionNumber()
    {
        self::assertSame([8007009, 9005005, 10000000], $this->subject->getAllMaintainedVersions(true));
68 69 70 71 72 73 74
    }

    /**
     * @test
     */
    public function getLatestVersionOfRelease()
    {
75
        self::assertSame('7.6.21', $this->subject->getLatestVersionOfRelease(7));
76 77 78 79 80 81 82
    }

    /**
     * @test
     */
    public function getLatestDevelopmentVersion()
    {
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
        self::assertSame(10, $this->subject->getLatestDevelopmentVersion());
    }

    /**
     * @test
     */
    public function getLatestDevelopmentVersionAsFullVersionNumber()
    {
        self::assertSame(10000000, $this->subject->getLatestDevelopmentVersion(true));
    }

    /**
     * @test
     */
    public function getAllLTSVersionsAsFullVersionNumber()
    {
        self::assertSame(
            [
                4005000,
                6002000,
                7006000,
                8007000,
                9005000
            ],
            $this->subject->getAllLTSVersions()
        );
    }

    /**
     * @test
     */
    public function getOldLTSVersionsAsFullVersionNumber()
    {
        self::assertSame(
            [
                4005000,
                6002000,
                7006000
            ],
            $this->subject->getOldLTSVersions()
        );
    }

    /**
     * @test
     */
    public function getVersionLabelOfNewVersion()
    {
        self::assertSame(
            '8',
            $this->subject->getVersionLabelOfRelease(8007004)
        );
    }

    /**
     * @test
     */
    public function getVersionLabelOfLegacyVersion()
    {
        self::assertSame(
            '4.5',
            $this->subject->getVersionLabelOfRelease(4005031)
        );
146 147 148 149 150 151 152 153 154 155
    }

    /**
     * Return Sample Json Data for testing purpose
     *
     * @return array
     */
    private function getSampleData()
    {
        $versions = [
156 157
            7 => [
                'latest' => '7.6.25',
158
                'releases' => [
159
                    '7.6.21' => [
160 161
                        'version' => '7.6.21'
                    ],
162
                    '7.6.20' => [
163 164
                        'version' => '7.6.20'
                    ],
165
                    '7.6.19' => [
166 167 168 169
                        'version' => '7.6.19'
                    ],
                ]
            ],
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
            8 => [
                'latest' => '8.7.9',
                'releases' => [
                    '8.7.9' => [
                        'version' => '8.7.9'
                    ],
                    '8.7.8' => [
                        'version' => '8.7.8'
                    ],
                    '8.7.7' => [
                        'version' => '8.7.7'
                    ],
                ]
            ],
            9 => [
                'latest' => '9.5.5',
                'releases' => [
                    '9.5.5' => [
                        'version' => '9.5.5'
                    ],
                    '9.5.4' => [
                        'version' => '9.5.4'
                    ]
                ]
            ],
            10 => [
                'latest' => '10.0.0'
            ],
            '6.2' => [
                'latest' => '6.2.31'
            ],
            '4.5' => [
                'latest' => '4.5.40'
            ],
            'latest_stable' => '10.0.0',
            'latest_old_stable' => '9.5.5',
            'latest_lts' => '9.5.5',
            'latest_old_lts' => '8.7.9'
208 209 210 211
        ];

        return $versions;
    }
212
}