File size: 2,091 Bytes
bf8c0ce | 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 76 77 78 79 80 81 | <?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\WidgetsProvider;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Piwik\Widget\WidgetConfig;
use Piwik\Widget\WidgetContainerConfig;
/**
* @group WidgetsProvider
* @group WidgetsProviderTest
*/
class WidgetsProviderTest extends IntegrationTestCase
{
/**
* @var WidgetsProvider
*/
private $widgets;
public function setUp(): void
{
parent::setUp();
$_GET['idSite'] = 1;
if (!Fixture::siteCreated(1)) {
Fixture::createWebsite('2015-01-01 00:00:00');
}
$this->widgets = new WidgetsProvider(StaticContainer::get('Piwik\Plugin\Manager'));
}
public function tearDown(): void
{
parent::tearDown();
unset($_GET['idSite']);
}
public function testGetWidgetContainerConfigsShouldOnlyFindWidgetContainerConfigs()
{
$configs = $this->widgets->getWidgetContainerConfigs();
$this->assertGreaterThanOrEqual(3, count($configs));
foreach ($configs as $config) {
$this->assertTrue($config instanceof WidgetContainerConfig);
}
}
public function testGetWidgetConfigsShouldFindWidgetConfigs()
{
$configs = $this->widgets->getWidgetConfigs();
$this->assertGreaterThanOrEqual(10, count($configs));
foreach ($configs as $config) {
$this->assertTrue($config instanceof WidgetConfig);
$this->assertFalse($config instanceof WidgetContainerConfig);
}
}
public function testGetWidgetConfigsShouldSetModuleAndActionForEachConfig()
{
$configs = $this->widgets->getWidgetConfigs();
foreach ($configs as $config) {
$this->assertNotEmpty($config->getModule());
$this->assertNotEmpty($config->getAction());
}
}
}
|