Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run UI tests on PHP 5.4 in Piwik 3.0 branch #8452

Merged
merged 4 commits into from
Jul 29, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ language: php

php:
- 5.6
- 5.3.3
- 5.4
# - hhvm

services:
Expand Down Expand Up @@ -44,37 +44,37 @@ matrix:
- php: hhvm
exclude:
# Run test suites separately only on PHP 5.6 with PDO
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=SystemTests MYSQL_ADAPTER=PDO_MYSQL
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=IntegrationTests MYSQL_ADAPTER=PDO_MYSQL
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=AllTests MYSQL_ADAPTER=PDO_MYSQL
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=UnitTests MYSQL_ADAPTER=PDO_MYSQL
- php: hhvm
env: TEST_SUITE=SystemTests MYSQL_ADAPTER=PDO_MYSQL
- php: hhvm
env: TEST_SUITE=IntegrationTests MYSQL_ADAPTER=PDO_MYSQL
- php: hhvm
env: TEST_SUITE=UnitTests MYSQL_ADAPTER=PDO_MYSQL
# run UI tests on PHP 5.3.3 only
# run UI tests on PHP 5.4 only
- php: 5.6
env: TEST_SUITE=UITests MYSQL_ADAPTER=PDO_MYSQL
# run all tests not on PHP 5.6 and run MySQLI tests only on 5.6
- php: 5.6
env: TEST_SUITE=AllTests MYSQL_ADAPTER=PDO_MYSQL
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=AllTests MYSQL_ADAPTER=MYSQLI
- php: hhvm
env: TEST_SUITE=AllTests MYSQL_ADAPTER=MYSQLI
# Javascript tests need to run only on one PHP version
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=JavascriptTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
- php: hhvm
env: TEST_SUITE=JavascriptTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
# AngularJS tests need to run only on one PHP version
- php: 5.3.3
- php: 5.4
env: TEST_SUITE=AngularJSTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
- php: hhvm
env: TEST_SUITE=AngularJSTests MYSQL_ADAPTER=PDO_MYSQL SKIP_COMPOSER_INSTALL=1
Expand All @@ -83,15 +83,12 @@ sudo: required

script: $PIWIK_ROOT_DIR/tests/travis/travis.sh

before_install:
# do not use the Zend allocator on PHP 5.3 since it will randomly segfault after program execution
- '[[ "$TRAVIS_PHP_VERSION" == 5.3* ]] && export USE_ZEND_ALLOC=0 || true'

install:
- git fetch -q

- export GENERATE_TRAVIS_YML_COMMAND="php ./tests/travis/generator/main.php generate:travis-yml --core --verbose"
- '[[ "$TRAVIS_JOB_NUMBER" != *.1 || "$TRAVIS_PULL_REQUEST" != "false" ]] || ./tests/travis/autoupdate_travis_yml.sh'
# Disable it until this is in master, otherwise we have to create a branch for travis submodule
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wanted to avoid having to keep a branch of travis submodule in sync. I reckon it's ok to just not have this activated for now. Not sure how to make sure we won't forget to enable it again. Of course we can create an issue but chances are high we won't look into that issue... I will create one though if we merge this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, cc @diosmosis maybe you have some thoughts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already talked about it

#- export GENERATE_TRAVIS_YML_COMMAND="php ./tests/travis/generator/main.php generate:travis-yml --core --verbose"
#- '[[ "$TRAVIS_JOB_NUMBER" != *.1 || "$TRAVIS_PULL_REQUEST" != "false" ]] || ./tests/travis/autoupdate_travis_yml.sh'

- '[ ! -f ./tests/travis/install_mysql_5.6.sh ] || ./tests/travis/install_mysql_5.6.sh'

Expand Down
15 changes: 6 additions & 9 deletions core/Plugin/ControllerAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,19 @@ private static function notifyIfEAcceleratorIsUsed()

private static function notifyWhenPhpVersionIsEOL()
{
$notifyPhpIsEOL = Piwik::hasUserSuperUserAccess() && self::isPhpVersion53();
$notifyPhpIsEOL = Piwik::hasUserSuperUserAccess() && self::isPhpVersion54();
if (!$notifyPhpIsEOL) {
return;
}
$dateDropSupport = Date::factory('2015-05-01')->getLocalized('%longMonth% %longYear%');
$message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion', $dateDropSupport)
. "\n "
. Piwik::translate('General_WarningPhpVersionXIsTooOld', '5.3');
$message = Piwik::translate('General_WarningPhpVersionXIsTooOld', '5.4');

$notification = new Notification($message);
$notification->title = Piwik::translate('General_Warning');
$notification->priority = Notification::PRIORITY_LOW;
$notification->context = Notification::CONTEXT_WARNING;
$notification->type = Notification::TYPE_TRANSIENT;
$notification->flags = Notification::FLAG_NO_CLEAR;
NotificationManager::notify('PHP53VersionCheck', $notification);
NotificationManager::notify('PHP54VersionCheck', $notification);
}

