Skip to content

Commit

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

API phpunit 9 support
  • Loading branch information
Maxime Rainville authored Nov 10, 2021
2 parents 6c2b654 + 2b9536e commit 5aca443
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
],
"require": {
"silverstripe/vendor-plugin": "^1.0",
"silverstripe/framework": "^4.0",
"silverstripe/framework": "^4.10",
"silverstripe/cms": "^4.0",
"silverstripe/versioned": "^1.0"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {
Expand All @@ -38,4 +38,4 @@
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"prefer-stable": true
}
}
9 changes: 5 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<phpunit bootstrap="vendor/silverstripe/cms/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">
<directory suffix=".php">src/</directory>
Expand Down
8 changes: 4 additions & 4 deletions tests/WidgetControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WidgetControllerTest extends FunctionalTest
TestWidget::class,
];

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

Expand All @@ -32,7 +32,7 @@ public function testWidgetFormRendering()
$response = $this->get($page->URLSegment);

$formAction = sprintf('%s/widget/%d/%s', $page->URLSegment, $widget->ID, 'Form');
$this->assertContains(
$this->assertStringContainsString(
$formAction,
$response->getBody(),
"Widget forms are rendered through WidgetArea templates"
Expand All @@ -47,12 +47,12 @@ public function testWidgetFormSubmission()
$this->get($page->URLSegment);
$response = $this->submitForm('Form_Form', null, array('TestValue' => 'Updated'));

$this->assertContains(
$this->assertStringContainsString(
'TestValue: Updated',
$response->getBody(),
"Form values are submitted to correct widget form"
);
$this->assertContains(
$this->assertStringContainsString(
sprintf('Widget ID: %d', $widget->ID),
$response->getBody(),
"Widget form acts on correct widget, as identified in the URL"
Expand Down

2 comments on commit 5aca443

@mandrew
Copy link

@mandrew mandrew commented on 5aca443 Jan 9, 2022

Choose a reason for hiding this comment

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

@maxime-rainville is there any reason why this is tagged to 4.10? If so (e.g. you are getting ready for the next release) then I'm ok with using the previous tag but just wondered :)

@maxime-rainville
Copy link

Choose a reason for hiding this comment

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

We upgraded all our test coverage to use PHPUnit 9.5. But only framework 4.10 and above supports it. So our latest release, all our composer dependencies have been bump to framework 4.10.

Please sign in to comment.