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

WidgetsTest.php « Plugin « Integration « PHPUnit « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 185faba06425f03ae8035a2c1e4453fd4a57e9ed (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
76
77
78
79
80
81
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

namespace Piwik\Tests\Integration\Plugin;

use Piwik\Container\StaticContainer;
use Piwik\Db;
use Piwik\Plugin\Widgets;
use Piwik\Settings\Storage;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
use Piwik\Widget\WidgetConfig;
use Piwik\Widget\WidgetContainerConfig;

/**
 * @group Widgets
 * @group WidgetsTest
 */
class WidgetsTest extends IntegrationTestCase
{
    /**
     * @var Widgets
     */
    private $widgets;

    public function setUp()
    {
        parent::setUp();

        $_GET['idSite'] = 1;
        if (!Fixture::siteCreated(1)) {
            Fixture::createWebsite('2015-01-01 00:00:00');
        }

        $this->widgets = new Widgets(StaticContainer::get('Piwik\Plugin\Manager'));
    }

    public function tearDown()
    {
        parent::tearDown();
        unset($_GET['idSite']);
    }

    public function test_getWidgetContainerConfigs_shouldOnlyFindWidgetContainerConfigs()
    {
        $configs = $this->widgets->getWidgetContainerConfigs();

        $this->assertGreaterThanOrEqual(3, count($configs));

        foreach ($configs as $config) {
            $this->assertTrue($config instanceof WidgetContainerConfig);
        }
    }

    public function test_getWidgetConfigs_shouldFindWidgetConfigs()
    {
        $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 test_getWidgetConfigs_shouldSetModuleAndActionForEachConfig()
    {
        $configs = $this->widgets->getWidgetConfigs();

        foreach ($configs as $config) {
            $this->assertNotEmpty($config->getModule());
            $this->assertNotEmpty($config->getAction());
        }
    }
}