Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API phpunit9 support #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"silverstripe/framework": "^4.10",
"silverstripe/cms": "^4@dev",
"silverstripe/vendor-plugin": "^1.0"
},
"require-dev": {
"sminnee/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3"
},
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +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
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