1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-24 16:07:37 +00:00
Files
matomo/tests/PHPUnit/Integration/Plugin/ReleaseChannelsTest.php
caddoo f25664cef6 Add preview release channel (#22205)
* Add preview release channel

* remove translator function for text that isn't shown in front end

* Update plugins/CoreUpdater/ReleaseChannel/LatestPreview.php

---------

Co-authored-by: Stefan Giehl <stefan@matomo.org>
2024-05-10 13:48:05 +02:00

101 خطوط
3.0 KiB
PHP

<?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\Tests\Integration\Plugin;
use Piwik\Container\StaticContainer;
use Piwik\Plugin;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Piwik\UpdateCheck\ReleaseChannel;
/**
* @group Plugin
* @group ReleaseChannels
* @group ReleaseChannelsTest
*/
class ReleaseChannelsTest extends IntegrationTestCase
{
/**
* @var Plugin\ReleaseChannels
*/
private $channels;
public function setUp(): void
{
parent::setUp();
if (!Fixture::siteCreated(1)) {
Fixture::createWebsite('2015-01-01 00:00:00');
}
$this->channels = new Plugin\ReleaseChannels(StaticContainer::get('Piwik\Plugin\Manager'));
}
public function testGetAllReleaseChannelsShouldFindAllAvailableRelaseChannels()
{
$channels = $this->channels->getAllReleaseChannels();
$this->assertCount(5, $channels);
foreach ($channels as $channel) {
$this->assertTrue($channel instanceof ReleaseChannel);
}
}
public function testGetAllReleaseChannelsShouldOrderChannelsByOrderId()
{
$channels = $this->channels->getAllReleaseChannels();
$lowest = 0;
foreach ($channels as $channel) {
$this->assertGreaterThanOrEqual($lowest, $channel->getOrder());
$lowest = $channel->getOrder();
}
// to make sure we actually went into the for loop...
$this->assertGreaterThan(0, $lowest);
}
/**
* @dataProvider getTestValidReleaseChannelIds
*/
public function testIsValidReleaseChannelIdShouldDetectIfReleaseChannelIsCorrectOrNot($expectedExists, $id)
{
$this->assertSame($expectedExists, $this->channels->isValidReleaseChannelId($id));
}
public function getTestValidReleaseChannelIds()
{
return array(
array($exists = true, $id = 'latest_stable'),
array($exists = true, $id = 'latest_beta'),
array($exists = true, $id = 'latest_5x_stable'),
array($exists = true, $id = 'latest_preview'),
array($exists = true, $id = 'laTest_stable'), // we do not check for exact match
array($exists = false, $id = ''),
array($exists = false, $id = 'latest'),
array($exists = false, $id = 'stable'),
array($exists = false, $id = 'lateststable'),
);
}
public function getTestActiveReleaseChannel()
{
return array(
array('latest_stable', 'latest_stable'),
array('latest_4x_stable', 'latest_5x_stable'),
array('latest_beta', 'latest_beta'),
array('latest_beta', 'latEst_betA'),
array('latest_stable', ''), // if nothing configured should return default (the one with lowest order)
array('latest_stable', 'latest'), // if invalid id configured should return default (the one with lowest order)
);
}
}