update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -0,0 +1,99 @@
|
|||
<?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\Plugins\Diagnostics\Test\Integration\Commands;
|
||||
|
||||
use Piwik\Tests\Fixtures\OneVisitorTwoVisits;
|
||||
use Piwik\Tests\Framework\TestCase\ConsoleCommandTestCase;
|
||||
use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
|
||||
|
||||
/**
|
||||
* TODO: This could be a unit test if we could inject the ArchiveTableDao in the command
|
||||
* @group AnalyzeArchiveTableTest
|
||||
*/
|
||||
class AnalyzeArchiveTableTest extends ConsoleCommandTestCase
|
||||
{
|
||||
/**
|
||||
* @var OneVisitorTwoVisits
|
||||
*/
|
||||
public static $fixture = null;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// make sure archiving is initiated so there is data in the archive tables
|
||||
VisitsSummaryAPI::getInstance()->get(self::$fixture->idSite, 'month', '2010-03-01');
|
||||
VisitsSummaryAPI::getInstance()->get(self::$fixture->idSite, 'month', '2010-03-01', 'browserCode==FF');
|
||||
VisitsSummaryAPI::getInstance()->get(self::$fixture->idSite, 'month', '2010-03-01', 'daysSinceFirstVisit==2');
|
||||
}
|
||||
|
||||
public function test_CommandOutput_IsAsExpected()
|
||||
{
|
||||
$expected = <<<OUTPUT
|
||||
Statistics for the archive_numeric_2010_03 and archive_blob_2010_03 tables:
|
||||
|
||||
+-------------------------------------------+------------+---------------+-------------+---------+-----------+----------------+-------------+
|
||||
| Group | # Archives | # Invalidated | # Temporary | # Error | # Segment | # Numeric Rows | # Blob Rows |
|
||||
+-------------------------------------------+------------+---------------+-------------+---------+-----------+----------------+-------------+
|
||||
| week[2010-03-01 - 2010-03-07] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 36 | 63 |
|
||||
| month[2010-03-01 - 2010-03-31] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 36 | 63 |
|
||||
| day[2010-03-03 - 2010-03-03] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-04 - 2010-03-04] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-05 - 2010-03-05] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-06 - 2010-03-06] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 36 | 51 |
|
||||
| day[2010-03-07 - 2010-03-07] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-08 - 2010-03-08] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| week[2010-03-08 - 2010-03-14] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-09 - 2010-03-09] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-10 - 2010-03-10] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-11 - 2010-03-11] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-12 - 2010-03-12] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-13 - 2010-03-13] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-14 - 2010-03-14] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-15 - 2010-03-15] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| week[2010-03-15 - 2010-03-21] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-16 - 2010-03-16] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-17 - 2010-03-17] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-18 - 2010-03-18] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-19 - 2010-03-19] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-20 - 2010-03-20] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-21 - 2010-03-21] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-22 - 2010-03-22] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| week[2010-03-22 - 2010-03-28] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-23 - 2010-03-23] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-24 - 2010-03-24] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-25 - 2010-03-25] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-26 - 2010-03-26] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-27 - 2010-03-27] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-28 - 2010-03-28] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-29 - 2010-03-29] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-30 - 2010-03-30] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
| day[2010-03-31 - 2010-03-31] idSite = 1 | 3 | 0 | 0 | 0 | 2 | 0 | 0 |
|
||||
+-------------------------------------------+------------+---------------+-------------+---------+-----------+----------------+-------------+
|
||||
|
||||
Total # Archives: 102
|
||||
Total # Invalidated Archives: 0
|
||||
Total # Temporary Archives: 0
|
||||
Total # Error Archives: 0
|
||||
Total # Segment Archives: 68
|
||||
|
||||
|
||||
OUTPUT;
|
||||
|
||||
$this->applicationTester->run(array(
|
||||
'command' => 'diagnostics:analyze-archive-table',
|
||||
'table-date' => '2010_03',
|
||||
));
|
||||
$actual = $this->applicationTester->getDisplay();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
||||
AnalyzeArchiveTableTest::$fixture = new OneVisitorTwoVisits();
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
<?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\Plugins\Diagnostics\Test\Integration\Commands;
|
||||
|
||||
use Piwik\Application\Kernel\GlobalSettingsProvider;
|
||||
use Piwik\Ini\IniReader;
|
||||
use Piwik\Plugins\Diagnostics\ConfigReader;
|
||||
use Piwik\Plugins\ExampleSettingsPlugin\Settings;
|
||||
use Piwik\Tests\Fixtures\OneVisitorTwoVisits;
|
||||
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
|
||||
|
||||
/**
|
||||
* TODO: This could be a unit test if we could inject the ArchiveTableDao in the command
|
||||
* @group Diagnostics
|
||||
* @group Plugins
|
||||
*/
|
||||
class ConfigReaderTest extends IntegrationTestCase
|
||||
{
|
||||
/**
|
||||
* @var ConfigReader
|
||||
*/
|
||||
private $configReader;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$settings = new GlobalSettingsProvider($this->configPath('global.ini.php'), $this->configPath('config.ini.php'), $this->configPath('common.config.ini.php'));
|
||||
$this->configReader = new ConfigReader($settings, new IniReader());
|
||||
}
|
||||
|
||||
public function test_getConfigValuesFromFiles()
|
||||
{
|
||||
$fileConfig = $this->configReader->getConfigValuesFromFiles();
|
||||
|
||||
$expected = array (
|
||||
'Category' =>
|
||||
array (
|
||||
'key1' =>
|
||||
array (
|
||||
'value' => 'value_overwritten',
|
||||
'description' => '',
|
||||
'isCustomValue' => true,
|
||||
'defaultValue' => 'value1',
|
||||
),
|
||||
'key2' =>
|
||||
array (
|
||||
'value' => 'valueCommon',
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => 'value2',
|
||||
),
|
||||
'key3' =>
|
||||
array (
|
||||
'value' => '${@piwik(crash))}',
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => NULL,
|
||||
),
|
||||
),
|
||||
'CategoryOnlyInGlobalFile' =>
|
||||
array (
|
||||
'key3' =>
|
||||
array (
|
||||
'value' => 'value3',
|
||||
'description' => 'test comment',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => 'value3',
|
||||
),
|
||||
'key4' =>
|
||||
array (
|
||||
'value' => 'value4',
|
||||
'description' => 'test comment 4',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => 'value4',
|
||||
),
|
||||
),
|
||||
'TestArray' =>
|
||||
array (
|
||||
'installed' =>
|
||||
array (
|
||||
'value' =>
|
||||
array (
|
||||
0 => 'plugin"1',
|
||||
1 => 'plugin2',
|
||||
2 => 'plugin3',
|
||||
),
|
||||
'description' => 'test comment 2
|
||||
with multiple lines',
|
||||
'isCustomValue' => true,
|
||||
'defaultValue' =>
|
||||
array (
|
||||
0 => 'plugin1',
|
||||
1 => 'plugin4',
|
||||
),
|
||||
),
|
||||
),
|
||||
'TestArrayOnlyInGlobalFile' =>
|
||||
array (
|
||||
'my_array' =>
|
||||
array (
|
||||
'value' =>
|
||||
array (
|
||||
0 => 'value1',
|
||||
1 => 'value2',
|
||||
),
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' =>
|
||||
array (
|
||||
0 => 'value1',
|
||||
1 => 'value2',
|
||||
),
|
||||
),
|
||||
),
|
||||
'GeneralSection' =>
|
||||
array (
|
||||
'password' =>
|
||||
array (
|
||||
'value' => '******',
|
||||
'description' => '',
|
||||
'isCustomValue' => true,
|
||||
'defaultValue' => NULL,
|
||||
),
|
||||
'login' =>
|
||||
array (
|
||||
'value' => 'tes"t',
|
||||
'description' => '',
|
||||
'isCustomValue' => true,
|
||||
'defaultValue' => NULL,
|
||||
),
|
||||
),
|
||||
'TestOnlyInCommon' =>
|
||||
array (
|
||||
'value' =>
|
||||
array (
|
||||
'value' => 'commonValue',
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => NULL,
|
||||
),
|
||||
),
|
||||
'Tracker' =>
|
||||
array (
|
||||
'commonConfigTracker' =>
|
||||
array (
|
||||
'value' => 'commonConfigTrackerValue',
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
$this->assertEquals($expected, $fileConfig);
|
||||
}
|
||||
|
||||
public function test_addConfigValuesFromPluginSettings()
|
||||
{
|
||||
$settings = new Settings();
|
||||
|
||||
$configValues = $this->configReader->addConfigValuesFromPluginSettings(array(), array($settings));
|
||||
|
||||
$expected = array (
|
||||
'ExampleSettingsPlugin' =>
|
||||
array (
|
||||
'metric' =>
|
||||
array (
|
||||
'value' => NULL,
|
||||
'description' => 'Choose the metric that should be displayed in the browser tab',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => 'nb_visits',
|
||||
),
|
||||
'browsers' =>
|
||||
array (
|
||||
'value' => NULL,
|
||||
'description' => 'The value will be only displayed in the following browsers',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' =>
|
||||
array (
|
||||
0 => 'firefox',
|
||||
1 => 'chromium',
|
||||
2 => 'safari',
|
||||
),
|
||||
),
|
||||
'description' =>
|
||||
array (
|
||||
'value' => NULL,
|
||||
'description' => 'This description will be displayed next to the value',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => 'This is the value:
|
||||
Another line',
|
||||
),
|
||||
'password' =>
|
||||
array (
|
||||
'value' => NULL,
|
||||
'description' => 'Password for the 3rd API where we fetch the value',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
$this->assertEquals($expected, $configValues);
|
||||
}
|
||||
|
||||
public function test_addConfigValuesFromPluginSettings_shouldAddDescriptionAndDefaultValueForExistingConfigValues()
|
||||
{
|
||||
$settings = new Settings();
|
||||
|
||||
$existing = array(
|
||||
'ExampleSettingsPlugin' =>
|
||||
array (
|
||||
'metric' =>
|
||||
array (
|
||||
'value' => NULL,
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => null,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$configValues = $this->configReader->addConfigValuesFromPluginSettings($existing, array($settings));
|
||||
|
||||
$this->assertSame('Choose the metric that should be displayed in the browser tab', $configValues['ExampleSettingsPlugin']['metric']['description']);
|
||||
$this->assertSame('nb_visits', $configValues['ExampleSettingsPlugin']['metric']['defaultValue']);
|
||||
}
|
||||
|
||||
public function test_addConfigValuesFromPluginSettings_shouldMaskValueIfTypeIsPassword()
|
||||
{
|
||||
$settings = new Settings();
|
||||
$settings->metric->uiControlType = Settings::CONTROL_PASSWORD;
|
||||
|
||||
$existing = array(
|
||||
'ExampleSettingsPlugin' =>
|
||||
array (
|
||||
'metric' =>
|
||||
array (
|
||||
'value' => 'test',
|
||||
'description' => '',
|
||||
'isCustomValue' => false,
|
||||
'defaultValue' => null,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$configValues = $this->configReader->addConfigValuesFromPluginSettings($existing, array($settings));
|
||||
|
||||
$this->assertSame('******', $configValues['ExampleSettingsPlugin']['metric']['value']);
|
||||
}
|
||||
|
||||
private function configPath($file)
|
||||
{
|
||||
return PIWIK_INCLUDE_PATH . '/tests/resources/Config/' . $file;
|
||||
}
|
||||
}
|
||||
|
||||
AnalyzeArchiveTableTest::$fixture = new OneVisitorTwoVisits();
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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\Plugins\Diagnostics\Test\Mock;
|
||||
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\Diagnostic;
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
|
||||
|
||||
class DiagnosticWithError implements Diagnostic
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
return array(
|
||||
DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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\Plugins\Diagnostics\Test\Mock;
|
||||
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\Diagnostic;
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
|
||||
|
||||
class DiagnosticWithSuccess implements Diagnostic
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
return array(
|
||||
DiagnosticResult::singleResult('Success', DiagnosticResult::STATUS_OK, 'Comment'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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\Plugins\Diagnostics\Test\Mock;
|
||||
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\Diagnostic;
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
|
||||
|
||||
class DiagnosticWithWarning implements Diagnostic
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
return array(
|
||||
DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?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\Plugins\Diagnostics\Test\Unit\Diagnostic;
|
||||
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResultItem;
|
||||
|
||||
class DiagnosticResultTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_getStatus_shouldReturnTheWorstStatus()
|
||||
{
|
||||
$result = new DiagnosticResult('Label');
|
||||
|
||||
$this->assertEquals(DiagnosticResult::STATUS_OK, $result->getStatus());
|
||||
|
||||
$result->addItem(new DiagnosticResultItem(DiagnosticResult::STATUS_WARNING));
|
||||
$this->assertEquals(DiagnosticResult::STATUS_WARNING, $result->getStatus());
|
||||
|
||||
$result->addItem(new DiagnosticResultItem(DiagnosticResult::STATUS_ERROR));
|
||||
$this->assertEquals(DiagnosticResult::STATUS_ERROR, $result->getStatus());
|
||||
}
|
||||
|
||||
public function test_singleResult_shouldReturnAResultWithASingleItem()
|
||||
{
|
||||
$result = DiagnosticResult::singleResult('Label', DiagnosticResult::STATUS_ERROR);
|
||||
|
||||
$this->assertInstanceOf('Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult', $result);
|
||||
$this->assertEquals('Label', $result->getLabel());
|
||||
$this->assertEquals(DiagnosticResult::STATUS_ERROR, $result->getStatus());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?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\Plugins\Diagnostics\Test\Unit;
|
||||
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
|
||||
use Piwik\Plugins\Diagnostics\DiagnosticReport;
|
||||
|
||||
class DiagnosticReportTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_shouldComputeErrorAndWarningCount()
|
||||
{
|
||||
$report = new DiagnosticReport(
|
||||
array(DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment')),
|
||||
array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment'))
|
||||
);
|
||||
|
||||
$this->assertEquals(1, $report->getErrorCount());
|
||||
$this->assertTrue($report->hasErrors());
|
||||
$this->assertEquals(1, $report->getWarningCount());
|
||||
$this->assertTrue($report->hasWarnings());
|
||||
|
||||
$report = new DiagnosticReport(array(), array());
|
||||
|
||||
$this->assertEquals(0, $report->getErrorCount());
|
||||
$this->assertFalse($report->hasErrors());
|
||||
$this->assertEquals(0, $report->getWarningCount());
|
||||
$this->assertFalse($report->hasWarnings());
|
||||
}
|
||||
|
||||
public function test_getAllResults()
|
||||
{
|
||||
$report = new DiagnosticReport(
|
||||
array(DiagnosticResult::singleResult('Error', DiagnosticResult::STATUS_ERROR, 'Comment')),
|
||||
array(DiagnosticResult::singleResult('Warning', DiagnosticResult::STATUS_WARNING, 'Comment'))
|
||||
);
|
||||
|
||||
$this->assertCount(1, $report->getMandatoryDiagnosticResults());
|
||||
$this->assertCount(1, $report->getOptionalDiagnosticResults());
|
||||
$this->assertCount(2, $report->getAllResults());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?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\Plugins\Diagnostics\Test\Unit;
|
||||
|
||||
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
|
||||
use Piwik\Plugins\Diagnostics\DiagnosticService;
|
||||
use Piwik\Plugins\Diagnostics\Test\Mock\DiagnosticWithError;
|
||||
use Piwik\Plugins\Diagnostics\Test\Mock\DiagnosticWithSuccess;
|
||||
use Piwik\Plugins\Diagnostics\Test\Mock\DiagnosticWithWarning;
|
||||
|
||||
class DiagnosticServiceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_runDiagnostics()
|
||||
{
|
||||
$mandatoryDiagnostics = array(
|
||||
new DiagnosticWithError(),
|
||||
);
|
||||
$optionalDiagnostics = array(
|
||||
new DiagnosticWithWarning(),
|
||||
new DiagnosticWithSuccess(),
|
||||
);
|
||||
|
||||
$service = new DiagnosticService($mandatoryDiagnostics, $optionalDiagnostics, array());
|
||||
|
||||
$report = $service->runDiagnostics();
|
||||
|
||||
$results = $report->getAllResults();
|
||||
|
||||
$this->assertCount(3, $results);
|
||||
$this->assertEquals('Error', $results[0]->getLabel());
|
||||
$this->assertEquals(DiagnosticResult::STATUS_ERROR, $results[0]->getStatus());
|
||||
$this->assertEquals('Warning', $results[1]->getLabel());
|
||||
$this->assertEquals(DiagnosticResult::STATUS_WARNING, $results[1]->getStatus());
|
||||
$this->assertEquals('Success', $results[2]->getLabel());
|
||||
$this->assertEquals(DiagnosticResult::STATUS_OK, $results[2]->getStatus());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue