diff --git a/core/modules/user/src/Plugin/migrate/source/d6/User.php b/core/modules/user/src/Plugin/migrate/source/d6/User.php index 1260ca75e1c7fe937986d99f71b7e9c2b64e514c..56f68bf8c80220ce1cef53ad3d9487d097465308 100644 --- a/core/modules/user/src/Plugin/migrate/source/d6/User.php +++ b/core/modules/user/src/Plugin/migrate/source/d6/User.php @@ -100,6 +100,7 @@ protected function baseFields() { 'name' => $this->t('Username'), 'pass' => $this->t('Password'), 'mail' => $this->t('Email address'), + 'theme' => $this->t('Theme'), 'signature' => $this->t('Signature'), 'signature_format' => $this->t('Signature format'), 'created' => $this->t('Registered timestamp'), diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c321185713070c2b740de686c889bc454cb3af3b --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/ProfileFieldTest.php @@ -0,0 +1,129 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the profile_field source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\ProfileField + * @group user + */ +class ProfileFieldTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = [ + [ + 'source_data' => [], + 'expected_data' => [], + ], + ]; + + $profile_fields = [ + [ + 'fid' => 1, + 'title' => 'First name', + 'name' => 'profile_first_name', + 'explanation' => 'First name user', + 'category' => 'profile', + 'page' => '', + 'type' => 'textfield', + 'weight' => 0, + 'required' => 1, + 'register' => 0, + 'visibility' => 2, + 'autocomplete' => 0, + 'options' => '', + ], + [ + 'fid' => 2, + 'title' => 'Last name', + 'name' => 'profile_last_name', + 'explanation' => 'Last name user', + 'category' => 'profile', + 'page' => '', + 'type' => 'textfield', + 'weight' => 0, + 'required' => 0, + 'register' => 0, + 'visibility' => 2, + 'autocomplete' => 0, + 'options' => '', + ], + [ + 'fid' => 3, + 'title' => 'Policy', + 'name' => 'profile_policy', + 'explanation' => 'A checkbox that say if you accept policy of website', + 'category' => 'profile', + 'page' => '', + 'type' => 'checkbox', + 'weight' => 0, + 'required' => 1, + 'register' => 1, + 'visibility' => 2, + 'autocomplete' => 0, + 'options' => '', + ], + [ + 'fid' => 4, + 'title' => 'Color', + 'name' => 'profile_color', + 'explanation' => 'A selection that allows user to select a color', + 'category' => 'profile', + 'page' => '', + 'type' => 'selection', + 'weight' => 0, + 'required' => 0, + 'register' => 0, + 'visibility' => 2, + 'autocomplete' => 0, + 'options' => "red\nblue\ngreen", + ], + ]; + + $tests[0]['source_data']['profile_fields'] = $profile_fields; + + // Profile values are merged with pre-set options of a "selection" field. + $tests[0]['source_data']['profile_values'] = [ + [ + 'fid' => 4, + 'uid' => 1, + 'value' => 'yellow', + ] + ]; + + // Expected options are: + // for "checkbox" fields - array with NULL options + // for "selection" fields - options in both keys and values + $expected_field_options = [ + '', + '', + [NULL, NULL], + [ + 'red' => 'red', + 'blue' => 'blue', + 'green' => 'green', + 'yellow' => 'yellow', + ] + ]; + + $tests[0]['expected_data'] = $profile_fields; + + foreach ($tests[0]['expected_data'] as $delta => $row) { + $tests[0]['expected_data'][$delta]['options'] = $expected_field_options[$delta]; + } + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/UserPictureInstanceTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/UserPictureInstanceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d9e77edde03a2c6944b335f198482bf5c7879ea6 --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/UserPictureInstanceTest.php @@ -0,0 +1,55 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the user_picture_instance source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\UserPictureInstance + * @group user + */ +class UserPictureInstanceTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['variable'] = [ + [ + 'name' => 'file_directory', + 'value' => serialize(NULL), + ], + [ + 'name' => 'user_picture_file_size', + 'value' => serialize(128), + ], + [ + 'name' => 'user_picture_dimensions', + 'value' => serialize('128x128'), + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'id' => '', + 'file_directory' => 'pictures', + 'max_filesize' => '128KB', + 'max_resolution' => '128x128', + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Unit/Migrate/d6/ProfileFieldValuesTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldValuesTest.php similarity index 57% rename from core/modules/user/tests/src/Unit/Migrate/d6/ProfileFieldValuesTest.php rename to core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldValuesTest.php index 7e4b62641e7e12cd3a97945bd4177e807a4f0418..26c2ed55f8d865dd955149040bc0adae7f3ed86a 100644 --- a/core/modules/user/tests/src/Unit/Migrate/d6/ProfileFieldValuesTest.php +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldValuesTest.php @@ -1,52 +1,44 @@ <?php -namespace Drupal\Tests\user\Unit\Migrate\d6; +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6; -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; -use Drupal\user\Plugin\migrate\source\d6\ProfileFieldValues; +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; /** * Tests the d6_profile_field_values source plugin. * + * @covers \Drupal\user\Plugin\migrate\source\d6\ProfileFieldValues * @group user */ -class ProfileFieldValuesTest extends MigrateSqlSourceTestCase { +class ProfileFieldValuesTest extends MigrateSqlSourceTestBase { - const PLUGIN_CLASS = ProfileFieldValues::class; - - protected $migrationConfiguration = array( - 'id' => 'test', - 'source' => array( - 'plugin' => 'd6_profile_field_values', - ), - ); - - protected $expectedResults = array( - array( - 'profile_color' => array('red'), - 'profile_biography' => array('Lorem ipsum dolor sit amet...'), - 'uid' => '2', - ), - ); + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; /** * {@inheritdoc} */ - protected function setUp() { - $this->databaseContents['profile_values'] = array( - array( + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['profile_values'] = [ + [ 'fid' => '8', 'uid' => '2', 'value' => 'red', - ), - array( + ], + [ 'fid' => '9', 'uid' => '2', 'value' => 'Lorem ipsum dolor sit amet...', - ), - ); - $this->databaseContents['profile_fields'] = array( - array( + ], + ]; + + $tests[0]['source_data']['profile_fields'] = [ + [ 'fid' => '8', 'title' => 'Favorite color', 'name' => 'profile_color', @@ -60,8 +52,8 @@ protected function setUp() { 'visibility' => '2', 'autocomplete' => '1', 'options' => '', - ), - array( + ], + [ 'fid' => '9', 'title' => 'Biography', 'name' => 'profile_biography', @@ -75,9 +67,19 @@ protected function setUp() { 'visibility' => '2', 'autocomplete' => '0', 'options' => '', - ), - ); - parent::setUp(); + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'profile_color' => ['red'], + 'profile_biography' => ['Lorem ipsum dolor sit amet...'], + 'uid' => '2', + ], + ]; + + return $tests; } } diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1a841d32dfa53a97c063f5ed53dab1a99cb8512c --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php @@ -0,0 +1,87 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the d6_user_role source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\d6\Role + * @group user + */ +class RoleTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = [ + [ + 'source_data' => [], + 'expected_data' => [], + ], + ]; + + $roles = [ + [ + 'rid' => 1, + 'name' => 'anonymous user', + 'permissions' => [ + 'access content', + ], + ], + [ + 'rid' => 2, + 'name' => 'authenticated user', + 'permissions' => [ + 'access comments', + 'access content', + 'post comments', + 'post comments without approval', + ], + ], + [ + 'rid' => 3, + 'name' => 'administrator', + 'permissions' => [ + 'access comments', + 'administer comments', + 'post comments', + 'post comments without approval', + 'access content', + 'administer content types', + 'administer nodes', + ], + ], + ]; + + // The source data. + foreach ($roles as $role) { + $tests[0]['source_data']['permission'][] = [ + 'rid' => $role['rid'], + 'perm' => implode(', ', $role['permissions']), + ]; + unset($role['permissions']); + $tests[0]['source_data']['role'][] = $role; + } + + $tests[0]['source_data']['filter_formats'] = [ + [ + 'format' => 1, + 'roles' => '', + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = $roles; + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserPictureFileTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserPictureFileTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2724d35f59f6692028337d9b7c274f4c8443598b --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserPictureFileTest.php @@ -0,0 +1,49 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the d6_user_picture_file source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\d6\UserPictureFile + * @group user + */ +class UserPictureFileTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['users'] = [ + [ + 'uid' => '2', + 'picture' => 'core/modules/simpletest/files/image-test.jpg', + ], + [ + 'uid' => '15', + 'picture' => '', + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'uid' => '2', + 'picture' => 'core/modules/simpletest/files/image-test.jpg', + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserPictureTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserPictureTest.php new file mode 100644 index 0000000000000000000000000000000000000000..aea6afa7c90ff39a48412557e7a667c352807f9a --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserPictureTest.php @@ -0,0 +1,46 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the d6_user_picture source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\d6\UserPicture + * @group user + */ +class UserPictureTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['users'] = [ + [ + 'uid' => 1, + 'access' => 1382835435, + 'picture' => 'sites/default/files/pictures/picture-1.jpg', + ], + [ + 'uid' => 2, + 'access' => 1382835436, + 'picture' => 'sites/default/files/pictures/picture-2.jpg', + ], + ]; + + // User picture data model is identical in source input and output. + $tests[0]['expected_data'] = $tests[0]['source_data']['users']; + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1dc34a7cd6018907ff6de1879e902c2468d48341 --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/UserTest.php @@ -0,0 +1,83 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the d6_user source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\d6\User + * @group user + */ +class UserTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['users'] = [ + [ + 'uid' => 2, + 'name' => 'admin', + 'pass' => '1234', + 'mail' => 'admin@example.com', + 'theme' => '', + 'signature' => '', + 'signature_format' => 0, + 'created' => 1279402616, + 'access' => 1322981278, + 'login' => 1322699994, + 'status' => 0, + 'timezone' => 'America/Lima', + 'language' => 'en', + // @todo Add the file when needed. + 'picture' => 'sites/default/files/pictures/picture-1.jpg', + 'init' => 'admin@example.com', + 'data' => NULL, + ], + [ + 'uid' => 4, + 'name' => 'alice', + // @todo d6 hash? + 'pass' => '1234', + 'mail' => 'alice@example.com', + 'theme' => '', + 'signature' => '', + 'signature_format' => 0, + 'created' => 1322981368, + 'access' => 1322982419, + 'login' => 132298140, + 'status' => 0, + 'timezone' => 'America/Lima', + 'language' => 'en', + 'picture' => '', + 'init' => 'alice@example.com', + 'data' => NULL, + ], + ]; + + // getDatabase() will not create empty tables, so we need to insert data + // even if it's irrelevant to the test. + $tests[0]['source_data']['users_roles'] = [ + [ + 'uid' => 99, + 'rid' => 99, + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = $tests[0]['source_data']['users']; + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8e14d63c9d94df5afa1a013ccc6a4c86f0c6607d --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php @@ -0,0 +1,120 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d7; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests the d7_user source plugin. + * + * @covers \Drupal\user\Plugin\migrate\source\d7\User + * @group user + */ +class UserTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['user', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['field_config_instance'] = [ + [ + 'id' => '33', + 'field_id' => '11', + 'field_name' => 'field_file', + 'entity_type' => 'user', + 'bundle' => 'user', + 'data' => 'a:0:{}', + 'deleted' => '0', + ], + ]; + $tests[0]['source_data']['field_data_field_file'] = [ + [ + 'entity_type' => 'user', + 'bundle' => 'user', + 'deleted' => 0, + 'entity_id' => 2, + 'revision_id' => NULL, + 'language' => 'und', + 'delta' => 0, + 'field_file_fid' => 99, + 'field_file_display' => 1, + 'field_file_description' => 'None', + ], + ]; + $tests[0]['source_data']['role'] = [ + [ + 'rid' => 2, + 'name' => 'authenticated user', + 'weight' => 0, + ], + ]; + $tests[0]['source_data']['users'] = [ + [ + 'uid' => '2', + 'name' => 'Odo', + 'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8', + 'mail' => 'odo@local.host', + 'theme' => '', + 'signature' => '', + 'signature_format' => 'filtered_html', + 'created' => '1432750741', + 'access' => '0', + 'login' => '0', + 'status' => '1', + 'timezone' => 'America/Chicago', + 'language' => '', + 'picture' => '0', + 'init' => 'odo@local.host', + 'data' => 'a:1:{s:7:"contact";i:1;}', + ], + ]; + $tests[0]['source_data']['users_roles'] = [ + [ + 'uid' => 2, + 'rid' => 2, + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'uid' => '2', + 'name' => 'Odo', + 'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8', + 'mail' => 'odo@local.host', + 'signature' => '', + 'signature_format' => 'filtered_html', + 'created' => '1432750741', + 'access' => '0', + 'login' => '0', + 'status' => '1', + 'timezone' => 'America/Chicago', + 'language' => '', + 'picture' => '0', + 'init' => 'odo@local.host', + 'roles' => [2], + 'data' => [ + 'contact' => 1, + ], + 'field_file' => [ + [ + 'fid' => 99, + 'display' => 1, + 'description' => 'None', + ], + ], + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/user/tests/src/Unit/Migrate/ProfileFieldTest.php b/core/modules/user/tests/src/Unit/Migrate/ProfileFieldTest.php deleted file mode 100644 index a639bf4186ba511e8ca43ccabe7a687858c4eca3..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Migrate/ProfileFieldTest.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Migrate; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests profile_field source plugin. - * - * @group user - */ -class ProfileFieldTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\ProfileField'; - - protected $migrationConfiguration = [ - 'id' => 'test_profile_fields', - 'source' => [ - 'plugin' => 'd6_profile_field', - ], - ]; - - protected $expectedResults = [ - [ - 'fid' => 1, - 'title' => 'First name', - 'name' => 'profile_first_name', - 'explanation' => 'First name user', - 'category' => 'profile', - 'page' => '', - 'type' => 'textfield', - 'weight' => 0, - 'required' => 1, - 'register' => 0, - 'visibility' => 2, - 'autocomplete' => 0, - 'options' => [], - ], - [ - 'fid' => 2, - 'title' => 'Last name', - 'name' => 'profile_last_name', - 'explanation' => 'Last name user', - 'category' => 'profile', - 'page' => '', - 'type' => 'textfield', - 'weight' => 0, - 'required' => 0, - 'register' => 0, - 'visibility' => 2, - 'autocomplete' => 0, - 'options' => [], - ], - [ - 'fid' => 3, - 'title' => 'Policy', - 'name' => 'profile_policy', - 'explanation' => 'A checkbox that say if you accept policy of website', - 'category' => 'profile', - 'page' => '', - 'type' => 'checkbox', - 'weight' => 0, - 'required' => 1, - 'register' => 1, - 'visibility' => 2, - 'autocomplete' => 0, - 'options' => [], - ], - ]; - - /** - * Prepopulate contents with results. - */ - protected function setUp() { - $this->databaseContents['profile_fields'] = $this->expectedResults; - foreach ($this->databaseContents['profile_fields'] as &$row) { - $row['options'] = serialize([]); - } - parent::setUp(); - } - -} diff --git a/core/modules/user/tests/src/Unit/Migrate/UserPictureInstanceTest.php b/core/modules/user/tests/src/Unit/Migrate/UserPictureInstanceTest.php deleted file mode 100644 index a650704d4870e18757ef7d657c4458b5ef4823cc..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Migrate/UserPictureInstanceTest.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Migrate; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; -use Drupal\user\Plugin\migrate\source\UserPictureInstance; - -/** - * Tests user_picture_instance source plugin. - * - * @group user - */ -class UserPictureInstanceTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = UserPictureInstance::class; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'user_picture_instance', - ], - ]; - - protected $expectedResults = array( - array( - 'id' => '', - 'file_directory' => 'pictures', - 'max_filesize' => '128KB', - 'max_resolution' => '128x128', - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['variable'] = array( - array( - 'name' => 'file_directory', - 'value' => serialize(NULL), - ), - array( - 'name' => 'user_picture_file_size', - 'value' => serialize(128), - ), - array( - 'name' => 'user_picture_dimensions', - 'value' => serialize('128x128'), - ), - ); - parent::setUp(); - } - -} diff --git a/core/modules/user/tests/src/Unit/Migrate/d6/RoleTest.php b/core/modules/user/tests/src/Unit/Migrate/d6/RoleTest.php deleted file mode 100644 index 9d21b56c19fba03e392bb261fc91f9e5b0290167..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Migrate/d6/RoleTest.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Migrate\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests D6 role source plugin. - * - * @group user - */ -class RoleTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d6\Role'; - - protected $migrationConfiguration = array( - 'id' => 'test', - 'source' => array( - 'plugin' => 'd6_user_role', - ), - ); - - protected $expectedResults = array( - array( - 'rid' => 1, - 'name' => 'anonymous user', - 'permissions' => array( - 'access content', - ), - ), - array( - 'rid' => 2, - 'name' => 'authenticated user', - 'permissions' => array( - 'access comments', - 'access content', - 'post comments', - 'post comments without approval', - ), - ), - array( - 'rid' => 3, - 'name' => 'administrator', - 'permissions' => array( - 'access comments', - 'administer comments', - 'post comments', - 'post comments without approval', - 'access content', - 'administer content types', - 'administer nodes', - ), - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - foreach ($this->expectedResults as $row) { - $this->databaseContents['permission'][] = array( - 'perm' => implode(', ', $row['permissions']), - 'rid' => $row['rid'], - ); - unset($row['permissions']); - $this->databaseContents['role'][] = $row; - } - $this->databaseContents['filter_formats'][] = array( - 'format' => 1, - 'roles' => '', - ); - parent::setUp(); - } - -} diff --git a/core/modules/user/tests/src/Unit/Migrate/d6/UserPictureFileTest.php b/core/modules/user/tests/src/Unit/Migrate/d6/UserPictureFileTest.php deleted file mode 100644 index 6c045eaf3d0d5e403231bc611870e86008fa456d..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Migrate/d6/UserPictureFileTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Migrate\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; -use Drupal\user\Plugin\migrate\source\d6\UserPictureFile; - -/** - * Tests the d6_user_picture_file source plugin. - * - * @group user - */ -class UserPictureFileTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = UserPictureFile::class; - - protected $migrationConfiguration = array( - 'id' => 'test', - 'source' => array( - 'plugin' => 'd6_user_picture_file', - ), - ); - - protected $expectedResults = array( - array( - 'uid' => '2', - 'picture' => 'core/modules/simpletest/files/image-test.jpg', - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['users'] = array( - array( - 'uid' => '2', - 'picture' => 'core/modules/simpletest/files/image-test.jpg', - ), - array( - 'uid' => '15', - 'picture' => '', - ), - ); - parent::setUp(); - } - -} diff --git a/core/modules/user/tests/src/Unit/Migrate/d6/UserPictureTest.php b/core/modules/user/tests/src/Unit/Migrate/d6/UserPictureTest.php deleted file mode 100644 index 1962b17329b056d04bf7ba5332b58bf51aca8ed8..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Migrate/d6/UserPictureTest.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Migrate\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests D6 user picture source plugin. - * - * @group user - */ -class UserPictureTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d6\UserPicture'; - - protected $migrationConfiguration = array( - 'id' => 'test_user_picture', - 'source' => array( - 'plugin' => 'd6_user_picture', - ), - ); - - protected $expectedResults = array( - array( - 'uid' => 1, - 'access' => 1382835435, - 'picture' => 'sites/default/files/pictures/picture-1.jpg', - ), - array( - 'uid' => 2, - 'access' => 1382835436, - 'picture' => 'sites/default/files/pictures/picture-2.jpg', - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['users'] = $this->expectedResults; - parent::setUp(); - } - -} diff --git a/core/modules/user/tests/src/Unit/Migrate/d6/UserTest.php b/core/modules/user/tests/src/Unit/Migrate/d6/UserTest.php deleted file mode 100644 index d087451d0504cbccc14f5944d53a0342776d8bf7..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Migrate/d6/UserTest.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Migrate\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests D6 user source plugin. - * - * @group user - */ -class UserTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d6\User'; - - protected $migrationConfiguration = array( - 'id' => 'test', - 'source' => array( - 'plugin' => 'd6_user', - ), - ); - - protected $expectedResults = array( - array( - 'uid' => 2, - 'name' => 'admin', - // @todo d6 hash? - 'pass' => '1234', - 'mail' => 'admin@example.com', - 'theme' => '', - 'signature' => '', - 'signature_format' => 0, - 'created' => 1279402616, - 'access' => 1322981278, - 'login' => 1322699994, - 'status' => 0, - 'timezone' => 'America/Lima', - 'language' => 'en', - // @todo Add the file when needed. - 'picture' => 'sites/default/files/pictures/picture-1.jpg', - 'init' => 'admin@example.com', - 'data' => NULL, - ), - array( - 'uid' => 4, - 'name' => 'alice', - // @todo d6 hash? - 'pass' => '1234', - 'mail' => 'alice@example.com', - 'theme' => '', - 'signature' => '', - 'signature_format' => 0, - 'created' => 1322981368, - 'access' => 1322982419, - 'login' => 132298140, - 'status' => 0, - 'timezone' => 'America/Lima', - 'language' => 'en', - 'picture' => '', - 'init' => 'alice@example.com', - 'data' => NULL, - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - foreach ($this->expectedResults as $k => $row) { - $this->databaseContents['users'][$k] = $row; - } - // getDatabase() will not create empty tables, so we need to insert data - // even if it's irrelevant to the test. - $this->databaseContents['users_roles'] = array( - array( - 'uid' => 99, - 'rid' => 99, - ), - ); - parent::setUp(); - } - -} diff --git a/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/UserTest.php b/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/UserTest.php deleted file mode 100644 index f2c862bc67ad2aafe29ad314fd1fc3f6ac98852f..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Unit/Plugin/migrate/source/d7/UserTest.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Unit\Plugin\migrate\source\d7; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests D7 user source plugin. - * - * @group user - */ -class UserTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d7\User'; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'd7_user', - ], - ]; - - protected $expectedResults = [ - [ - 'uid' => '2', - 'name' => 'Odo', - 'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8', - 'mail' => 'odo@local.host', - 'signature' => '', - 'signature_format' => 'filtered_html', - 'created' => '1432750741', - 'access' => '0', - 'login' => '0', - 'status' => '1', - 'timezone' => 'America/Chicago', - 'language' => '', - 'picture' => '0', - 'init' => 'odo@local.host', - 'roles' => [2], - 'data' => [ - 'contact' => 1, - ], - 'field_file' => [ - [ - 'fid' => 99, - 'display' => 1, - 'description' => 'None', - ], - ], - ], - ]; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->databaseContents['users'][] = [ - 'uid' => '2', - 'name' => 'Odo', - 'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8', - 'mail' => 'odo@local.host', - 'theme' => '', - 'signature' => '', - 'signature_format' => 'filtered_html', - 'created' => '1432750741', - 'access' => '0', - 'login' => '0', - 'status' => '1', - 'timezone' => 'America/Chicago', - 'language' => '', - 'picture' => '0', - 'init' => 'odo@local.host', - 'data' => 'a:1:{s:7:"contact";i:1;}', - ]; - $this->databaseContents['users_roles'][] = [ - 'uid' => 2, - 'rid' => 2, - ]; - $this->databaseContents['role'][] = [ - 'rid' => 2, - 'name' => 'authenticated user', - 'weight' => 0, - ]; - $this->databaseContents['field_config_instance'] = [ - [ - 'id' => '33', - 'field_id' => '11', - 'field_name' => 'field_file', - 'entity_type' => 'user', - 'bundle' => 'user', - 'data' => 'a:0:{}', - 'deleted' => '0', - ], - ]; - $this->databaseContents['field_data_field_file'] = [ - [ - 'entity_type' => 'user', - 'bundle' => 'user', - 'deleted' => 0, - 'entity_id' => 2, - 'revision_id' => NULL, - 'language' => 'und', - 'delta' => 0, - 'field_file_fid' => 99, - 'field_file_display' => 1, - 'field_file_description' => 'None', - ], - ]; - parent::setUp(); - } - -}