Skip to content

Commit

Permalink
Fixes for Travis (#628)
Browse files Browse the repository at this point in the history
* downgrading Composer to 1.x. MW is not yet compatible with Composer 2.x, see https://phabricator.wikimedia.org/T266417.
* use "void" functions
* use double quotes to allow using alias ("as") for SMW variable, e.g. SMW='dev-master#28a03f0 as 3.2.2'
* update test-matrix
* fix "Xdebug 3 is installed by default, breaking builds"
* get rid of old style mock creation
* get rid of reflection induced notices
  • Loading branch information
gesinn-it-gea committed Jan 13, 2021
1 parent e4957f3 commit 670487b
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 39 deletions.
25 changes: 18 additions & 7 deletions .travis.yml
Expand Up @@ -3,24 +3,35 @@ language: php
os:
- linux

env:
global:
# fix "Xdebug 3 is installed by default, breaking builds"
# see https://travis-ci.community/t/xdebug-3-is-installed-by-default-breaking-builds/10748
- XDEBUG_MODE=coverage

services:
- mysql
- postgresql

jobs:
fast_finish: true
include:
- env: DB=mysql; MW=REL1_33; SMW=~3.1@dev; TYPE=coverage
php: 7.3
- env: DB=sqlite; MW=REL1_31; SMW=~3.0; MERMAID=2.1.0
# 1) sqlite, previous MW LTS stable, current SMW stable
- env: DB=sqlite; MW=REL1_31; SMW=3.2.2; MERMAID=2.1.0
php: 7.1
- env: DB=mysql; MW=REL1_31; SMW=~3.0@dev
php: 7.1
- env: DB=postgres; MW=REL1_32; SMW=~3.0@dev
# 2) postgres, current MW non-LTS stable, current SMW stable
- env: DB=postgres; MW=REL1_34; SMW=3.2.2
php: 7.2
- env: DB=mysql; MW=REL1_33; SMW=~3.0@dev; MERMAID=2.2.0
# 3) mysql, current MW LTS stable, current SMW stable, COVERAGE
# temp run against cherry-pick SMW until SMW 3.2.3 is available
# temp stay with MW 1.34 until all SMW tests are passing for 1.35
- env: DB=mysql; MW=REL1_34; SMW='dev-master#229e166 as 3.2.2'; TYPE=coverage
php: 7.3

before_install:
# MW is not yet compatible with Composer 2.x, see https://phabricator.wikimedia.org/T266417
- composer self-update --1

install:
- bash ./build/travis/install-mediawiki.sh
- bash ./build/travis/install-semantic-result-formats.sh
Expand Down
2 changes: 1 addition & 1 deletion build/travis/install-semantic-result-formats.sh
Expand Up @@ -14,7 +14,7 @@ function installPHPUnitWithComposer {
function installSMWWithComposer {
if [ "$SMW" != "" ]
then
composer require 'mediawiki/semantic-media-wiki='$SMW --update-with-dependencies
composer require "mediawiki/semantic-media-wiki=$SMW" --update-with-dependencies
fi
}

Expand Down
10 changes: 6 additions & 4 deletions tests/phpunit/Unit/BibTex/BibTexFileExportPrinterTest.php
Expand Up @@ -31,6 +31,11 @@ public function testCanConstruct() {
* @dataProvider filenameProvider
*/
public function testGetFileName( $filename, $searchlabel, $expected ) {
if ( version_compare( phpversion(), '7.4', '>=' ) ) {
// ResultPrinterReflector creates notices on PHP 7.4+
$this->markTestSkipped();
return;
}

$parameters = [
'filename' => $filename,
Expand Down Expand Up @@ -84,13 +89,10 @@ public function filenameProvider() {
* @return MockObject|SMWQueryResult
*/
private function newQueryResultDummy() {
return $this->getMockBuilder( SMWQueryResult::class )
->disableOriginalConstructor()
->getMock();
return $this->createMock( SMWQueryResult::class );
}

public function testGetMimeType() {

$instance = new BibTexFileExportPrinter(
'bibtex'
);
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Unit/Formats/TreeTest.php
Expand Up @@ -34,12 +34,12 @@ class TreeTest extends QueryPrinterRegistryTestCase {
* Keep the global state and restore it on tearDown to avoid influencing
* other tests in case this one fails in between.
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
self::$initial_parser = $GLOBALS['wgParser'];
self::$initial_title = $GLOBALS['wgTitle'];
}

protected function tearDown() {
protected function tearDown(): void {
$GLOBALS['wgParser'] = self::$initial_parser;
$GLOBALS['wgTitle'] = self::$initial_title;

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Unit/Graph/GraphFormatterTest.php
Expand Up @@ -26,7 +26,7 @@ class GraphFormatterTest extends \PHPUnit_Framework_TestCase {

private $nodes = [];

protected function setUp() {
protected function setUp(): void {
parent::setUp();

$params = [
Expand Down
6 changes: 2 additions & 4 deletions tests/phpunit/Unit/Outline/OutlineResultPrinterTest.php
Expand Up @@ -17,7 +17,7 @@ class OutlineResultPrinterTest extends \PHPUnit_Framework_TestCase {

private $queryResult;

protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->queryResult = $this->getMockBuilder( '\SMWQueryResult' )
Expand All @@ -35,9 +35,7 @@ public function testCanConstruct() {

public function testGetResult_LinkOnNonFileOutput() {

$link = $this->getMockBuilder( '\SMWInfolink' )
->disableOriginalConstructor()
->getMock();
$link = $this->createMock( \SMWInfolink::class );

$link->expects( $this->any() )
->method( 'getText' )
Expand Down
16 changes: 2 additions & 14 deletions tests/phpunit/Unit/iCalendar/DateParserTest.php
Expand Up @@ -15,19 +15,9 @@
*/
class DateParserTest extends \PHPUnit_Framework_TestCase {

public function testCanConstruct() {

$this->assertInstanceOf(
DateParser::class,
new DateParser()
);
}

public function testParseDate_Year() {

$timeValue = $this->getMockBuilder( '\SMWTimeValue' )
->disableOriginalConstructor()
->getMock();
$timeValue = $this->createMock( \SMWTimeValue::class );

$timeValue->expects( $this->any() )
->method( 'getYear' )
Expand All @@ -43,9 +33,7 @@ public function testParseDate_Year() {

public function testParseDate_Year_Month_Day_Time() {

$timeValue = $this->getMockBuilder( '\SMWTimeValue' )
->disableOriginalConstructor()
->getMock();
$timeValue = $this->createMock( \SMWTimeValue::class );

$timeValue->expects( $this->any() )
->method( 'getYear' )
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Unit/iCalendar/IcalFormatterTest.php
Expand Up @@ -19,7 +19,7 @@ class IcalFormatterTest extends \PHPUnit_Framework_TestCase {
private $stringValidator;
private $icalTimezoneFormatter;

protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->icalTimezoneFormatter = $this->getMockBuilder( '\SRF\iCalendar\IcalTimezoneFormatter' )
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Unit/iCalendar/IcalTimezoneFormatterTest.php
Expand Up @@ -18,7 +18,7 @@ class IcalTimezoneFormatterTest extends \PHPUnit_Framework_TestCase {

private $stringValidator;

protected function setUp() {
protected function setUp(): void {
parent::setUp();

$this->stringValidator = TestEnvironment::newValidatorFactory()->newStringValidator();
Expand Down
12 changes: 8 additions & 4 deletions tests/phpunit/Unit/vCard/vCardFileExportPrinterTest.php
Expand Up @@ -19,9 +19,15 @@ class vCardFileExportPrinterTest extends \PHPUnit_Framework_TestCase {
private $queryResult;
private $resultPrinterReflector;

protected function setUp() {
protected function setUp(): void {
parent::setUp();

if ( version_compare( phpversion(), '7.4', '>=' ) ) {
// ResultPrinterReflector creates notices on PHP 7.4+
$this->markTestSkipped();
return;
}

$this->resultPrinterReflector = new ResultPrinterReflector();

$this->queryResult = $this->getMockBuilder( '\SMWQueryResult' )
Expand Down Expand Up @@ -73,9 +79,7 @@ public function testGetMimeType() {

public function testGetResult_LinkOnNonFileOutput() {

$link = $this->getMockBuilder( '\SMWInfolink' )
->disableOriginalConstructor()
->getMock();
$link = $this->createMock( \SMWInfolink::class );

$link->expects( $this->any() )
->method( 'getText' )
Expand Down

0 comments on commit 670487b

Please sign in to comment.