/**
Expand Down Expand Up @@ -214,11 +211,11 @@ protected static function getPiwikVersion()
private static function checkPhpVersion($view)
{
$view->phpVersion = PHP_VERSION;
$view->phpIsNewEnough = version_compare($view->phpVersion, '5.3.0', '>=');
$view->phpIsNewEnough = version_compare($view->phpVersion, '5.4.0', '>=');
}

private static function isPhpVersion53()
private static function isPhpVersion54()
{
return strpos(PHP_VERSION, '5.3') === 0;
return strpos(PHP_VERSION, '5.4') === 0;
}
}
4 changes: 0 additions & 4 deletions tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ public static function unsetLocationProvider()
// also fails on other PHP, is it really needed?
return;

// this randomly fails on PHP 5.3
if(strpos(PHP_VERSION, '5.3') === 0) {
return;
}
try {
LocationProvider::setCurrentProvider('default');
} catch(Exception $e) {
Expand Down
12 changes: 0 additions & 12 deletions tests/PHPUnit/Framework/TestCase/SystemTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ public static function isTravisCI()
return !empty($travis);
}

public static function isPhpVersion53()
{
return strpos(PHP_VERSION, '5.3') === 0;
}

public static function isMysqli()
{
return getenv('MYSQL_ADAPTER') == 'MYSQLI';
Expand Down Expand Up @@ -594,13 +589,6 @@ public static function deleteArchiveTables()
DbHelper::deleteArchiveTables();
}

protected function skipWhenPhp53()
{
if(self::isPhpVersion53()) {
$this->markTestSkipped('Sometimes fail on php 5.3');
}
}

public function assertHttpResponseText($expectedResponseText, $url, $message = '')
{
self::assertThat($url, new HttpResponseText($expectedResponseText), $message);
Expand Down
4 changes: 0 additions & 4 deletions tests/PHPUnit/Framework/TestRequest/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ private function normalizeApiResponse($apiResponse)

private function normalizeEncodingPhp533($apiResponse)
{
if (!SystemTestCase::isPhpVersion53()
|| strpos($apiResponse, '<result') === false) {
return $apiResponse;
}
return str_replace('&amp;#039;', "'", $apiResponse);
}

Expand Down
1 change: 0 additions & 1 deletion tests/PHPUnit/Integration/Plugin/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public function test_getSettingsForCurrentUser_shouldOnlyReturnSettingsHavingEno

public function test_getSettingsForCurrentUser_shouldReturnAllSettingsIfEnoughPermissionsAndSortThemBySettingOrder()
{
$this->skipWhenPhp53();
$this->setSuperUser();

$this->addSystemSetting('mysystemsetting1', 'mytitle1');
Expand Down
4 changes: 0 additions & 4 deletions tests/PHPUnit/System/ArchiveCronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public function getApiForTesting()

public function testArchivePhpCron()
{
if(self::isPhpVersion53()) {
$this->markTestSkipped('Fails on PHP 5.3 once in a blue moon.');
}

$this->setLastRunArchiveOptions();
$output = $this->runArchivePhpCron();

Expand Down
4 changes: 0 additions & 4 deletions tests/PHPUnit/System/AutoSuggestAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public function testApi($api, $params)
// Refresh cache for CustomVariables\Model
Cache::clearCacheGeneral();

if(self::isPhpVersion53() && self::isTravisCI()) {
$this->markTestSkipped("Skipping this test as it seg faults on php 5.3 (bug triggered on travis)");
}

$this->runApiTests($api, $params);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/PHPUnit/System/CliMultiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public function test_request_shouldReturnResultAsArray_IfOnlyOneUrlIsGiven()

public function test_request_shouldRunAsync()
{
$this->skipWhenPhp53();
$this->assertTrue($this->cliMulti->supportsAsync);
}

Expand Down Expand Up @@ -142,15 +141,13 @@ public function test_request_shouldWorkInCaseItDoesNotRunFromCli()
*/
public function test_request_shouldDetectFinishOfRequest_IfNoParamsAreGiven()
{
$this->skipWhenPhp53();
$this->cliMulti->runAsSuperUser();
$response = $this->cliMulti->request(array($this->completeUrl('')));
$this->assertStringStartsWith('Error in Piwik: Error: no website was found', $response[0]);
}

public function test_request_shouldBeAbleToRenderARegularPageInPiwik()
{
$this->skipWhenPhp53();
Fixture::createWebsite('2014-01-01 00:00:00');

$urls = array($this->completeUrl('/?module=Widgetize&idSite=1&period=day&date=today'));
Expand Down
90 changes: 42 additions & 48 deletions tests/PHPUnit/System/ManyVisitorsOneWebsiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,54 +115,48 @@ public function getApiForTesting()
)),
);

// Randomly fails on 5.3
if(!self::isPhpVersion53()) {

$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_sortDesc',
'otherRequestParameters' => array('filter_sort_order' => 'desc', 'filter_limit' => 7)
));

// #5950
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_sortByIdVisit',
'otherRequestParameters' => array('filter_sort_order' => 'desc', 'filter_sort_column' => 'idVisit', 'filter_limit' => 7)
));

// #7458
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_offsetAndLimit_1',
'otherRequestParameters' => array('filter_offset' => '1', 'filter_limit' => 3)
));
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_offsetAndLimit_2',
'otherRequestParameters' => array('filter_offset' => '4', 'filter_limit' => 3)
));

// #8324
// testing filter_excludelowpop and filter_excludelowpop_value
$apiToTest[] = array('UserCountry.getCountry', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_getCountry_with_filter_excludelowpop',
'otherRequestParameters' => array('filter_excludelowpop' => 'nb_visits', 'filter_excludelowpop_value' => 5)
));


}
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_sortDesc',
'otherRequestParameters' => array('filter_sort_order' => 'desc', 'filter_limit' => 7)
));

// #5950
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_sortByIdVisit',
'otherRequestParameters' => array('filter_sort_order' => 'desc', 'filter_sort_column' => 'idVisit', 'filter_limit' => 7)
));

// #7458
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_offsetAndLimit_1',
'otherRequestParameters' => array('filter_offset' => '1', 'filter_limit' => 3)
));
$apiToTest[] = array('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_Live.getLastVisitsDetails_offsetAndLimit_2',
'otherRequestParameters' => array('filter_offset' => '4', 'filter_limit' => 3)
));

// #8324
// testing filter_excludelowpop and filter_excludelowpop_value
$apiToTest[] = array('UserCountry.getCountry', array(
'idSite' => $idSite,
'date' => $dateString,
'periods' => 'month',
'testSuffix' => '_getCountry_with_filter_excludelowpop',
'otherRequestParameters' => array('filter_excludelowpop' => 'nb_visits', 'filter_excludelowpop_value' => 5)
));

// this also fails on all PHP versions, it seems randomly.
// $apiToTest[] = array('Live.getLastVisitsDetails', array(
Expand Down
4 changes: 0 additions & 4 deletions tests/PHPUnit/System/PivotByQueryParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ public function test_PivotByParam_PlaysNiceWithDataTableMaps()
}
public function assertApiResponseEqualsExpected($apiMethod, $queryParams)
{
if(self::isPhpVersion53()) {
// 5.3.3 space encoding fail eg. https://travis-ci.org/piwik/piwik/jobs/35920420
$this->markTestSkipped();
}
parent::assertApiResponseEqualsExpected($apiMethod, $queryParams);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class TwoVisitorsTwoWebsitesDifferentDaysArchivingDisabledTest extends SystemTes
*/
public function testApi($api, $params)
{
if (self::isPhpVersion53() && self::isTravisCI()) {
$this->markTestSkipped("Skipping this test as it often fails on travis)");
}
$this->runApiTests($api, $params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class TwoVisitorsTwoWebsitesDifferentDaysConversionsTest extends SystemTestCase
*/
public function testApi($api, $params)
{
$this->markTestSkippedOnPhp53();

$this->runApiTests($api, $params);
}

Expand Down Expand Up @@ -126,8 +124,6 @@ public function getApiForTesting()
// plugins is non-trivial, so not done now.
public function test_Archive_getNumeric_ReturnsMetricsFromDifferentPlugins_WhenThoseMetricsAreRequested()
{
$this->markTestSkippedOnPhp53();

// Tests that getting a visits summary metric (nb_visits) & a Goal's metric (Goal_revenue)
// at the same time works.
$dateTimeRange = '2010-01-03,2010-01-06';
Expand All @@ -149,8 +145,6 @@ public function test_Archive_getNumeric_ReturnsMetricsFromDifferentPlugins_WhenT
// plugins is non-trivial, so not done now.
public function test_Archive_getNumeric_shouldInvalidateRememberedReportsOncePerRequestIfNeeded()
{
$this->markTestSkippedOnPhp53();

// Tests that getting a visits summary metric (nb_visits) & a Goal's metric (Goal_revenue)
// at the same time works.
$dateTimeRange = '2010-01-03,2010-01-06';
Expand Down Expand Up @@ -219,13 +213,6 @@ public static function getOutputPrefix()
{
return 'TwoVisitors_twoWebsites_differentDays_Conversions';
}

private function markTestSkippedOnPhp53()
{
if (self::isPhpVersion53() && self::isTravisCI()) {
$this->markTestSkipped("Skipping this test as it often fails on travis)");
}
}
}

TwoVisitorsTwoWebsitesDifferentDaysConversionsTest::$fixture = new TwoSitesTwoVisitorsDifferentDays();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public function testImagesIncludedInTests()
*/
public function testApi($api, $params)
{
if(self::isTravisCI() && self::isPhpVersion53()) {
$this->markTestSkipped('This test fails on travis eg. https://travis-ci.org/piwik/piwik/jobs/46944264');
}
$this->runApiTests($api, $params);
}

Expand Down
Loading