public function EntitySerializationTest::testUserNormalize in Drupal 8
Same name and namespace in other branches
- 9 core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php \Drupal\Tests\serialization\Kernel\EntitySerializationTest::testUserNormalize()
Tests user normalization, using the entity_serialization_test module to override some default access controls.
File
- core/
modules/ serialization/ tests/ src/ Kernel/ EntitySerializationTest.php, line 188
Class
- EntitySerializationTest
- Tests that entities can be serialized to supported core formats.
Namespace
Drupal\Tests\serialization\KernelCode
public function testUserNormalize() {
// Test password isn't available.
$normalized = $this->serializer
->normalize($this->user);
$this
->assertArrayNotHasKey('pass', $normalized);
$this
->assertArrayNotHasKey('mail', $normalized);
// Test again using our test user, so that our access control override will
// allow password viewing.
$normalized = $this->serializer
->normalize($this->user, NULL, [
'account' => $this->user,
]);
// The key 'pass' will now exist, but the password value should be
// normalized to NULL.
$this
->assertIdentical($normalized['pass'], [
NULL,
], '"pass" value is normalized to [NULL]');
}