Skip to content
Extraits de code Groupes Projets
Valider 63526ce1 rédigé par JulienMoumne's avatar JulienMoumne
Parcourir les fichiers

refs #3323 - include images in scheduled reports only if system under test...

refs #3323 - include images in scheduled reports only if system under test matches some technical characteristics of the Piwik QA Server

TODO
 * update method 'canImagesBeIncludedInScheduledReports' to match the new Piwik QA server when it will be up and running
 * build a vagrant VM with QA server specs, generate reports using it and override expected files

git-svn-id: http://dev.piwik.org/svn/trunk@6932 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 715d9303
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 20685 ajouts et 10244 suppressions
...@@ -22,7 +22,6 @@ class Test_Piwik_Integration_EcommerceOrderWithItems extends IntegrationTestCase ...@@ -22,7 +22,6 @@ class Test_Piwik_Integration_EcommerceOrderWithItems extends IntegrationTestCase
parent::setUpBeforeClass(); parent::setUpBeforeClass();
try { try {
self::setUpWebsitesAndGoals(); self::setUpWebsitesAndGoals();
self::setUpScheduledReports(self::$idSite);
self::trackVisits(); self::trackVisits();
} catch(Exception $e) { } catch(Exception $e) {
// Skip whole test suite if an error occurs while setup // Skip whole test suite if an error occurs while setup
...@@ -30,6 +29,11 @@ class Test_Piwik_Integration_EcommerceOrderWithItems extends IntegrationTestCase ...@@ -30,6 +29,11 @@ class Test_Piwik_Integration_EcommerceOrderWithItems extends IntegrationTestCase
} }
} }
public function testSetUpScheduledReports()
{
$this->setUpScheduledReports(self::$idSite);
}
/** /**
* @dataProvider getApiForTesting * @dataProvider getApiForTesting
* @group Integration * @group Integration
......
...@@ -30,7 +30,6 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ ...@@ -30,7 +30,6 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ
parent::setUpBeforeClass(); parent::setUpBeforeClass();
try { try {
self::setUpWebsitesAndGoals(); self::setUpWebsitesAndGoals();
self::setUpScheduledReports(self::$idSite1);
self::trackVisits(); self::trackVisits();
} catch(Exception $e) { } catch(Exception $e) {
// Skip whole test suite if an error occurs while setup // Skip whole test suite if an error occurs while setup
...@@ -38,6 +37,11 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ ...@@ -38,6 +37,11 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays extends Integ
} }
} }
public function testSetUpScheduledReports()
{
$this->setUpScheduledReports(self::$idSite1);
}
/** /**
* @dataProvider getApiForTesting * @dataProvider getApiForTesting
* @group Integration * @group Integration
......
...@@ -238,10 +238,18 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -238,10 +238,18 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
/** /**
* Create one MAIL and two MOBILE scheduled reports * Create one MAIL and two MOBILE scheduled reports
* *
* Reports sent by mail can contain PNG graphs when the user specifies it.
* Depending on the system under test, generated images differ slightly.
* Because of this discrepancy, PNG graphs are only tested if the system under test
* has the characteristics described in 'canImagesBeIncludedInScheduledReports'
*
* @see canImagesBeIncludedInScheduledReports
* @param int $idSite id of website created * @param int $idSite id of website created
*/ */
protected static function setUpScheduledReports($idSite) protected function setUpScheduledReports($idSite)
{ {
$includeImages = self::canImagesBeIncludedInScheduledReports();
// fake access is needed so API methods can call Piwik::getCurrentUserLogin(), e.g: 'PDFReports.addReport' // fake access is needed so API methods can call Piwik::getCurrentUserLogin(), e.g: 'PDFReports.addReport'
$pseudoMockAccess = new FakeAccess; $pseudoMockAccess = new FakeAccess;
FakeAccess::$superUser = true; FakeAccess::$superUser = true;
...@@ -256,6 +264,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -256,6 +264,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
$availableReportIds[] = $reportMetadata['uniqueId']; $availableReportIds[] = $reportMetadata['uniqueId'];
} }
//@review should we also test evolution graphs?
// set-up mail report // set-up mail report
Piwik_PDFReports_API::getInstance()->addReport( Piwik_PDFReports_API::getInstance()->addReport(
$idSite, $idSite,
...@@ -264,7 +273,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -264,7 +273,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
Piwik_PDFReports::EMAIL_TYPE, Piwik_PDFReports::EMAIL_TYPE,
Piwik_ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports() Piwik_ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
$availableReportIds, $availableReportIds,
array("displayFormat"=>Piwik_PDFReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS) array("displayFormat" => $includeImages ? Piwik_PDFReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS : Piwik_PDFReports::DISPLAY_FORMAT_TABLES_ONLY)
); );
// set-up sms report for one website // set-up sms report for one website
...@@ -288,6 +297,30 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -288,6 +297,30 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
array("MultiSites_getAll"), array("MultiSites_getAll"),
array("phoneNumbers"=>array()) array("phoneNumbers"=>array())
); );
if(!$includeImages)
{
$this->markTestSkipped(
'Do take note that scheduled reports are not being tested with images. ' .
'If images contained in scheduled reports have been altered, tests will fail on the Piwik QA Server. ' .
'To include images in the test suite, please use a machine with the following specifications :' // TODO update with new Piwik QA Server
);
}
}
/**
* Return true if system under test has the following characteristics :
* - // TODO update doc with new Piwik QA Server technical characteristics
*
*/
private static function canImagesBeIncludedInScheduledReports()
{
// TODO update to match new Piwik QA Server
$gdInfo = gd_info();
return
stristr(php_uname(),'Linux precise32') &&
phpversion() == '5.3.10-1ubuntu3.2' &&
$gdInfo['GD Version'] == '2.0';
} }
/** /**
...@@ -301,12 +334,14 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -301,12 +334,14 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
*/ */
protected static function getApiForTestingScheduledReports($dateTime, $period) protected static function getApiForTestingScheduledReports($dateTime, $period)
{ {
$reportContentPostfix = self::canImagesBeIncludedInScheduledReports() ? '_tables_and_graph' : '_tables_only';
return array( return array(
// HTML Scheduled Report // HTML Scheduled Report
array( array(
'PDFReports.generateReport', 'PDFReports.generateReport',
array( array(
'testSuffix' => '_scheduled_report_in_html', 'testSuffix' => '_scheduled_report_in_html' . $reportContentPostfix,
'date' => $dateTime, 'date' => $dateTime,
'periods' => array($period), 'periods' => array($period),
'format' => 'original', 'format' => 'original',
...@@ -322,7 +357,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase ...@@ -322,7 +357,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
array( array(
'PDFReports.generateReport', 'PDFReports.generateReport',
array( array(
'testSuffix' => '_scheduled_report_in_pdf', 'testSuffix' => '_scheduled_report_in_pdf' . $reportContentPostfix,
'date' => $dateTime, 'date' => $dateTime,
'periods' => array($period), 'periods' => array($period),
'format' => 'original', 'format' => 'original',
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter