Commit 5ce0364f authored by heddn's avatar heddn Committed by heddn

Issue #3131401 by heddn: Return type void in tests

parent b992e26f
......@@ -25,5 +25,8 @@
"suggest": {
"sainsburys/guzzle-oauth2-plugin": "3.0 required for the OAuth2 authentication plugin",
"ext-soap": "*"
},
"requires": {
"php": ">=7.1"
}
}
......@@ -2,8 +2,7 @@ type: module
name: Migrate Example
description: 'Examples of how Drupal 8+ migration compares to previous versions.'
package: Examples
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:migrate
- migrate_plus:migrate_example_setup
......
......@@ -2,8 +2,7 @@ type: module
name: Migrate Example Setup
description: 'Separate site configuration for the example from the actual migration.'
package: Migration
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
hidden: true
dependencies:
- drupal:comment
......
......@@ -2,8 +2,7 @@ type: module
name: Migrate Example (Advanced)
description: 'Specialized examples of Drupal 8+ migration.'
package: Examples
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:migrate
- migrate_plus:migrate_example_advanced_setup
......
......@@ -2,8 +2,7 @@ type: module
name: Migrate Advanced Example Setup
description: 'Separate site configuration for the example from the actual migration.'
package: Migration
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
hidden: true
dependencies:
- drupal:comment
......
......@@ -2,8 +2,7 @@ type: module
name: Migrate JSON Example
description: 'Simple JSON Migration example'
package: Examples
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:migrate
- migrate_plus:migrate_plus
......@@ -2,7 +2,6 @@ type: module
name: Migrate Plus
description: 'Enhancements to core migration support'
package: Migration
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:migrate
......@@ -2,8 +2,7 @@ type: module
name: Migrate Plus Test
description: 'Test module to test Migrate Plus.'
package: Testing
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:migrate
- migrate_plus:migrate_plus
......@@ -39,7 +39,7 @@ class LoadTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($this->user);
......@@ -48,7 +48,7 @@ class LoadTest extends BrowserTestBase {
/**
* Tests that the home page loads with a 200 response.
*/
public function testLoad() {
public function testLoad(): void {
$this->drupalGet(Url::fromRoute('<front>'));
$this->assertSession()->statusCodeEquals(200);
}
......
......@@ -50,7 +50,7 @@ class EntityLookupAccessTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installSchema('system', ['sequences']);
$this->installEntitySchema('entity_test');
......@@ -64,7 +64,7 @@ class EntityLookupAccessTest extends KernelTestBase {
/**
* Tests that access is honored for entity lookups.
*/
public function testEntityLookupAccessCheck() {
public function testEntityLookupAccessCheck(): void {
$definition = [
'source' => [
'plugin' => 'embedded_data',
......
......@@ -29,7 +29,7 @@ class MigrateTableIncrementTest extends MigrateTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->connection = $this->container->get('database');
$this->connection->schema()->createTable(static::TABLE_NAME, [
......@@ -57,7 +57,7 @@ class MigrateTableIncrementTest extends MigrateTestBase {
/**
* {@inheritdoc}
*/
protected function tearDown() {
protected function tearDown(): void {
$this->connection->schema()->dropTable(static::TABLE_NAME);
parent::tearDown();
}
......@@ -68,7 +68,7 @@ class MigrateTableIncrementTest extends MigrateTestBase {
* @return array
* The migration definition.
*/
public function tableDestinationMigration() {
public function tableDestinationMigration(): array {
return [
'dummy table' => [
[
......
......@@ -39,7 +39,7 @@ class MigrateTableTest extends MigrateTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->connection = $this->container->get('database');
......@@ -98,7 +98,7 @@ class MigrateTableTest extends MigrateTestBase {
/**
* {@inheritdoc}
*/
protected function tearDown() {
protected function tearDown(): void {
$this->sourceDatabase->schema()->dropTable(static::SOURCE_TABLE_NAME);
$this->connection->schema()->dropTable(static::DEST_TABLE_NAME);
parent::tearDown();
......@@ -157,7 +157,7 @@ class MigrateTableTest extends MigrateTestBase {
/**
* Tests table migration.
*/
public function testTableMigration() {
public function testTableMigration(): void {
$definition = [
'id' => 'migration_table_test',
'migration_tags' => ['Testing'],
......@@ -214,7 +214,7 @@ class MigrateTableTest extends MigrateTestBase {
*
* @dataProvider tableDestinationMigration
*/
public function testTableUpdate(array $definition) {
public function testTableUpdate(array $definition): void {
// Make sure migration overwrites the original data for the first row.
$original_values = [
'data' => 'dummy value',
......
......@@ -37,7 +37,7 @@ class MigrationConfigEntityTest extends MigrateTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->pluginManager = \Drupal::service('plugin.manager.migration');
$this->installConfig('migrate_plus');
......@@ -48,7 +48,7 @@ class MigrationConfigEntityTest extends MigrateTestBase {
/**
* Tests cache invalidation.
*/
public function testCacheInvalidation() {
public function testCacheInvalidation(): void {
$config = Migration::create([
'id' => 'test',
'status' => TRUE,
......@@ -77,7 +77,7 @@ class MigrationConfigEntityTest extends MigrateTestBase {
/**
* Tests migration status.
*/
public function testMigrationStatus() {
public function testMigrationStatus(): void {
$configs = [
[
'id' => 'test_active',
......@@ -115,7 +115,7 @@ class MigrationConfigEntityTest extends MigrateTestBase {
/**
* Tests migration from configuration.
*/
public function testImport() {
public function testImport(): void {
$this->installConfig('migrate_plus_test');
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->pluginManager->createInstance('fruit_terms');
......
......@@ -21,7 +21,7 @@ class MigrationGroupTest extends KernelTestBase {
/**
* Test that group configuration is properly merged into specific migrations.
*/
public function testConfigurationMerge() {
public function testConfigurationMerge(): void {
$group_id = 'test_group';
/** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group */
......@@ -96,7 +96,7 @@ class MigrationGroupTest extends KernelTestBase {
/**
* Test that deleting a group deletes its migrations.
*/
public function testDelete() {
public function testDelete(): void {
/** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group */
$group_configuration = [
'id' => 'test_group',
......@@ -130,7 +130,7 @@ class MigrationGroupTest extends KernelTestBase {
/**
* Test that migrations without a group are assigned to the default group.
*/
public function testDefaultGroup() {
public function testDefaultGroup(): void {
$this->installConfig('migrate_plus_test');
/** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $pluginManager */
......
......@@ -32,7 +32,7 @@ class DefaultEntityValueTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installSchema('system', ['sequences']);
$this->installEntitySchema('user');
......@@ -43,7 +43,7 @@ class DefaultEntityValueTest extends KernelTestBase {
*
* @covers ::transform
*/
public function testDefaultEntityValue() {
public function testDefaultEntityValue(): void {
// Create a user.
$editorial_user = $this->createUser([], 'editorial');
$journalist_user = $this->createUser([], 'journalist');
......
......@@ -71,7 +71,7 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
// Create article content type.
$values = [
......@@ -132,7 +132,7 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
*
* @covers ::transform
*/
public function testTransform(array $definition, array $expected, array $preSeed = []) {
public function testTransform(array $definition, array $expected, array $preSeed = []): void {
// Pre seed some test data.
foreach ($preSeed as $storageName => $values) {
// If the first element of $values is a non-empty array, create multiple
......@@ -149,8 +149,11 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
/** @var \Drupal\migrate\Plugin\Migration $migration */
$migration = $this->migrationPluginManager->createStubMigration($definition);
$reflector = new \ReflectionObject($migration->getDestinationPlugin());
$attribute = $reflector->getProperty('storage');
$attribute->setAccessible(true);
/** @var \Drupal\Core\Entity\EntityStorageBase $storage */
$storage = $this->readAttribute($migration->getDestinationPlugin(), 'storage');
$storage = $attribute->getValue($migration->getDestinationPlugin());
$migrationExecutable = (new MigrateExecutable($migration, $this));
$migrationExecutable->import();
......
......@@ -32,7 +32,7 @@ class EntityLookupTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->installSchema('system', ['sequences']);
$this->installEntitySchema('user');
......@@ -46,7 +46,7 @@ class EntityLookupTest extends KernelTestBase {
*
* @covers ::transform
*/
public function testLookupEntityWithoutBundles() {
public function testLookupEntityWithoutBundles(): void {
// Create a user.
$known_user = $this->createUser([], 'lucuma');
// Setup test migration objects.
......
......@@ -58,7 +58,7 @@ class FileBlobTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->pluginManager = $this->container->get('plugin.manager.migrate.process');
......@@ -200,7 +200,7 @@ EOT;
*
* @covers ::transform
*/
public function testFileCreation() {
public function testFileCreation(): void {
/** @var \Drupal\migrate\MigrateExecutableInterface $executable */
$executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
$row = new Row([], []);
......
......@@ -18,7 +18,7 @@ class HttpTest extends KernelTestBase {
*
* @dataProvider headerDataProvider
*/
public function testHttpHeaders(array $definition, array $expected, array $preSeed = []) {
public function testHttpHeaders(array $definition, array $expected, array $preSeed = []): void {
$http = new Http($definition, 'http', []);
$this->assertEquals($expected, $http->getRequestHeaders());
}
......@@ -29,7 +29,7 @@ class HttpTest extends KernelTestBase {
* @return array
* The test cases
*/
public function headerDataProvider() {
public function headerDataProvider(): array {
return [
'dummy headers specified' => [
'definition' => [
......
......@@ -33,7 +33,7 @@ class JsonTest extends KernelTestBase {
* @throws \Drupal\Component\Plugin\Exception\PluginException
* @throws \Exception
*/
public function testMissingProperties($file, array $ids, array $fields, array $expected) {
public function testMissingProperties($file, array $ids, array $fields, array $expected): void {
$path = $this->container
->get('module_handler')
->getModule('migrate_plus')
......@@ -69,7 +69,7 @@ class JsonTest extends KernelTestBase {
* @return array
* The test cases.
*/
public function jsonBaseDataProvider() {
public function jsonBaseDataProvider(): array {
return [
'missing properties' => [
'file' => 'missing_properties.json',
......
......@@ -48,7 +48,7 @@ class SimpleXmlTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->path = $this->container->get('module_handler')
->getModule('migrate_plus')->getPath();
......@@ -89,7 +89,7 @@ class SimpleXmlTest extends KernelTestBase {
/**
* Tests reducing single values.
*/
public function testReduceSingleValue() {
public function testReduceSingleValue(): void {
$url = $this->path . '/tests/data/simple_xml_reduce_single_value.xml';
$this->configuration['urls'][0] = $url;
$parser = $this->pluginManager->createInstance('simple_xml', $this->configuration);
......@@ -101,7 +101,7 @@ class SimpleXmlTest extends KernelTestBase {
*
* XML file with lots of different white spaces before the starting tag.
*/
public function testReadNonStandardXmlWhitespace() {
public function testReadNonStandardXmlWhitespace(): void {
$url = $this->path . '/tests/data/simple_xml_invalid_multi_whitespace.xml';
$this->configuration['urls'][0] = $url;
......@@ -114,7 +114,7 @@ class SimpleXmlTest extends KernelTestBase {
*
* XML file with one empty line before the starting tag.
*/
public function testReadNonStandardXml2() {
public function testReadNonStandardXml2(): void {
$url = $this->path . '/tests/data/simple_xml_invalid_single_line.xml';
$this->configuration['urls'][0] = $url;
......@@ -127,7 +127,7 @@ class SimpleXmlTest extends KernelTestBase {
*
* @throws \Drupal\Migrate\MigrateException
*/
public function testReadBrokenXmlMissingTag() {
public function testReadBrokenXmlMissingTag(): void {
$url = $this->path . '/tests/data/simple_xml_broken_missing_tag.xml';
$this->configuration['urls'][0] = $url;
$this->expectException(MigrateException::class);
......@@ -141,7 +141,7 @@ class SimpleXmlTest extends KernelTestBase {
*
* @throws \Drupal\Migrate\MigrateException
*/
public function testReadBrokenXmlTagMismatch() {
public function testReadBrokenXmlTagMismatch(): void {
$url = $this->path . '/tests/data/simple_xml_broken_tag_mismatch.xml';
$this->configuration['urls'][0] = $url;
......@@ -157,7 +157,7 @@ class SimpleXmlTest extends KernelTestBase {
*
* @throws \Drupal\Migrate\MigrateException
*/
public function testReadNonXml() {
public function testReadNonXml(): void {
$url = $this->path . '/tests/data/simple_xml_non_xml.xml';
$this->configuration['urls'][0] = $url;
......@@ -172,7 +172,7 @@ class SimpleXmlTest extends KernelTestBase {
*
* @throws \Drupal\Migrate\MigrateException
*/
public function testReadNonExistingXml() {
public function testReadNonExistingXml(): void {
$url = $this->path . '/tests/data/simple_xml_non_existing.xml';
$this->configuration['urls'][0] = $url;
......
......@@ -15,7 +15,7 @@ class DataParserPluginBaseTest extends MigrateTestCase {
/**
* @covers ::nextSource
*/
public function testNextSourceWithOneUrl() {
public function testNextSourceWithOneUrl(): void {
$parser = $this->getMockedDataParser();
$parser->expects($this->once())
->method('openSourceUrl')
......@@ -26,7 +26,7 @@ class DataParserPluginBaseTest extends MigrateTestCase {
/**
* @covers ::nextSource
*/
public function testNextSourceWithoutUrls() {
public function testNextSourceWithoutUrls(): void {
$config = [
'urls' => [],
];
......@@ -40,7 +40,7 @@ class DataParserPluginBaseTest extends MigrateTestCase {
/**
* @covers ::count
*/
public function testCountWithoutUrls() {
public function testCountWithoutUrls(): void {
$config = [
'urls' => [],
];
......
......@@ -83,14 +83,14 @@ class FileTest extends MigrateTestCase {
/**
* Set up test environment.
*/
public function setUp() {
public function setUp(): void {
$this->baseDir = vfsStream::setup(self::BASE_DIRECTORY);
}
/**
* Test fetching a valid file.
*/
public function testFetchFile() {
public function testFetchFile(): void {
$file_name = 'file.json';
$file_path = vfsStream::url(implode(DIRECTORY_SEPARATOR, [self::BASE_DIRECTORY, $file_name]));
$migration_config = $this->specificMigrationConfig + [
......@@ -118,7 +118,7 @@ class FileTest extends MigrateTestCase {
/**
* Test fetching multiple valid files.
*/
public function testFetchMultipleFiles() {
public function testFetchMultipleFiles(): void {
$number_of_files = 3;
$file_paths = [];
$file_names = [];
......@@ -159,7 +159,7 @@ class FileTest extends MigrateTestCase {
/**
* Test trying to fetch an unreadable file results in exception.
*/
public function testFetchUnreadableFile() {
public function testFetchUnreadableFile(): void {
$file_name = 'file.json';
$file_path = vfsStream::url(implode(DIRECTORY_SEPARATOR, [self::BASE_DIRECTORY, $file_name]));
$migration_config = $this->specificMigrationConfig + [
......
......@@ -87,7 +87,7 @@ class HttpTest extends MigrateTestCase {
/**
* Set up test environment.
*/
public function setUp() {
public function setUp(): void {
// Mock up a Basic authentication plugin that will be used in requests.
$basic_authenticator = $this->getMockBuilder(Basic::class)
->disableOriginalConstructor()
......@@ -107,7 +107,7 @@ class HttpTest extends MigrateTestCase {
/**
* Test 'http' data fetcher (with auth) returns an expected response.
*/
public function testFetchHttpWithAuth() {
public function testFetchHttpWithAuth(): void {
$migration_config = $this->migrationConfiguration + $this->specificMigrationConfig;
$plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
......@@ -127,7 +127,7 @@ class HttpTest extends MigrateTestCase {
/**
* Test 'http' data fetcher (without auth) returns an expected response.
*/
public function testFetchHttpNoAuth() {
public function testFetchHttpNoAuth(): void {
$migration_config = $this->migrationConfiguration + $this->specificMigrationConfig;
unset($migration_config['authentication']);
......@@ -145,7 +145,7 @@ class HttpTest extends MigrateTestCase {
/**
* Test 'http' data fetcher (with auth) dies as expected when auth fails.
*/
public function testFetchHttpAuthFailure() {
public function testFetchHttpAuthFailure(): void {
$migration_config = $this->migrationConfiguration + $this->specificMigrationConfig;
$plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
......@@ -159,7 +159,7 @@ class HttpTest extends MigrateTestCase {
/**
* Test 'http' data fetcher (with auth) dies as expected when server down.
*/
public function testFetchHttp500Error() {
public function testFetchHttp500Error(): void {
$migration_config = $this->migrationConfiguration + $this->specificMigrationConfig;
$plugin = new TestHttp($migration_config, $this->dataFetcherPluginId, $this->pluginDefinition);
......
......@@ -17,7 +17,7 @@ class ArrayPopTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
$this->plugin = new ArrayPop([], 'array_pop', []);
parent::setUp();
}
......@@ -28,7 +28,7 @@ class ArrayPopTest extends MigrateProcessTestCase {
* @return array
* An array containing input values and expected output values.
*/
public function arrayPopDataProvider() {
public function arrayPopDataProvider(): array {
return [
'indexed array' => [
'input' => ['v1', 'v2', 'v3'],
......@@ -55,7 +55,7 @@ class ArrayPopTest extends MigrateProcessTestCase {
*
* @dataProvider arrayPopDataProvider
*/
public function testArrayPop(array $input, $expected_output) {
public function testArrayPop(array $input, $expected_output): void {
$output = $this->plugin->transform($input, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($output, $expected_output);
}
......@@ -63,7 +63,7 @@ class ArrayPopTest extends MigrateProcessTestCase {
/**
* Test invalid input.
*/
public function testArrayPopFromString() {
public function testArrayPopFromString(): void {
$this->expectException(MigrateException::class);
$this->expectExceptionMessage('Input should be an array.');
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
......
......@@ -17,7 +17,7 @@ class ArrayShiftTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
protected function setUp(): void {
$this->plugin = new ArrayShift([], 'array_shift', []);
parent::setUp();
}
......@@ -28,7 +28,7 @@ class ArrayShiftTest extends MigrateProcessTestCase {
* @return array
* An array containing input values and expected output values.
*/
public function arrayShiftDataProvider() {
public function arrayShiftDataProvider(): array {
return [
'indexed array' => [
'input' => ['v1', 'v2', 'v3'],
......@@ -55,7 +55,7 @@ class ArrayShiftTest extends MigrateProcessTestCase {
*
* @dataProvider arrayShiftDataProvider
*/
public function testArrayShift(array $input, $expected_output) {
public function testArrayShift(array $input, $expected_output): void {
$output = $this->plugin->transform($input, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($output, $expected_output);
}
......@@ -63,7 +63,7 @@ class ArrayShiftTest extends MigrateProcessTestCase {
/**
* Test invalid input.
*/
public function testArrayShiftFromString() {
public function testArrayShiftFromString(): void {
$this->expectException(MigrateException::class);
$this->expectExceptionMessage('Input should be an array.');
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
......
......@@ -41,14 +41,14 @@ class DomApplyStylesTest extends MigrateProcessTestCase {
/**
* Mock a config factory object.
*
* @var Drupal\Core\Config\ConfigFactoryInterface
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory = NULL;
/**