Merge pull request #6736 from dhensby/pulls/4/phpunit-5

Bump PHPUnit to 5.7
This commit is contained in:
Loz Calver 2017-03-24 10:21:49 +00:00 committed by GitHub
commit a9e1ce48df
63 changed files with 102 additions and 95 deletions

View File

@ -35,6 +35,7 @@ before_script:
- "if [ \"$PHPCS_TEST\" = \"1\" ]; then pyrus install pear/PHP_CodeSniffer; fi"
- phpenv rehash
- phpenv config-rm xdebug.ini
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- "export DISPLAY=\":99\""
- "export XVFBARGS=\":99 -ac -screen 0 1024x768x16\""
- composer install --prefer-dist

View File

@ -32,7 +32,7 @@
"vlucas/phpdotenv": "^2.4"
},
"require-dev": {
"phpunit/PHPUnit": "~4.8",
"phpunit/PHPUnit": "^5.7",
"silverstripe/behat-extension": "^2.1.0",
"silverstripe/serve": "dev-master",
"silverstripe/testsession": "^2.0.0-alpha3",

View File

@ -80,7 +80,7 @@ class FunctionalTest extends SapphireTest
return $this->mainSession->session();
}
public function setUp()
protected function setUp()
{
// Skip calling FunctionalTest directly.
if (get_class($this) == __CLASS__) {
@ -107,7 +107,7 @@ class FunctionalTest extends SapphireTest
SecurityToken::disable();
}
public function tearDown()
protected function tearDown()
{
SecurityToken::enable();

View File

@ -228,7 +228,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
protected $originalEnv = null;
public function setUp()
protected function setUp()
{
//nest config and injector for each test so they are effectively sandboxed per test
Config::nest();
@ -562,7 +562,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
return $path;
}
public function tearDown()
protected function tearDown()
{
// Preserve memory settings
ini_set('memory_limit', ($this->originalMemoryLimit) ? $this->originalMemoryLimit : -1);

View File

@ -47,7 +47,7 @@ class ControllerTest extends FunctionalTest
UnsecuredController::class,
];
public function setUp()
protected function setUp()
{
parent::setUp();
Director::config()->update('alternate_base_url', '/');
@ -62,7 +62,7 @@ class ControllerTest extends FunctionalTest
SSViewer::set_themes($themes);
}
public function tearDown()
protected function tearDown()
{
Deprecation::restore_settings($this->depSettings);
parent::tearDown();

View File

@ -12,14 +12,14 @@ class CookieTest extends SapphireTest
private $cookieInst;
public function setUp()
protected function setUp()
{
parent::setUp();
Injector::nest();
Injector::inst()->registerService(new CookieJar($_COOKIE), 'SilverStripe\\Control\\Cookie_Backend');
}
public function tearDown()
protected function tearDown()
{
//restore the cookie_backend
Injector::unnest();

View File

@ -32,7 +32,7 @@ class DirectorTest extends SapphireTest
TestController::class
];
public function setUp()
protected function setUp()
{
parent::setUp();
@ -77,7 +77,7 @@ class DirectorTest extends SapphireTest
Director::config()->set('rules', $this->getExtraRoutes());
}
public function tearDown()
protected function tearDown()
{
$_GET = $this->originalGet;
$_SESSION = $this->originalSession;

View File

@ -51,7 +51,9 @@ class SwiftMailerTest extends SapphireTest
$email->setFrom('from@example.com');
$email->setSubject('Subject');
$mailer = $this->getMock(SwiftMailer::class, array('sendSwift'));
$mailer = $this->getMockBuilder(SwiftMailer::class)
->setMethods(array('sendSwift'))
->getMock();
$mailer->expects($this->once())->method('sendSwift')->willReturnCallback(function ($message) {
$this->assertInstanceOf(Swift_Message::class, $message);
});

View File

@ -9,7 +9,7 @@ use SilverStripe\Dev\SapphireTest;
class SwiftPluginTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -96,7 +96,7 @@ class RSSFeedTest extends SapphireTest
$this->assertNotContains('<title>Test Custom Template</title>', $content);
}
public function setUp()
protected function setUp()
{
parent::setUp();
Config::inst()->update(Director::class, 'alternate_base_url', '/');
@ -113,7 +113,7 @@ class RSSFeedTest extends SapphireTest
);
}
public function tearDown()
protected function tearDown()
{
parent::tearDown();
$_SERVER['HTTP_HOST'] = self::$original_host;

View File

@ -31,7 +31,7 @@ class ClassInfoTest extends SapphireTest
WithRelation::class,
);
public function setUp()
protected function setUp()
{
parent::setUp();
ClassInfo::reset_db_cache();

View File

@ -14,7 +14,7 @@ class CoreTest extends SapphireTest
protected $tempPath;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->tempPath = Director::baseFolder() . DIRECTORY_SEPARATOR . 'silverstripe-cache';
@ -51,7 +51,7 @@ class CoreTest extends SapphireTest
}
}
public function tearDown()
protected function tearDown()
{
parent::tearDown();
$user = getTempFolderUsername();

View File

@ -4,6 +4,7 @@ namespace SilverStripe\Core\Tests\Injector;
use InvalidArgumentException;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Factory;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator;
use SilverStripe\Core\Tests\Injector\AopProxyServiceTest\AnotherService;
@ -40,14 +41,14 @@ class InjectorTest extends SapphireTest
protected $nestingLevel = 0;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->nestingLevel = 0;
}
public function tearDown()
protected function tearDown()
{
while ($this->nestingLevel > 0) {
@ -813,7 +814,7 @@ class InjectorTest extends SapphireTest
)
);
$factory = $this->getMock('SilverStripe\\Core\\Injector\\Factory');
$factory = $this->getMockBuilder(Factory::class)->getMock();
$factory
->expects($this->once())
->method('create')

View File

@ -32,7 +32,7 @@ class ClassLoaderTest extends SapphireTest
*/
protected $testManifest2;
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -27,7 +27,7 @@ class ClassManifestTest extends SapphireTest
*/
protected $manifestTests;
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -12,7 +12,7 @@ use SilverStripe\Dev\SapphireTest;
class ConfigManifestTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
@ -20,7 +20,7 @@ class ConfigManifestTest extends SapphireTest
ModuleLoader::instance()->pushManifest($moduleManifest);
}
public function tearDown()
protected function tearDown()
{
ModuleLoader::instance()->popManifest();
parent::tearDown();

View File

@ -18,7 +18,7 @@ class ModuleManifestTest extends SapphireTest
*/
protected $manifest;
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -23,7 +23,7 @@ class NamespacedClassManifestTest extends SapphireTest
*/
protected $manifest;
public function setUp()
protected function setUp()
{
parent::setUp();
@ -32,7 +32,7 @@ class NamespacedClassManifestTest extends SapphireTest
ClassLoader::instance()->pushManifest($this->manifest, false);
}
public function tearDown()
protected function tearDown()
{
parent::tearDown();
ClassLoader::instance()->popManifest();

View File

@ -29,7 +29,7 @@ class ThemeResourceLoaderTest extends SapphireTest
/**
* Set up manifest before each test
*/
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -76,7 +76,7 @@ class MemoryLimitTest extends SapphireTest
private $origMemLimit, $origTimeLimit;
public function setUp()
protected function setUp()
{
$this->origMemLimit = ini_get('memory_limit');
$this->origTimeLimit = ini_get('max_execution_time');
@ -86,7 +86,7 @@ class MemoryLimitTest extends SapphireTest
set_increase_time_limit_max(-1);
}
public function tearDown()
protected function tearDown()
{
ini_set('memory_limit', $this->origMemLimit);
set_time_limit($this->origTimeLimit);

View File

@ -26,7 +26,7 @@ use SilverStripe\Control\Controller;
class ObjectTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
Injector::inst()->unregisterAllObjects();

View File

@ -9,7 +9,7 @@ use SilverStripe\Dev\SapphireTest;
*/
class PhpSyntaxTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
$this->markTestSkipped('This needs to be written to include only core php files, not test/thirdparty files');

View File

@ -10,7 +10,7 @@ use Exception;
class ErrorControlChainTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
// Check we can run PHP at all

View File

@ -26,7 +26,7 @@ class ParameterConfirmationTokenTest extends SapphireTest
protected $oldHost = null;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->oldHost = $_SERVER['HTTP_HOST'];
@ -40,7 +40,7 @@ class ParameterConfirmationTokenTest extends SapphireTest
$_GET['parameterconfirmationtokentest_emptytokentoken'] = '';
}
public function tearDown()
protected function tearDown()
{
foreach ($_GET as $param => $value) {
if (stripos($param, 'parameterconfirmationtokentest_') === 0) {

View File

@ -10,7 +10,7 @@ class BulkLoaderResultTest extends SapphireTest
{
protected $extraDataObjects = array(Player::class);
public function setUp()
protected function setUp()
{
parent::setUp();
Player::create(array('Name' => 'Vincent', 'Status' => 'Available'))->write();

View File

@ -15,7 +15,7 @@ class CSVParserTest extends SapphireTest
*/
protected $csvPath = null;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->csvPath = __DIR__ . '/CsvBulkLoaderTest/csv/';

View File

@ -30,7 +30,7 @@ class CsvBulkLoaderTest extends SapphireTest
*/
protected $csvPath = null;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->csvPath = __DIR__ . '/CsvBulkLoaderTest/csv/';

View File

@ -12,7 +12,7 @@ class DeprecationTest extends SapphireTest
static $originalVersionInfo;
public function setUp()
protected function setUp()
{
parent::setUp();
@ -21,7 +21,7 @@ class DeprecationTest extends SapphireTest
Deprecation::set_enabled(true);
}
public function tearDown()
protected function tearDown()
{
Deprecation::restore_settings(self::$originalVersionInfo);
parent::tearDown();

View File

@ -14,7 +14,7 @@ use SilverStripe\Dev\Tests\DevAdminControllerTest\Controller1;
class DevAdminControllerTest extends FunctionalTest
{
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -11,7 +11,7 @@ use SilverStripe\ORM\FieldType\DBDatetime;
class DateFieldTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
i18n::set_locale('en_NZ');

View File

@ -19,14 +19,14 @@ class DatetimeFieldTest extends SapphireTest
{
protected $timezone = null;
public function setUp()
protected function setUp()
{
parent::setUp();
i18n::set_locale('en_NZ');
$this->timezone = date_default_timezone_get();
}
public function tearDown()
protected function tearDown()
{
date_default_timezone_set($this->timezone);
parent::tearDown(); // TODO: Change the autogenerated stub

View File

@ -46,7 +46,7 @@ class FormTest extends FunctionalTest
ControllerWithStrictPostCheck::class,
];
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -56,7 +56,7 @@ class GridFieldDeleteActionTest extends SapphireTest
Permissions::class
];
public function setUp()
protected function setUp()
{
parent::setUp();
$this->list = new DataList(Team::class);

View File

@ -51,7 +51,7 @@ class GridFieldEditButtonTest extends SapphireTest
Permissions::class
);
public function setUp()
protected function setUp()
{
parent::setUp();
$this->list = new DataList(Team::class);

View File

@ -29,7 +29,7 @@ class GridFieldExportButtonTest extends SapphireTest
NoView::class
);
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -49,7 +49,7 @@ class GridFieldPaginatorTest extends FunctionalTest
Cheerleader::class,
);
public function setUp()
protected function setUp()
{
parent::setUp();
$this->list = new DataList(Team::class);

View File

@ -19,7 +19,7 @@ class GridFieldPrintButtonTest extends SapphireTest
TestObject::class
);
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -37,7 +37,7 @@ class HTMLEditorFieldTest extends FunctionalTest
protected $extraDataObjects = array(TestObject::class);
public function setUp()
protected function setUp()
{
parent::setUp();
@ -67,7 +67,7 @@ class HTMLEditorFieldTest extends FunctionalTest
}
}
public function tearDown()
protected function tearDown()
{
TestAssetStore::reset();
parent::tearDown();

View File

@ -24,7 +24,7 @@ class HTMLEditorFieldToolbarTest extends SapphireTest
return new Toolbar(null, '/');
}
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -11,7 +11,7 @@ use SilverStripe\ORM\FieldType\DBDatetime;
class SeparatedDateFieldTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
i18n::set_locale('en_NZ');

View File

@ -10,7 +10,7 @@ use SilverStripe\i18n\i18n;
class TimeFieldTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
i18n::set_locale('en_NZ');

View File

@ -15,7 +15,7 @@ class DBDateTest extends SapphireTest
{
protected $oldError = null;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->oldError = error_reporting();
@ -24,7 +24,7 @@ class DBDateTest extends SapphireTest
i18n::set_locale('en_NZ');
}
public function tearDown()
protected function tearDown()
{
$this->restoreNotices();
parent::tearDown();

View File

@ -12,7 +12,7 @@ use SilverStripe\Security\Member;
*/
class DBDatetimeTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
i18n::set_locale('en_NZ');

View File

@ -14,7 +14,7 @@ use SilverStripe\View\Parsers\ShortcodeParser;
class DBHTMLTextTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
@ -24,7 +24,7 @@ class DBHTMLTextTest extends SapphireTest
ShortcodeParser::set_active('htmltest');
}
public function tearDown()
protected function tearDown()
{
ShortcodeParser::set_active('default');
parent::tearDown();

View File

@ -10,7 +10,7 @@ use SilverStripe\Security\Member;
class DBTimeTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
i18n::set_locale('en_NZ');

View File

@ -20,7 +20,7 @@ class DataDifferencerTest extends SapphireTest
DataDifferencerTest\HasOneRelationObject::class
);
public function setUp()
protected function setUp()
{
parent::setUp();
@ -39,7 +39,7 @@ class DataDifferencerTest extends SapphireTest
}
}
public function tearDown()
protected function tearDown()
{
TestAssetStore::reset();
parent::tearDown();

View File

@ -15,7 +15,7 @@ class DecimalTest extends SapphireTest
DecimalTest\TestObject::class
);
public function setUp()
protected function setUp()
{
parent::setUp();
$this->testDataObject = $this->objFromFixture(DecimalTest\TestObject::class, 'test-dataobject');

View File

@ -21,13 +21,13 @@ class ManyManyThroughListTest extends SapphireTest
ManyManyThroughListTest\VersionedObject::class,
];
public function setUp()
protected function setUp()
{
parent::setUp();
DataObject::reset();
}
public function tearDown()
protected function tearDown()
{
DataObject::reset();
parent::tearDown();

View File

@ -6,6 +6,7 @@ use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\PaginatedList;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\ORM\Tests\DataObjectTest\Player;
use SilverStripe\View\ArrayData;
@ -58,7 +59,7 @@ class PaginatedListTest extends SapphireTest
public function testSetPaginationFromQuery()
{
$query = $this->getMock('SilverStripe\\ORM\\Queries\\SQLSelect');
$query = $this->getMockBuilder(SQLSelect::class)->getMock();
$query->expects($this->once())
->method('getLimit')
->will($this->returnValue(array('limit' => 15, 'start' => 30)));

View File

@ -23,13 +23,13 @@ class SQLSelectTest extends SapphireTest
protected $oldDeprecation = null;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->oldDeprecation = Deprecation::dump_settings();
}
public function tearDown()
protected function tearDown()
{
Deprecation::restore_settings($this->oldDeprecation);
parent::tearDown();

View File

@ -11,7 +11,7 @@ use SilverStripe\ORM\Search\FulltextSearchable;
class FulltextSearchableTest extends SapphireTest
{
public function setUp()
protected function setUp()
{
parent::setUp();
@ -23,7 +23,7 @@ class FulltextSearchableTest extends SapphireTest
* properly at the end of the test. This becomes apparent when a later test tries to
* ALTER TABLE File and add fulltext indexes with the InnoDB table type.
*/
public function tearDown()
protected function tearDown()
{
parent::tearDown();

View File

@ -30,7 +30,7 @@ class VersionedOwnershipTest extends SapphireTest
protected static $fixture_file = 'VersionedOwnershipTest.yml';
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -24,7 +24,7 @@ class BasicAuthTest extends FunctionalTest
ControllerSecuredWithoutPermission::class,
];
public function setUp()
protected function setUp()
{
parent::setUp();

View File

@ -25,7 +25,7 @@ class MemberAuthenticatorTest extends SapphireTest
protected $defaultUsername = null;
protected $defaultPassword = null;
public function setUp()
protected function setUp()
{
parent::setUp();
@ -35,7 +35,7 @@ class MemberAuthenticatorTest extends SapphireTest
Security::setDefaultAdmin('admin', 'password');
}
public function tearDown()
protected function tearDown()
{
Security::setDefaultAdmin($this->defaultUsername, $this->defaultPassword);
parent::tearDown();

View File

@ -49,7 +49,7 @@ class MemberTest extends FunctionalTest
/**
* @skipUpgrade
*/
public function setUp()
protected function setUp()
{
parent::setUp();
@ -58,7 +58,7 @@ class MemberTest extends FunctionalTest
Member::set_password_validator(null);
}
public function tearDown()
protected function tearDown()
{
Member::config()->unique_identifier_field = $this->orig['Member_unique_identifier_field'];
parent::tearDown();

View File

@ -12,7 +12,7 @@ use SilverStripe\Security\Tests\PasswordEncryptorTest\TestEncryptor;
class PasswordEncryptorTest extends SapphireTest
{
public function tearDown()
protected function tearDown()
{
parent::tearDown();
PasswordEncryptor_Blowfish::set_cost(10);

View File

@ -15,7 +15,7 @@ class SecurityDefaultAdminTest extends SapphireTest
protected $defaultUsername = null;
protected $defaultPassword = null;
public function setUp()
protected function setUp()
{
parent::setUp();
@ -33,7 +33,7 @@ class SecurityDefaultAdminTest extends SapphireTest
Permission::flush_permission_cache();
}
public function tearDown()
protected function tearDown()
{
Security::setDefaultAdmin($this->defaultUsername, $this->defaultPassword);
Permission::flush_permission_cache();

View File

@ -45,7 +45,7 @@ class SecurityTest extends FunctionalTest
SecurityTest\SecuredController::class,
];
public function setUp()
protected function setUp()
{
// This test assumes that MemberAuthenticator is present and the default
$this->priorAuthenticators = Authenticator::get_authenticators();
@ -70,7 +70,7 @@ class SecurityTest extends FunctionalTest
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_url', '/');
}
public function tearDown()
protected function tearDown()
{
// Restore selected authenticator

View File

@ -11,7 +11,7 @@ class ShortcodeParserTest extends SapphireTest
protected $arguments, $contents, $tagName, $parser;
protected $extra = array();
public function setUp()
protected function setUp()
{
ShortcodeParser::get('test')->register('test_shortcode', array($this, 'shortcodeSaver'));
$this->parser = ShortcodeParser::get('test');
@ -19,7 +19,7 @@ class ShortcodeParserTest extends SapphireTest
parent::setUp();
}
public function tearDown()
protected function tearDown()
{
ShortcodeParser::get('test')->unregister('test_shortcode');
@ -314,7 +314,8 @@ class ShortcodeParserTest extends SapphireTest
public function testNoParseAttemptIfNoCode()
{
$stub = $this->getMock('SilverStripe\\View\\Parsers\\ShortcodeParser', array('replaceElementTagsWithMarkers'));
$stub = $this->getMockBuilder(ShortcodeParser::class)->setMethods(array('replaceElementTagsWithMarkers'))
->getMock();
$stub->register(
'test',
function () {

View File

@ -20,13 +20,13 @@ class RequirementsTest extends SapphireTest
static $html_template = '<html><head></head><body></body></html>';
public function setUp()
protected function setUp()
{
parent::setUp();
TestAssetStore::activate('RequirementsTest'); // Set backend root to /RequirementsTest
}
public function tearDown()
protected function tearDown()
{
TestAssetStore::reset();
parent::tearDown();

View File

@ -45,7 +45,7 @@ class SSViewerTest extends SapphireTest
SSViewerTest\TestObject::class,
);
public function setUp()
protected function setUp()
{
parent::setUp();
SSViewer::config()->update('source_file_comments', false);
@ -54,7 +54,7 @@ class SSViewerTest extends SapphireTest
$this->oldServer = $_SERVER;
}
public function tearDown()
protected function tearDown()
{
$_SERVER = $this->oldServer;
TestAssetStore::reset();
@ -201,7 +201,8 @@ class SSViewerTest extends SapphireTest
public function testRequirements()
{
$requirements = $this->getMock("SilverStripe\\View\\Requirements_Backend", array("javascript", "css"));
$requirements = $this->getMockBuilder(Requirements_Backend::class)->setMethods(array("javascript", "css"))
->getMock();
$jsFile = FRAMEWORK_DIR . '/tests/forms/a.js';
$cssFile = FRAMEWORK_DIR . '/tests/forms/a.js';

View File

@ -17,13 +17,13 @@ class i18nTest extends SapphireTest
{
use i18nTestManifest;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->setupManifest();
}
public function tearDown()
protected function tearDown()
{
$this->tearDownManifest();
parent::tearDown();

View File

@ -20,7 +20,7 @@ class i18nTextCollectorTest extends SapphireTest
*/
protected $alternateBaseSavePath = null;
public function setUp()
protected function setUp()
{
parent::setUp();
$this->setupManifest();
@ -29,7 +29,7 @@ class i18nTextCollectorTest extends SapphireTest
Filesystem::makeFolder($this->alternateBaseSavePath);
}
public function tearDown()
protected function tearDown()
{
if (is_dir($this->alternateBaseSavePath)) {
Filesystem::removeFolder($this->alternateBaseSavePath);