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

Upgrade master to PHPUnit 8 #9166

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
"ext-xml": "*"
},
"require-dev": {
"phpunit/phpunit": "7.1.3",
"sminnee/phpunit-mock-objects": "^3.4.5",
"phpunit/phpunit": "^8",
"silverstripe/versioned": "^2"
},
"provide": {
Expand Down
2 changes: 1 addition & 1 deletion docs/en/02_Developer_Guides/06_Testing/00_Unit_Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ use SilverStripe\Dev\SapphireTest;

class PageTest extends SapphireTest
{
public function setUp()
public function setUp(): void
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the kind of thing that would ideally be able to be automated by the upgrader, since it's going to be very common in modules and projects. Relevant issue: silverstripe/silverstripe-upgrader#175

{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions src/Dev/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function session() : Session
return $this->mainSession->session();
}

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

Expand Down Expand Up @@ -112,7 +112,7 @@ protected function setUp()
SecurityToken::disable();
}

protected function tearDown()
protected function tearDown(): void
{
SecurityToken::enable();
unset($this->mainSession);
Expand Down
8 changes: 4 additions & 4 deletions src/Dev/SapphireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function getRequireDefaultRecordsFrom()
*
* User code should call parent::setUp() before custom setup code
*/
protected function setUp()
protected function setUp(): void
{
if (!defined('FRAMEWORK_PATH')) {
trigger_error(
Expand Down Expand Up @@ -373,7 +373,7 @@ protected function currentTestDisablesDatabase() : bool
*
* @throws Exception
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
// Start tests
static::start();
Expand Down Expand Up @@ -402,7 +402,7 @@ public static function setUpBeforeClass()
*
* User code should call parent::tearDownAfterClass() after custom tear down code
*/
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
// Call state helpers
static::$state->tearDownOnce(static::class);
Expand Down Expand Up @@ -567,7 +567,7 @@ protected function getCurrentRelativePath() : string
*
* User code should call parent::tearDown() after custom tear down code
*/
protected function tearDown()
protected function tearDown(): void
{
// Reset mocked datetime
DBDatetime::clear_mock_now();
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ControllerTest extends FunctionalTest
UnsecuredController::class,
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Director::config()->update('alternate_base_url', '/');
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CookieTest extends SapphireTest
{

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Injector::inst()->registerService(new CookieJar($_COOKIE), 'SilverStripe\\Control\\Cookie_Backend');
Expand Down
6 changes: 3 additions & 3 deletions tests/php/Control/DirectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DirectorTest extends SapphireTest

private $originalEnvType;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Director::config()->set('alternate_base_url', 'http://www.mysite.com:9090/');
Expand All @@ -44,10 +44,10 @@ protected function setUp()
$this->expectedRedirect = null;
}

protected function tearDown(...$args)
protected function tearDown(): void
{
Environment::setEnv('SS_ENVIRONMENT_TYPE', $this->originalEnvType);
parent::tearDown(...$args);
parent::tearDown();
}

protected function getExtraRoutes()
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/Email/SwiftPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class SwiftPluginTest extends SapphireTest
{

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

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/HTTPCacheControlIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HTTPCacheControlIntegrationTest extends FunctionalTest
RuleController::class,
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
HTTPCacheControlMiddleware::config()
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/HTTPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
class HTTPTest extends FunctionalTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
// Set to disabled at null forcing level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CanonicalURLMiddlewareTest extends SapphireTest
*/
protected $middleware;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class HTTPCacheControlMiddlewareTest extends SapphireTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
// Set to disabled at null forcing level
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/Middleware/RateLimitMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RateLimitMiddlewareTest extends FunctionalTest
TestController::class,
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
DBDatetime::set_mock_now('2017-09-27 00:00:00');
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Control/RSS/RSSFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testRenderWithTemplate()
$this->assertNotContains('<title>Test Custom Template</title>', $content);
}

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Config::modify()->set(Director::class, 'alternate_base_url', '/');
Expand All @@ -116,7 +116,7 @@ function () {
);
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
$_SERVER['HTTP_HOST'] = self::$original_host;
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Control/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class SessionTest extends SapphireTest
*/
protected $session = null;

protected function setUp()
protected function setUp(): void
{
$this->session = new Session([]);
return parent::setUp();
parent::setUp();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Control/SimpleResourceURLGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class SimpleResourceURLGeneratorTest extends SapphireTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
Director::config()->set(
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class CacheTest extends SapphireTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Cache/RateLimiterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class RateLimiterTest extends SapphireTest
{

protected function setUp()
protected function setUp(): void
{
parent::setUp();
DBDatetime::set_mock_now('2017-09-27 00:00:00');
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/ClassInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ClassInfoTest extends SapphireTest
WithRelation::class,
);

protected function setUp()
protected function setUp(): void
{
parent::setUp();
ClassInfo::reset_db_cache();
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Core/ConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class ConvertTest extends SapphireTest

private $previousLocaleSetting = null;

public function setUp()
public function setUp(): void
{
parent::setUp();
// clear the previous locale setting
$this->previousLocaleSetting = null;
}

public function tearDown()
public function tearDown(): void
{
parent::tearDown();
// If a test sets the locale, reset it on teardown
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Core/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CoreTest extends SapphireTest

protected $tempPath;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->tempPath = Director::baseFolder() . DIRECTORY_SEPARATOR . 'silverstripe-cache';
Expand Down Expand Up @@ -52,7 +52,7 @@ public function testGetTempPathInProject()
}
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
$user = TempFolder::getTempFolderUsername();
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Core/Injector/InjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class InjectorTest extends SapphireTest

protected $nestingLevel = 0;

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

$this->nestingLevel = 0;
}

protected function tearDown()
protected function tearDown(): void
{

while ($this->nestingLevel > 0) {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Manifest/ClassLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClassLoaderTest extends SapphireTest
*/
protected $testManifest2;

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

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Manifest/ClassManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ClassManifestTest extends SapphireTest
*/
protected $manifestTests;

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

Expand Down
4 changes: 2 additions & 2 deletions tests/php/Core/Manifest/ConfigManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class ConfigManifestTest extends SapphireTest
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -22,7 +22,7 @@ protected function setUp()
ModuleLoader::inst()->pushManifest($moduleManifest);
}

protected function tearDown()
protected function tearDown(): void
{
ModuleLoader::inst()->popManifest();
parent::tearDown();
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Manifest/ModuleManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ModuleManifestTest extends SapphireTest
*/
protected $manifest;

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

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Manifest/ModuleResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ModuleResourceTest extends SapphireTest
*/
protected $manifest;

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

Expand Down
4 changes: 2 additions & 2 deletions tests/php/Core/Manifest/NamespacedClassManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NamespacedClassManifestTest extends SapphireTest
*/
protected $manifest;

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

Expand All @@ -35,7 +35,7 @@ protected function setUp()
ClassLoader::inst()->pushManifest($this->manifest, false);
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
ClassLoader::inst()->popManifest();
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Manifest/PrioritySorterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PrioritySorterTest extends SapphireTest
*/
protected $sorter;

public function setUp()
public function setUp(): void
{
parent::setUp();
$modules = [
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Core/Manifest/ThemeResourceLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ThemeResourceLoaderTest extends SapphireTest
/**
* Set up manifest before each test
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -60,7 +60,7 @@ protected function setUp()
ThemeResourceLoader::flush();
}

protected function tearDown()
protected function tearDown(): void
{
ModuleLoader::inst()->popManifest();
parent::tearDown();
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/Manifest/VersionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VersionProviderTest extends SapphireTest
*/
protected $provider;

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->provider = new VersionProvider;
Expand Down
Loading