Skip to content

Commit

Permalink
Merge pull request #77 from creative-commoners/pulls/2.0/phpunit7
Browse files Browse the repository at this point in the history
API Upgrade to PHPUnit 7, increase minimum PHP version to 7.1
  • Loading branch information
Damian Mooyman authored Jan 7, 2018
2 parents 520731a + c0554c2 commit 5299ec3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ env:
matrix:
fast_finish: true
include:
- php: 5.6
- php: 7.1
env: DB=PGSQL PHPUNIT_TEST=1 PHPCS_TEST=1
- php: 7.0
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.1
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.2
env: DB=MYSQL PDO=1 PHPUNIT_COVERAGE_TEST=1

before_script:
Expand All @@ -26,16 +26,14 @@ before_script:

# Install composer
- composer validate
- composer install --prefer-dist
- composer require silverstripe/recipe-core:2.0.x-dev silverstripe/admin:2.0.x-dev --prefer-dist --no-update
- composer update
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --prefer-dist; fi
- composer require silverstripe/recipe-core:2.x-dev --no-update
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:3.x-dev --no-update; fi
- if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi
- composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile

script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/php; fi
- if [[ $PHPCS_TEST ]]; then composer run-script lint; fi
- if [[ $PHPCS_TEST ]]; then composer validate; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi

after_success:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"silverstripe/vendor-plugin": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^7@dev",
"silverstripe/admin": "^2"
},
"extra": {
Expand Down
6 changes: 4 additions & 2 deletions tests/php/ChangeSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Versioned\Tests;

use BadMethodCallException;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit_Framework_ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use SilverStripe\Dev\SapphireTest;
Expand Down Expand Up @@ -72,7 +73,7 @@ protected function assertChangeSetLooksLike($cs, $match)
}
}

throw new PHPUnit_Framework_ExpectationFailedException(
throw new ExpectationFailedException(
'Change set didn\'t include expected item',
new ComparisonFailure(
['Class' => $class, 'ID' => $objectID, 'Added' => $mode],
Expand All @@ -93,11 +94,12 @@ protected function assertChangeSetLooksLike($cs, $match)
'ChangeType' => $item->getChangeType()
];
}
throw new PHPUnit_Framework_ExpectationFailedException(
throw new ExpectationFailedException(
'Change set included items that weren\'t expected',
new ComparisonFailure([], $extra, '', print_r($extra, true))
);
}
$this->assertTrue(true, 'No exceptions were thrown during assertion process');
}

public function testAddObject()
Expand Down
9 changes: 3 additions & 6 deletions tests/php/VersionedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Versioned\ChangeSet;
use SilverStripe\Versioned\Tests\VersionedTest\SingleStage;
use SilverStripe\Versioned\Versioned;

class VersionedTest extends SapphireTest
Expand Down Expand Up @@ -150,10 +149,8 @@ public function testInvalidPublish()
$obj->ExtraField = 'Foo'; // ensure that child version table gets written
$obj->write();
$class = VersionedTest\TestObject::class;
$this->setExpectedException(
'InvalidArgumentException',
"Can't find {$class}#{$obj->ID} in stage Live"
);
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("Can't find {$class}#{$obj->ID} in stage Live");

// Fail publishing from live to stage
$obj->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT);
Expand Down Expand Up @@ -1177,7 +1174,7 @@ public function testVersionedHandlesRenamedDataObjectFields()
$this->resetDBSchema(true);
$testData = new VersionedTest\RelatedWithoutversion();
$testData->NewField = 'Test';
$testData->write();
$this->assertGreaterThan(0, $testData->write(), 'Failed to successfully write object');
}

public function testCanView()
Expand Down

0 comments on commit 5299ec3

Please sign in to comment.