Skip to content

Commit

Permalink
Merge pull request #410 from creative-commoners/pulls/master/sapphire…
Browse files Browse the repository at this point in the history
…-test-nine

API phpunit 9 support
  • Loading branch information
Maxime Rainville authored Nov 2, 2021
2 parents 7af51b7 + e060705 commit 37a5b86
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 25 deletions.
16 changes: 5 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,16 @@ env:
matrix:
fast_finish: true
include:
- php: 7.2
env: DB=PGSQL PHPUNIT_TEST=1 PHPCS_TEST=1
- php: 7.3
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.3
env: DB=MYSQL PDO=1 PHPUNIT_COVERAGE_TEST=1
env: DB=MYSQL PDO=1 PHPUNIT_TEST=1 PHPCS_TEST=1
- php: 7.4
env: DB=MYSQL PHPUNIT_TEST=1
env: DB=PGSQL PHPUNIT_TEST=1 PHPUNIT_COVERAGE_TEST=1
- php: 7.3
env: DB=MYSQL BEHAT_TEST=1
- php: 7.3
- php: 7.4
env: DB=MYSQL ASSETADMIN_TEST=1
# TODO https://github.com/silverstripe/silverstripe-asset-admin/issues/1163
allow_failures:
- php: 7.3
env: DB=MYSQL BEHAT_TEST=1
- php: 8.0
env: DB=MYSQL PHPUNIT_TEST=1

before_script:
# separately create artifacts directory for asset-admin behat test
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"type": "silverstripe-vendormodule",
"license": "BSD-3-Clause",
"require": {
"silverstripe/framework": "^4",
"php": "^7.3 || ^8.0",
"silverstripe/framework": "^4.10",
"silverstripe/vendor-plugin": "^1.0",
"webonyx/graphql-php": "^14.0",
"silverstripe/event-dispatcher": "^0.1.2"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"sminnee/phpunit-mock-objects": "^3.4.5",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0",
"silverstripe/versioned": "^1.0@dev"
},
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">

<testsuite name="Default">
<directory>tests</directory>
</testsuite>
<testsuites>
<testsuite name="Default">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
Expand Down
2 changes: 1 addition & 1 deletion tests/Auth/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HandlerTest extends SapphireTest
/**
* {@inheritDoc}
*/
protected function setUp() : void
protected function setUp(): void
{
parent::setUp();
Handler::config()->remove('authenticators');
Expand Down
4 changes: 2 additions & 2 deletions tests/Middleware/CSRFMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testItDoesntDoAnythingIfNotAMutation()
public function testItThrowsIfNoTokenIsProvided()
{
$this->expectException(Exception::class);
$this->expectExceptionMessageRegExp('/must provide a CSRF token/');
$this->expectExceptionMessageMatches('/must provide a CSRF token/');
$result = $this->simulateMiddlewareProcess(
new CSRFMiddleware(),
' mutation someMutation { tester }'
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testItThrowsIfNoTokenIsProvided()
public function testItThrowsIfTokenIsInvalid()
{
$this->expectException(Exception::class);
$this->expectExceptionMessageRegExp('/Invalid CSRF token/');
$this->expectExceptionMessageMatches('/Invalid CSRF token/');
$result = $this->simulateMiddlewareProcess(
new CSRFMiddleware(),
' mutation someMutation { tester }',
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/MiddlewareProcessTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class MiddlewareProcessTestBase extends SapphireTest
*/
protected $defaultCallback;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->defaultCallback = function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/DataObject/FieldAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FieldAccessorTest extends SapphireTest
Member::class,
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->obj = new FakeProduct();
Expand Down
4 changes: 2 additions & 2 deletions tests/Schema/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class IntegrationTest extends SapphireTest
Member::class,
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
TestStoreCreator::$dir = __DIR__;
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
$this->clean();
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class SchemaTest extends SapphireTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
// Kill the global schema
Expand Down

0 comments on commit 37a5b86

Please sign in to comment.