updated contrib modules
This commit is contained in:
@@ -5,8 +5,8 @@ description: 'Test module for Profile.'
|
||||
dependencies:
|
||||
- profile
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-06-12
|
||||
version: '8.x-1.0-beta1'
|
||||
# Information added by Drupal.org packaging script on 2017-09-19
|
||||
version: '8.x-1.0-rc1'
|
||||
core: '8.x'
|
||||
project: 'profile'
|
||||
datestamp: 1497287652
|
||||
datestamp: 1505830148
|
||||
|
||||
@@ -41,6 +41,7 @@ class ProfileTabTest extends ProfileTestBase {
|
||||
'access user profiles',
|
||||
'administer profile',
|
||||
'administer profile types',
|
||||
'administer users',
|
||||
'access administration pages',
|
||||
]);
|
||||
}
|
||||
@@ -87,19 +88,20 @@ class ProfileTabTest extends ProfileTestBase {
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/config');
|
||||
$this->clickLink('User profiles');
|
||||
$this->drupalGet('admin/config/people');
|
||||
$this->clickLink('Profile types');
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl('admin/config/people/profiles');
|
||||
|
||||
$this->drupalGet('admin/people/profiles');
|
||||
$this->assertLink($profile1->label());
|
||||
$this->assertLinkByHref($profile2->toUrl('canonical')->toString());
|
||||
|
||||
$this->drupalGet('admin/people');
|
||||
$tasks = [
|
||||
['entity.user.collection', []],
|
||||
['entity.profile.collection', []],
|
||||
['entity.profile_type.collection', []],
|
||||
];
|
||||
|
||||
$this->assertLocalTasks($tasks, 0);
|
||||
}
|
||||
|
||||
|
||||
+37
-14
@@ -5,6 +5,7 @@ namespace Drupal\Tests\profile\Functional;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\profile\Entity\ProfileType;
|
||||
use Drupal\profile\Entity\Profile;
|
||||
|
||||
/**
|
||||
* Tests basic CRUD functionality of profile types.
|
||||
@@ -35,7 +36,7 @@ class ProfileTypeCRUDTest extends ProfileTestBase {
|
||||
$type = $this->createProfileType($this->randomMachineName());
|
||||
\Drupal::service('router.builder')->rebuildIfNeeded();
|
||||
$this->drupalGet("user/{$this->adminUser->id()}/{$type->id()}");
|
||||
$this->assertResponse(200);
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,11 +46,11 @@ class ProfileTypeCRUDTest extends ProfileTestBase {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Create a new profile type.
|
||||
$this->drupalGet('admin/config/people/profiles/types');
|
||||
$this->assertResponse(200);
|
||||
$this->drupalGet('admin/config/people/profiles');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$this->clickLink(t('Add profile type'));
|
||||
|
||||
$this->assertUrl('admin/config/people/profiles/types/add');
|
||||
$this->assertSession()->addressEquals('admin/config/people/profiles/add');
|
||||
$id = Unicode::strtolower($this->randomMachineName());
|
||||
$label = $this->getRandomGenerator()->word(10);
|
||||
$edit = [
|
||||
@@ -57,26 +58,48 @@ class ProfileTypeCRUDTest extends ProfileTestBase {
|
||||
'label' => $label,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
$this->assertUrl('admin/config/people/profiles/types');
|
||||
$this->assertRaw(new FormattableMarkup('%label profile type has been created.', ['%label' => $label]));
|
||||
$this->assertLinkByHref("admin/config/people/profiles/types/manage/$id");
|
||||
$this->assertLinkByHref("admin/config/people/profiles/types/manage/$id/fields");
|
||||
$this->assertLinkByHref("admin/config/people/profiles/types/manage/$id/display");
|
||||
$this->assertLinkByHref("admin/config/people/profiles/types/manage/$id/delete");
|
||||
$this->assertSession()->addressEquals('admin/config/people/profiles');
|
||||
$this->assertSession()->responseContains(new FormattableMarkup('%label profile type has been created.', ['%label' => $label]));
|
||||
$this->assertSession()->linkByHrefExists("admin/config/people/profiles/manage/$id");
|
||||
$this->assertSession()->linkByHrefExists("admin/config/people/profiles/manage/$id/fields");
|
||||
$this->assertSession()->linkByHrefExists("admin/config/people/profiles/manage/$id/display");
|
||||
$this->assertSession()->linkByHrefExists("admin/config/people/profiles/manage/$id/delete");
|
||||
|
||||
// Edit the new profile type.
|
||||
$this->drupalGet("admin/config/people/profiles/types/manage/$id");
|
||||
$this->assertRaw(new FormattableMarkup('Edit %label profile type', ['%label' => $label]));
|
||||
$this->drupalGet("admin/config/people/profiles/manage/$id");
|
||||
$this->assertSession()->responseContains(new FormattableMarkup('Edit %label profile type', ['%label' => $label]));
|
||||
$this->getSession()->getPage()->checkField('Include in user registration form');
|
||||
$this->getSession()->getPage()->checkField('Create a new revision when a profile is modified');
|
||||
$this->submitForm([], 'Save');
|
||||
$this->assertUrl('admin/config/people/profiles/types');
|
||||
$this->assertRaw(new FormattableMarkup('%label profile type has been updated.', ['%label' => $label]));
|
||||
$this->assertSession()->addressEquals('admin/config/people/profiles');
|
||||
$this->assertSession()->responseContains(new FormattableMarkup('%label profile type has been updated.', ['%label' => $label]));
|
||||
|
||||
$profile_type = ProfileType::load($id);
|
||||
$this->assertEquals($label, $profile_type->label());
|
||||
$this->assertTrue($profile_type->getRegistration());
|
||||
$this->assertTrue($profile_type->shouldCreateNewRevision());
|
||||
|
||||
// Delete profile type.
|
||||
// First check with existing profile of type.
|
||||
$profile = Profile::create([
|
||||
'type' => $id,
|
||||
'uid' => $this->adminUser->id(),
|
||||
]);
|
||||
$profile->save();
|
||||
$this->drupalGet("admin/config/people/profiles/manage/$id/delete");
|
||||
$this->assertSession()->responseContains(new FormattableMarkup('%label is used by 1 profile on your site. You can not remove this profile type until you have removed all of the %label profiles', ['%label' => $label]));
|
||||
|
||||
// Delete profile and delete profile type.
|
||||
$profile->delete();
|
||||
$this->drupalGet("admin/config/people/profiles/manage/$id/delete");
|
||||
$this->assertSession()->responseContains('This action cannot be undone.');
|
||||
$this->assertSession()->linkByHrefExists('admin/config/people/profiles');
|
||||
$this->submitForm([], 'Delete');
|
||||
$this->assertSession()->addressEquals('admin/config/people/profiles');
|
||||
$this->assertSession()->responseContains(new FormattableMarkup('The profile type %label has been deleted.', ['%label' => $label]));
|
||||
|
||||
$profile_type = ProfileType::load($id);
|
||||
$this->assertNull($profile_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\profile\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Tests basic CRUD functionality of profile types.
|
||||
*
|
||||
* @group profile
|
||||
*/
|
||||
class ProfileTypeTest extends ProfileTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser([
|
||||
'access user profiles',
|
||||
'administer profile types',
|
||||
'administer profile fields',
|
||||
'administer profile display',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that routes are created for the profile type.
|
||||
*/
|
||||
public function testRoutes() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$type = $this->createProfileType($this->randomMachineName());
|
||||
\Drupal::service('router.builder')->rebuildIfNeeded();
|
||||
$this->drupalGet("user/{$this->adminUser->id()}/{$type->id()}");
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CRUD operations for profile types through the UI.
|
||||
*/
|
||||
public function testUi() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Create a new profile type.
|
||||
$this->drupalGet('admin/config/people/profiles');
|
||||
$this->assertResponse(200);
|
||||
$this->clickLink(t('Add profile type'));
|
||||
|
||||
$this->assertUrl('admin/config/people/profiles/add');
|
||||
$id = Unicode::strtolower($this->randomMachineName());
|
||||
$label = $this->randomString();
|
||||
$edit = [
|
||||
'id' => $id,
|
||||
'label' => $label,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
$this->assertUrl('admin/config/people/profiles');
|
||||
$this->assertRaw(new FormattableMarkup('%label profile type has been created.', ['%label' => $label]));
|
||||
$this->assertLinkByHref("admin/config/people/profiles/manage/$id");
|
||||
$this->assertLinkByHref("admin/config/people/profiles/manage/$id/fields");
|
||||
$this->assertLinkByHref("admin/config/people/profiles/manage/$id/display");
|
||||
$this->assertLinkByHref("admin/config/people/profiles/manage/$id/delete");
|
||||
|
||||
// Edit the new profile type.
|
||||
$this->drupalGet("admin/config/people/profiles/manage/$id");
|
||||
$this->assertRaw(new FormattableMarkup('Edit %label profile type', ['%label' => $label]));
|
||||
$edit = [
|
||||
'registration' => 1,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
$this->assertUrl('admin/config/people/profiles');
|
||||
$this->assertRaw(new FormattableMarkup('%label profile type has been updated.', ['%label' => $label]));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -309,8 +309,9 @@ class ProfileTest extends EntityKernelTestBase {
|
||||
$existing_profile_id = $profile2->id();
|
||||
$existing_revision_id = $profile2->getRevisionId();
|
||||
|
||||
// Changing field creates revision.
|
||||
// Changing profiles support revisions.
|
||||
$profile2->get('profile_fullname')->setValue($this->randomMachineName());
|
||||
$profile2->setNewRevision();
|
||||
$profile2->save();
|
||||
|
||||
$profile2 = $this->reloadEntity($profile2);
|
||||
|
||||
Reference in New Issue
Block a user