Mercurial > hg > isophonics-drupal-site
diff core/modules/user/tests/src/Kernel/UserEntityTest.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line diff
--- a/core/modules/user/tests/src/Kernel/UserEntityTest.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/modules/user/tests/src/Kernel/UserEntityTest.php Mon Apr 23 09:46:53 2018 +0100 @@ -22,6 +22,14 @@ public static $modules = ['system', 'user', 'field']; /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->installEntitySchema('user'); + } + + /** * Tests some of the methods. * * @see \Drupal\user\Entity\User::getRoles() @@ -65,4 +73,22 @@ $this->assertEqual([RoleInterface::AUTHENTICATED_ID, 'test_role_two'], $user->getRoles()); } + /** + * Tests that all user fields validate properly. + * + * @see \Drupal\Core\Field\FieldItemListInterface::generateSampleItems + * @see \Drupal\Core\Field\FieldItemInterface::generateSampleValue() + * @see \Drupal\Core\Entity\FieldableEntityInterface::validate() + */ + public function testUserValidation() { + $user = User::create([]); + foreach ($user as $field_name => $field) { + if (!in_array($field_name, ['uid'])) { + $user->$field_name->generateSampleItems(); + } + } + $violations = $user->validate(); + $this->assertFalse((bool) $violations->count()); + } + }