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

InfoTest.php « Commands « tests « CustomDimensions « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad47473fea986c39c10461fbc10f6efd54488ed7 (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
/**
 * 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\Plugins\CustomDimensions\tests\Commands;

use Piwik\Plugins\CustomDimensions\Commands\Info;
use Piwik\Plugins\CustomDimensions\CustomDimensions;
use Piwik\Plugins\CustomDimensions\Dao\LogTable;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;

/**
 * @group CustomDimensions
 * @group CustomDimensionsTest
 * @group Plugins
 * @group Plugins
 */
class InfoTest extends IntegrationTestCase
{
    public function testExecute_ShouldOutputInfoSuccess_IfEverythingIsOk()
    {
        $output = $this->executeCommand();

        self::assertStringContainsString('./console customdimensions:add-custom-dimension --scope=visit"
Installed indexes are:
1 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=visit --index=1
2 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=visit --index=2
3 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=visit --index=3
4 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=visit --index=4
5 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=visit --index=5

5 Custom Dimensions available in scope "action"
To add a Custom Dimension execute "./console customdimensions:add-custom-dimension --scope=action"
Installed indexes are:
1 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=action --index=1
2 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=action --index=2
3 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=action --index=3
4 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=action --index=4
5 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=action --index=5

5 Custom Dimensions available in scope "conversion"
Custom Dimensions are automatically added via the scope "visit" and cannot be added manually
Installed indexes are:
1 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=conversion --index=1
2 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=conversion --index=2
3 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=conversion --index=3
4 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=conversion --index=4
5 to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=conversion --index=5',
        $output);
    }

    public function testExecute_ShouldOutputErrorMessage_IfColumnsDoNotMatch()
    {
        $model = new LogTable(CustomDimensions::SCOPE_CONVERSION);
        $model->removeCustomDimension(5);

        self::assertStringContainsString('We found an error, Custom Dimensions in scope "conversion" are not correctly installed. Execute the following command to repair it:
./console customdimensions:add-custom-dimension --scope=conversion --count=1', $this->executeCommand());
    }

    private function executeCommand()
    {
        $infoCmd = new Info();

        $application = new Application();
        $application->add($infoCmd);
        $commandTester = new CommandTester($infoCmd);

        $commandTester->execute(array('command' => $infoCmd->getName()));
        $result = $commandTester->getDisplay();

        return $result;
    }
}