Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
12b49aa1
Commit
12b49aa1
authored
12 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#1637370
by danielnolde, sun, djdevin, Berdir: Added UUID support to core entity types.
parent
4c2e6b41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/entity/lib/Drupal/entity/Tests/EntityUUIDTest.php
+65
-0
65 additions, 0 deletions
...modules/entity/lib/Drupal/entity/Tests/EntityUUIDTest.php
with
65 additions
and
0 deletions
core/modules/entity/lib/Drupal/entity/Tests/EntityUUIDTest.php
0 → 100644
+
65
−
0
View file @
12b49aa1
<?php
/**
* @file
* Definition of Drupal\entity\Tests\EntityUUIDTest.
*/
namespace
Drupal\entity\Tests
;
use
Drupal\Component\Uuid\Uuid
;
use
Drupal\simpletest\WebTestBase
;
/**
* Tests creation, saving, and loading of entity UUIDs.
*/
class
EntityUUIDTest
extends
WebTestBase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Entity UUIDs'
,
'description'
=>
'Tests creation, saving, and loading of entity UUIDs.'
,
'group'
=>
'Entity API'
,
);
}
function
setUp
()
{
parent
::
setUp
(
array
(
'entity_test'
));
}
/**
* Tests UUID generation in entity CRUD operations.
*/
function
testCRUD
()
{
// Verify that no UUID is auto-generated when passing one for creation.
$uuid_service
=
new
Uuid
();
$uuid
=
$uuid_service
->
generate
();
$custom_entity
=
entity_create
(
'entity_test'
,
array
(
'name'
=>
$this
->
randomName
(),
'uuid'
=>
$uuid
,
));
$this
->
assertIdentical
(
$custom_entity
->
get
(
'uuid'
),
$uuid
);
// Save this entity, so we have more than one later.
$custom_entity
->
save
();
// Verify that a new UUID is generated upon creating an entity.
$entity
=
entity_create
(
'entity_test'
,
array
(
'name'
=>
$this
->
randomName
()));
$uuid
=
$entity
->
get
(
'uuid'
);
$this
->
assertTrue
(
$uuid
);
// Verify that the new UUID is different.
$this
->
assertNotEqual
(
$custom_entity
->
get
(
'uuid'
),
$uuid
);
// Verify that the UUID is retained upon saving.
$entity
->
save
();
$this
->
assertIdentical
(
$entity
->
get
(
'uuid'
),
$uuid
);
// Verify that the UUID is retained upon loading.
$entity_loaded
=
entity_test_load
(
$entity
->
id
(),
TRUE
);
$this
->
assertIdentical
(
$entity_loaded
->
get
(
'uuid'
),
$uuid
);
// Verify that entity_load_by_uuid() loads the same entity.
$entity_loaded_by_uuid
=
entity_load_by_uuid
(
'entity_test'
,
$uuid
,
TRUE
);
$this
->
assertIdentical
(
$entity_loaded_by_uuid
->
get
(
'uuid'
),
$uuid
);
$this
->
assertEqual
(
$entity_loaded_by_uuid
,
$entity_loaded
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment