Skip to content

Commit

Permalink
API phpunit9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 13, 2021
1 parent b031bb4 commit 1c27b2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"silverstripe/vendor-plugin": "^1.0"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions tests/ErrorPageFileExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ErrorPageFileExtensionTest extends SapphireTest

protected $versionedMode = null;

public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->versionedMode = Versioned::get_reading_mode();
Expand All @@ -34,7 +34,7 @@ public function setUp()
$file->write();
}

public function tearDown()
protected function tearDown(): void
{
Versioned::set_reading_mode($this->versionedMode);
TestAssetStore::reset();
Expand Down
16 changes: 8 additions & 8 deletions tests/ErrorPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ErrorPageTest extends FunctionalTest
*/
protected $tmpAssetsPath = '';

public function setUp()
protected function setUp(): void
{
parent::setUp();
// Set temporary asset backend store
Expand All @@ -43,7 +43,7 @@ public function setUp()
$this->logInWithPermission('ADMIN');
}

public function tearDown()
protected function tearDown(): void
{
DB::quiet(true);
TestAssetStore::reset();
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testSecurityError()
$response = $this->get('Security/nosuchaction');
$this->assertEquals($response->getStatusCode(), '404');
$this->assertNotNull($response->getBody());
$this->assertContains('text/html', $response->getHeader('Content-Type'));
$this->assertStringContainsString('text/html', $response->getHeader('Content-Type'));
}

public function testStaticCaching()
Expand All @@ -130,7 +130,7 @@ public function testStaticCaching()
$error = ErrorPage::get_content_for_errorcode('401');
$this->assertEmpty($error);
$expectedErrorPagePath = TestAssetStore::base_path() . '/error-401.html';
$this->assertFileNotExists($expectedErrorPagePath, 'Error page is not automatically cached');
$this->assertFileDoesNotExist($expectedErrorPagePath, 'Error page is not automatically cached');

// Write new 401 page
$page = new ErrorPage();
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testGeneratedFile()
// Static content is not available
$this->assertEmpty(ErrorPage::get_content_for_errorcode('405'));
$expectedErrorPagePath = TestAssetStore::base_path() . '/error-405.html';
$this->assertFileNotExists($expectedErrorPagePath, 'Error page is not cached in static location');
$this->assertFileDoesNotExist($expectedErrorPagePath, 'Error page is not cached in static location');
}

public function testGetByLink()
Expand Down Expand Up @@ -217,7 +217,7 @@ public function testWriteStaticPageWithDisableStaticFile()
'writeStaticPage should return false when enable_static_file is true'
);
$expectedErrorPagePath = TestAssetStore::base_path() . '/error-404.html';
$this->assertFileNotExists($expectedErrorPagePath, 'Error page should not be cached.');
$this->assertFileDoesNotExist($expectedErrorPagePath, 'Error page should not be cached.');
}

/**
Expand All @@ -236,9 +236,9 @@ public function testErrorMessageAppended($env, $shouldShowInDev)
$response = ErrorPage::response_for(404, 'Really bad error');
$this->assertNotEmpty($response->getBody());
if ($env === 'dev' && $shouldShowInDev) {
$this->assertContains('Really bad error', $response->getBody());
$this->assertStringContainsString('Really bad error', $response->getBody());
} else {
$this->assertNotContains('Really bad error', $response->getBody());
$this->assertStringNotContainsString('Really bad error', $response->getBody());
}

$kernel->setEnvironment($originalEnv);
Expand Down

0 comments on commit 1c27b2c

Please sign in to comment.