Skip to content

Commit

Permalink
API phpunit 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Nov 5, 2021
1 parent e3bf7ac commit b6f1e38
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
],
"license": "BSD-3-Clause",
"require": {
"php": "^7.3 || ^8.0",
"silverstripe/framework": "^4.10",
"cwp/cwp-core": "^2",
"silverstripe/cms": "^4",
"silverstripe/taxonomy": "^2",
"symbiote/silverstripe-gridfieldextensions": "^3.2"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3"
},
"suggest": {
Expand Down
8 changes: 4 additions & 4 deletions tests/PageTypes/DatedUpdateHolderControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DatedUpdateHolderControllerTest extends FunctionalTest

protected static $use_draft_site = true;

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

Expand All @@ -29,7 +29,7 @@ public function testSettingDateFiltersInReverseOrderShowsMessage()

$result = $this->get($holder->Link() . '?from=2018-01-10&to=2018-01-01');

$this->assertContains('Filter has been applied with the dates reversed', $result->getBody());
$this->assertStringContainsString('Filter has been applied with the dates reversed', $result->getBody());
}

public function testSettingFromButNotToDateShowsMessage()
Expand All @@ -39,14 +39,14 @@ public function testSettingFromButNotToDateShowsMessage()

$result = $this->get($holder->Link() . '?from=2018-01-10');

$this->assertContains('Filtered by a single date', $result->getBody());
$this->assertStringContainsString('Filtered by a single date', $result->getBody());
}

public function testInvalidDateFormat()
{
/** @var EventHolder $holder */
$holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
$result = $this->get($holder->Link() . '?from=christmas&to=2018-01-10');
$this->assertContains(htmlentities('Dates must be in "y-MM-dd" format.'), $result->getBody());
$this->assertStringContainsString(htmlentities('Dates must be in "y-MM-dd" format.'), $result->getBody());
}
}
2 changes: 1 addition & 1 deletion tests/PageTypes/SitemapPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SitemapPageTest extends FunctionalTest

protected static $use_draft_site = true;

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

Expand Down
2 changes: 1 addition & 1 deletion tests/Report/CwpStatsReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CwpStatsReportTest extends SapphireTest
{
protected static $fixture_file = 'CwpStatsReportTest.yml';

protected function setUp()
protected function setUp(): void
{
Config::modify()->set(SiteTree::class, 'create_default_pages', false);

Expand Down
8 changes: 4 additions & 4 deletions tests/Tasks/PopulateThemeSampleDataTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public function testOnlyCreateContactFormOnce()
$task = new PopulateThemeSampleDataTask;

// Run the task
$this->assertContains($createdMessage, $this->bufferedTask($task));
$this->assertStringContainsString($createdMessage, $this->bufferedTask($task));

// Run a second time
$this->assertNotContains($createdMessage, $this->bufferedTask($task));
$this->assertStringNotContainsString($createdMessage, $this->bufferedTask($task));

// Change the page name
$form = UserDefinedForm::get()->filter('URLSegment', 'contact')->first();
$form->URLSegment = 'testing';
$form->write();

// Ensure the old version is still detected in draft, so not recreated
$this->assertNotContains($createdMessage, $this->bufferedTask($task));
$this->assertStringNotContainsString($createdMessage, $this->bufferedTask($task));

// Delete the page, then ensure it's recreated again (DataObject::delete will remove staged versions)
$form->delete();
$this->assertContains($createdMessage, $this->bufferedTask($task));
$this->assertStringContainsString($createdMessage, $this->bufferedTask($task));
}

/**
Expand Down

0 comments on commit b6f1e38

Please sign in to comment.