Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
315
Merge Requests
315
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
dca2d601
Commit
dca2d601
authored
Feb 06, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1857442
by longwave, dawehner: Make $values optional on entity_create.
parent
f6dd96ca
Changes
50
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
78 additions
and
78 deletions
+78
-78
core/includes/entity.inc
core/includes/entity.inc
+5
-5
core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
...lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+1
-1
core/lib/Drupal/Core/Entity/DatabaseStorageController.php
core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+1
-1
core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php
...b/Drupal/Core/Entity/EntityStorageControllerInterface.php
+4
-4
core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php
...upal/Core/Entity/FieldableEntityStorageControllerBase.php
+1
-1
core/modules/comment/lib/Drupal/comment/Plugin/views/field/StatisticsLastCommentName.php
.../comment/Plugin/views/field/StatisticsLastCommentName.php
+1
-1
core/modules/comment/lib/Drupal/comment/Plugin/views/field/Username.php
...omment/lib/Drupal/comment/Plugin/views/field/Username.php
+1
-1
core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
...dules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
+1
-1
core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php
...s/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php
+4
-4
core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php
...odules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php
+3
-3
core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php
...ules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php
+2
-2
core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
...es/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
+3
-3
core/modules/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php
...es/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php
+1
-1
core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
+1
-1
core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php
...Drupal/entity_reference/Tests/EntityReferenceItemTest.php
+2
-2
core/modules/field/lib/Drupal/field/Tests/CrudTest.php
core/modules/field/lib/Drupal/field/Tests/CrudTest.php
+2
-2
core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
+1
-1
core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
...les/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
+1
-1
core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
...s/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
+1
-1
core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php
core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php
+1
-1
core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
+1
-1
core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
...dules/field/lib/Drupal/field/Tests/TranslationWebTest.php
+1
-1
core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
+1
-1
core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
+3
-3
core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php
...modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php
+2
-2
core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
+1
-1
core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
...s/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
+1
-1
core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php
core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php
+1
-1
core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
...u_link/lib/Drupal/menu_link/MenuLinkStorageController.php
+1
-1
core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
...modules/number/lib/Drupal/number/Tests/NumberItemTest.php
+1
-1
core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
...les/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+5
-5
core/modules/options/lib/Drupal/options/Tests/OptionsFormattersTest.php
...ptions/lib/Drupal/options/Tests/OptionsFormattersTest.php
+1
-1
core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaDatatypeCallbackTest.php
.../Drupal/rdf/Tests/Field/FieldRdfaDatatypeCallbackTest.php
+1
-1
core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php
.../Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php
+1
-1
core/modules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php
...ules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php
...ystem/lib/Drupal/system/Tests/Entity/EntityAccessTest.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php
...rupal/system/Tests/Entity/EntityFieldDefaultValueTest.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
...system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
+2
-2
core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
...m/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php
...b/Drupal/system/Tests/Entity/EntityViewControllerTest.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php
...em/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php
+2
-2
core/modules/system/tests/modules/entity_test/entity_test.module
...dules/system/tests/modules/entity_test/entity_test.module
+1
-1
core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php
...es/taxonomy/lib/Drupal/taxonomy/TermStorageController.php
+1
-1
core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
...b/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
+1
-1
core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
...ules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
+2
-2
core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php
...elephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php
+1
-1
core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
+1
-1
core/modules/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php
...es/text/lib/Drupal/text/Tests/TextWithSummaryItemTest.php
+2
-2
core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php
.../modules/user/lib/Drupal/user/Plugin/views/field/Name.php
+1
-1
core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php
...dules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php
+1
-1
No files found.
core/includes/entity.inc
View file @
dca2d601
...
...
@@ -377,16 +377,16 @@ function entity_delete_multiple($entity_type, array $ids) {
/**
* Constructs a new entity object, without permanently saving it.
*
* @param $entity_type
* @param
string
$entity_type
* The type of the entity.
* @param $values
*
An array of values to set, keyed by property name. If the entity type has
*
bundles
the bundle key has to be specified.
* @param
array
$values
*
(optional) An array of values to set, keyed by property name. If the
*
entity type has bundles,
the bundle key has to be specified.
*
* @return \Drupal\Core\Entity\EntityInterface
* A new entity object.
*/
function
entity_create
(
$entity_type
,
array
$values
)
{
function
entity_create
(
$entity_type
,
array
$values
=
array
()
)
{
return
\
Drupal
::
entityManager
()
->
getStorageController
(
$entity_type
)
->
create
(
$values
);
...
...
core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
View file @
dca2d601
...
...
@@ -248,7 +248,7 @@ protected function buildQuery($ids, $revision_id = FALSE) {
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::create().
*/
public
function
create
(
array
$values
)
{
public
function
create
(
array
$values
=
array
()
)
{
$class
=
$this
->
entityType
->
getClass
();
$class
::
preCreate
(
$this
,
$values
);
...
...
core/lib/Drupal/Core/Entity/DatabaseStorageController.php
View file @
dca2d601
...
...
@@ -235,7 +235,7 @@ protected function buildQuery($ids, $revision_id = FALSE) {
/**
* {@inheritdoc}
*/
public
function
create
(
array
$values
)
{
public
function
create
(
array
$values
=
array
()
)
{
$entity_class
=
$this
->
entityType
->
getClass
();
$entity_class
::
preCreate
(
$this
,
$values
);
...
...
core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php
View file @
dca2d601
...
...
@@ -111,14 +111,14 @@ public function loadByProperties(array $values = array());
/**
* Constructs a new entity object, without permanently saving it.
*
* @param $values
*
An array of values to set, keyed by property name. If the entity type has
*
bundles
the bundle key has to be specified.
* @param
array
$values
*
(optional) An array of values to set, keyed by property name. If the
*
entity type has bundles,
the bundle key has to be specified.
*
* @return \Drupal\Core\Entity\EntityInterface
* A new entity object.
*/
public
function
create
(
array
$values
);
public
function
create
(
array
$values
=
array
()
);
/**
* Deletes permanently saved entities.
...
...
core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php
View file @
dca2d601
...
...
@@ -55,7 +55,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
/**
* {@inheritdoc}
*/
public
function
create
(
array
$values
)
{
public
function
create
(
array
$values
=
array
()
)
{
$entity_class
=
$this
->
entityType
->
getClass
();
$entity_class
::
preCreate
(
$this
,
$values
);
...
...
core/modules/comment/lib/Drupal/comment/Plugin/views/field/StatisticsLastCommentName.php
View file @
dca2d601
...
...
@@ -61,7 +61,7 @@ protected function defineOptions() {
*/
public
function
render
(
ResultRow
$values
)
{
if
(
!
empty
(
$this
->
options
[
'link_to_user'
]))
{
$account
=
entity_create
(
'user'
,
array
()
);
$account
=
entity_create
(
'user'
);
$account
->
name
=
$this
->
getValue
(
$values
);
$account
->
uid
=
$values
->
{
$this
->
uid
};
$username
=
array
(
...
...
core/modules/comment/lib/Drupal/comment/Plugin/views/field/Username.php
View file @
dca2d601
...
...
@@ -61,7 +61,7 @@ public function buildOptionsForm(&$form, &$form_state) {
*/
protected
function
renderLink
(
$data
,
ResultRow
$values
)
{
if
(
!
empty
(
$this
->
options
[
'link_to_user'
]))
{
$account
=
entity_create
(
'user'
,
array
()
);
$account
=
entity_create
(
'user'
);
$account
->
uid
=
$this
->
getValue
(
$values
,
'uid'
);
$account
->
name
=
$this
->
getValue
(
$values
);
$account
->
homepage
=
$this
->
getValue
(
$values
,
'homepage'
);
...
...
core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
View file @
dca2d601
...
...
@@ -38,7 +38,7 @@ public static function getInfo() {
function
testCRUD
()
{
$default_langcode
=
language_default
()
->
id
;
// Verify default properties on a newly created empty entity.
$empty
=
entity_create
(
'config_test'
,
array
()
);
$empty
=
entity_create
(
'config_test'
);
$this
->
assertIdentical
(
$empty
->
id
,
NULL
);
$this
->
assertTrue
(
$empty
->
uuid
);
$this
->
assertIdentical
(
$empty
->
label
,
NULL
);
...
...
core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeItemTest.php
View file @
dca2d601
...
...
@@ -58,7 +58,7 @@ public function setUp() {
*/
public
function
testDateTimeItem
()
{
// Verify entity creation.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$value
=
'2014-01-01T20:00:00Z'
;
$entity
->
field_datetime
=
$value
;
$entity
->
name
->
value
=
$this
->
randomName
();
...
...
@@ -88,7 +88,7 @@ public function testDateTimeItem() {
*/
public
function
testSetValue
()
{
// Test DateTimeItem::setValue() using string.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$value
=
'2014-01-01T20:00:00Z'
;
$entity
->
get
(
'field_datetime'
)
->
set
(
0
,
$value
);
$entity
->
save
();
...
...
@@ -98,7 +98,7 @@ public function testSetValue() {
$this
->
assertEqual
(
$entity
->
field_datetime
[
0
]
->
value
,
$value
,
'DateTimeItem::setValue() works with string value.'
);
// Test DateTimeItem::setValue() using property array.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$value
=
'2014-01-01T20:00:00Z'
;
$entity
->
set
(
'field_datetime'
,
$value
);
$entity
->
save
();
...
...
@@ -113,7 +113,7 @@ public function testSetValue() {
*/
public
function
testSetValueProperty
()
{
// Test Date::setValue().
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$value
=
'2014-01-01T20:00:00Z'
;
$entity
->
set
(
'field_datetime'
,
$value
);
...
...
core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php
View file @
dca2d601
...
...
@@ -74,7 +74,7 @@ public function testText() {
);
// Create an entity with values for this text field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$field_name
}
->
value
=
'Hello, world!'
;
$this
->
entity
->
{
$field_name
}
->
format
=
'full_html'
;
$this
->
entity
->
save
();
...
...
@@ -126,7 +126,7 @@ public function testTextWysiwyg() {
);
// Create an entity with values for this text field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$field_name
}
->
value
=
'Hello, world!'
;
$this
->
entity
->
{
$field_name
}
->
format
=
'filtered_html'
;
$this
->
entity
->
save
();
...
...
@@ -163,7 +163,7 @@ public function testNumber() {
);
// Create an entity with values for this text field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$field_name
}
->
value
=
42
;
$this
->
entity
->
save
();
...
...
core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php
View file @
dca2d601
...
...
@@ -95,7 +95,7 @@ public function testSimpleEntityType() {
);
// Create an entity with values for this text field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$field_1_name
}
->
value
=
'Test'
;
$this
->
entity
->
{
$field_2_name
}
->
value
=
42
;
$this
->
entity
->
save
();
...
...
@@ -161,7 +161,7 @@ public function testEditorWithCustomMetadata() {
$full_html_format
->
save
();
// Create an entity with values for this rich text field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$field_name
}
->
value
=
'Test'
;
$this
->
entity
->
{
$field_name
}
->
format
=
'full_html'
;
$this
->
entity
->
save
();
...
...
core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
View file @
dca2d601
...
...
@@ -127,7 +127,7 @@ public function testEditorSelection() {
$this
->
editorSelector
=
new
EditorSelector
(
$this
->
editorManager
,
$this
->
container
->
get
(
'plugin.manager.field.formatter'
));
// Create an entity with values for this text field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
field_name
}
->
value
=
'Hello, world!'
;
$this
->
entity
->
{
$this
->
field_name
}
->
format
=
'filtered_html'
;
$this
->
entity
->
save
();
...
...
@@ -156,7 +156,7 @@ public function testMetadata() {
$this
->
metadataGenerator
=
new
MetadataGenerator
(
$this
->
accessChecker
,
$this
->
editorSelector
,
$this
->
editorManager
);
// Create an entity with values for the field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
field_name
}
->
value
=
'Test'
;
$this
->
entity
->
{
$this
->
field_name
}
->
format
=
'full_html'
;
$this
->
entity
->
save
();
...
...
@@ -183,7 +183,7 @@ public function testMetadata() {
*/
public
function
testGetUntransformedTextCommand
()
{
// Create an entity with values for the field.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
field_name
}
->
value
=
'Test'
;
$this
->
entity
->
{
$this
->
field_name
}
->
format
=
'full_html'
;
$this
->
entity
->
save
();
...
...
core/modules/editor/lib/Drupal/editor/Tests/EditorFileUsageTest.php
View file @
dca2d601
...
...
@@ -59,7 +59,7 @@ public function setUp() {
* Tests the configurable text editor manager.
*/
public
function
testEditorEntityHooks
()
{
$image
=
entity_create
(
'file'
,
array
()
);
$image
=
entity_create
(
'file'
);
$image
->
setFileUri
(
'core/misc/druplicon.png'
);
$image
->
setFilename
(
drupal_basename
(
$image
->
getFileUri
()));
$image
->
save
();
...
...
core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
View file @
dca2d601
...
...
@@ -59,7 +59,7 @@ public function setUp() {
*/
public
function
testEmailItem
()
{
// Verify entity creation.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$value
=
'test@example.com'
;
$entity
->
field_email
=
$value
;
$entity
->
name
->
value
=
$this
->
randomName
();
...
...
core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php
View file @
dca2d601
...
...
@@ -81,7 +81,7 @@ public function testContentEntityReferenceItem() {
$tid
=
$this
->
term
->
id
();
// Just being able to create the entity like this verifies a lot of code.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
field_test_taxonomy_term
->
target_id
=
$tid
;
$entity
->
name
->
value
=
$this
->
randomName
();
$entity
->
save
();
...
...
@@ -128,7 +128,7 @@ public function testConfigEntityReferenceItem() {
$referenced_entity_id
=
$this
->
vocabulary
->
id
();
// Just being able to create the entity like this verifies a lot of code.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
field_test_taxonomy_vocabulary
->
target_id
=
$referenced_entity_id
;
$entity
->
name
->
value
=
$this
->
randomName
();
$entity
->
save
();
...
...
core/modules/field/lib/Drupal/field/Tests/CrudTest.php
View file @
dca2d601
...
...
@@ -348,7 +348,7 @@ function testDeleteField() {
$this
->
assertTrue
(
!
empty
(
$instance
)
&&
empty
(
$instance
->
deleted
),
'A new instance for a previously used field name is created.'
);
// Save an entity with data for the field
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$values
[
0
][
'value'
]
=
mt_rand
(
1
,
127
);
$entity
->
{
$field
->
getName
()}
->
value
=
$values
[
0
][
'value'
];
$entity
=
$this
->
entitySaveReload
(
$entity
);
...
...
@@ -402,7 +402,7 @@ function testUpdateField() {
$instance
->
save
();
do
{
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
// Fill in the entity with more values than $cardinality.
for
(
$i
=
0
;
$i
<
20
;
$i
++
)
{
// We can not use $i here because 0 values are filtered out.
...
...
core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
View file @
dca2d601
...
...
@@ -110,7 +110,7 @@ function setUp() {
// Create an entity with values.
$this
->
values
=
$this
->
_generateTestFieldValues
(
$this
->
cardinality
);
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
field_name
}
->
setValue
(
$this
->
values
);
$this
->
entity
->
save
();
}
...
...
core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
View file @
dca2d601
...
...
@@ -48,7 +48,7 @@ function testFieldAttachView() {
$this
->
createFieldWithInstance
(
'_2'
);
$entity_type
=
'entity_test'
;
$entity_init
=
entity_create
(
$entity_type
,
array
()
);
$entity_init
=
entity_create
(
$entity_type
);
// Populate values to be displayed.
$values
=
$this
->
_generateTestFieldValues
(
$this
->
field
->
getCardinality
());
...
...
core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
View file @
dca2d601
...
...
@@ -58,7 +58,7 @@ function testFieldAttachSaveLoad() {
// TODO : test empty values filtering and "compression" (store consecutive deltas).
// Preparation: create three revisions and store them in $revision array.
$values
=
array
();
$entity
=
entity_create
(
$entity_type
,
array
()
);
$entity
=
entity_create
(
$entity_type
);
for
(
$revision_id
=
0
;
$revision_id
<
3
;
$revision_id
++
)
{
// Note: we try to insert one extra value.
$current_values
=
$this
->
_generateTestFieldValues
(
$cardinality
+
1
);
...
...
core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php
View file @
dca2d601
...
...
@@ -60,7 +60,7 @@ public function setUp() {
*/
public
function
testShapeItem
()
{
// Verify entity creation.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$shape
=
'cube'
;
$color
=
'blue'
;
$entity
->
{
$this
->
field_name
}
->
shape
=
$shape
;
...
...
core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
View file @
dca2d601
...
...
@@ -61,7 +61,7 @@ public function setUp() {
*/
public
function
testTestItem
()
{
// Verify entity creation.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$value
=
rand
(
1
,
10
);
$entity
->
field_test
=
$value
;
$entity
->
name
->
value
=
$this
->
randomName
();
...
...
core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
View file @
dca2d601
...
...
@@ -102,7 +102,7 @@ function testFieldFormTranslationRevisions() {
// Prepare the field translations.
field_test_entity_info_translatable
(
$this
->
entity_type
,
TRUE
);
$entity
=
entity_create
(
$this
->
entity_type
,
array
()
);
$entity
=
entity_create
(
$this
->
entity_type
);
$available_langcodes
=
array_flip
(
array_keys
(
language_list
()));
$field_name
=
$this
->
field
->
getName
();
...
...
core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
View file @
dca2d601
...
...
@@ -68,7 +68,7 @@ public function setUp() {
*/
public
function
testFileItem
()
{
// Create a test entity with the
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
file_test
->
target_id
=
$this
->
file
->
id
();
$entity
->
file_test
->
display
=
1
;
$entity
->
file_test
->
description
=
$description
=
$this
->
randomName
();
...
...
core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
View file @
dca2d601
...
...
@@ -22,11 +22,11 @@ public static function getInfo() {
function
setUp
()
{
parent
::
setUp
();
$this
->
image
=
entity_create
(
'file'
,
array
()
);
$this
->
image
=
entity_create
(
'file'
);
$this
->
image
->
setFileUri
(
'core/misc/druplicon.png'
);
$this
->
image
->
setFilename
(
drupal_basename
(
$this
->
image
->
getFileUri
()));
$this
->
non_image
=
entity_create
(
'file'
,
array
()
);
$this
->
non_image
=
entity_create
(
'file'
);
$this
->
non_image
->
setFileUri
(
'core/assets/vendor/jquery/jquery.js'
);
$this
->
non_image
->
setFilename
(
drupal_basename
(
$this
->
non_image
->
getFileUri
()));
}
...
...
@@ -105,7 +105,7 @@ function testFileValidateImageResolution() {
*/
function
testFileValidateNameLength
()
{
// Create a new file entity.
$file
=
entity_create
(
'file'
,
array
()
);
$file
=
entity_create
(
'file'
);
// Add a filename with an allowed length and test it.
$file
->
setFilename
(
str_repeat
(
'x'
,
240
));
...
...
core/modules/filter/lib/Drupal/filter/Tests/FilterCrudTest.php
View file @
dca2d601
...
...
@@ -34,14 +34,14 @@ public static function getInfo() {
*/
function
testTextFormatCrud
()
{
// Add a text format with minimum data only.
$format
=
entity_create
(
'filter_format'
,
array
()
);
$format
=
entity_create
(
'filter_format'
);
$format
->
format
=
'empty_format'
;
$format
->
name
=
'Empty format'
;
$format
->
save
();
$this
->
verifyTextFormat
(
$format
);
// Add another text format specifying all possible properties.
$format
=
entity_create
(
'filter_format'
,
array
()
);
$format
=
entity_create
(
'filter_format'
);
$format
->
format
=
'custom_format'
;
$format
->
name
=
'Custom format'
;
$format
->
setFilterConfig
(
'filter_url'
,
array
(
...
...
core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
View file @
dca2d601
...
...
@@ -73,7 +73,7 @@ public function setUp() {
*/
public
function
testImageItem
()
{
// Create a test entity with the image field set.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
image_test
->
target_id
=
$this
->
image
->
id
();
$entity
->
image_test
->
alt
=
$alt
=
$this
->
randomName
();
$entity
->
image_test
->
title
=
$title
=
$this
->
randomName
();
...
...
core/modules/image/lib/Drupal/image/Tests/ImageThemeFunctionTest.php
View file @
dca2d601
...
...
@@ -79,7 +79,7 @@ function testImageFormatterTheme() {
$url
=
$style
->
buildUrl
(
$original_uri
);
// Create a test entity with the image field set.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
image_test
->
target_id
=
$this
->
image
->
id
();
$entity
->
image_test
->
alt
=
NULL
;
$entity
->
image_test
->
uri
=
$original_uri
;
...
...
core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php
View file @
dca2d601
...
...
@@ -52,7 +52,7 @@ public function setUp() {
*/
public
function
testLinkItem
()
{
// Create entity.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$url
=
'http://www.drupal.org'
;
$title
=
$this
->
randomName
();
$class
=
$this
->
randomName
();
...
...
core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
View file @
dca2d601
...
...
@@ -71,7 +71,7 @@ public function __construct(EntityTypeInterface $entity_info, Connection $databa
/**
* {@inheritdoc}
*/
public
function
create
(
array
$values
)
{
public
function
create
(
array
$values
=
array
()
)
{
// The bundle of menu links being the menu name is not enforced but is the
// default behavior if no bundle is set.
if
(
!
isset
(
$values
[
'bundle'
])
&&
isset
(
$values
[
'menu_name'
]))
{
...
...
core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
View file @
dca2d601
...
...
@@ -54,7 +54,7 @@ public function setUp() {
*/
public
function
testNumberItem
()
{
// Verify entity creation.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$integer
=
rand
(
0
,
10
);
$entity
->
field_integer
=
$integer
;
$float
=
3.14
;
...
...
core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
View file @
dca2d601
...
...
@@ -34,7 +34,7 @@ public static function getInfo() {
*/
function
testUpdateAllowedValues
()
{
// All three options appear.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
()
->
getForm
(
$entity
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 exists'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 exists'
);
...
...
@@ -42,7 +42,7 @@ function testUpdateAllowedValues() {
// Use one of the values in an actual entity, and check that this value
// cannot be removed from the list.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
{
$this
->
fieldName
}
->
value
=
1
;
$entity
->
save
();
$this
->
field
->
settings
[
'allowed_values'
]
=
array
(
2
=>
'Two'
);
...
...
@@ -60,7 +60,7 @@ function testUpdateAllowedValues() {
// Removed options do not appear.
$this
->
field
->
settings
[
'allowed_values'
]
=
array
(
2
=>
'Two'
);
$this
->
field
->
save
();
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
()
->
getForm
(
$entity
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 does not exist'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 exists'
);
...
...
@@ -71,7 +71,7 @@ function testUpdateAllowedValues() {
$this
->
field
->
save
();
// The entity holds an outdated field object with the old allowed values
// setting, so we need to reintialize the entity object.
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
()
->
getForm
(
$entity
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 does not exist'
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 does not exist'
);
...
...
@@ -92,7 +92,7 @@ function testUpdateAllowedValues() {
'type'
=>
'options_buttons'
,
))
->
save
();
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
()
->
getForm
(
$entity
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 exists'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 exists'
);
...
...
core/modules/options/lib/Drupal/options/Tests/OptionsFormattersTest.php
View file @
dca2d601
...
...
@@ -34,7 +34,7 @@ public function setUp() {
* Tests the formatters.
*/
public
function
testFormatter
()
{
$entity
=
entity_create
(
'entity_test'
,
array
()
);
$entity
=
entity_create
(
'entity_test'
);
$entity
->
{
$this
->
fieldName
}
->
value
=
1
;
$build
=
field_view_field
(
$entity
,
$this
->
fieldName
,
array
());
...
...
core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaDatatypeCallbackTest.php
View file @
dca2d601
...
...
@@ -45,7 +45,7 @@ public function setUp() {
// Set up test values.
$this
->
test_value
=
$this
->
randomName
();
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
fieldName
}
->
value
=
$this
->
test_value
;
$this
->
entity
->
save
();
...
...
core/modules/rdf/lib/Drupal/rdf/Tests/Field/TaxonomyTermReferenceRdfaTest.php
View file @
dca2d601
...
...
@@ -93,7 +93,7 @@ public function setUp() {
))
->
save
();
// Set up test values.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
fieldName
}
->
target_id
=
$this
->
term
->
id
();
$this
->
entity
->
save
();
$this
->
uri
=
$this
->
getAbsoluteUri
(
$this
->
entity
);
...
...
core/modules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php
View file @
dca2d601
...
...
@@ -57,7 +57,7 @@ public function setUp() {
))
->
save
();
// Set up test entity.
$this
->
entity
=
entity_create
(
'entity_test'
,
array
()
);
$this
->
entity
=
entity_create
(
'entity_test'
);
$this
->
entity
->
{
$this
->
fieldName
}
->
value
=
$this
->
testValue
;
$this
->
entity
->
{
$this
->
fieldName
}
->
summary
=
$this
->
testSummary
;
}
...
...
core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php
View file @
dca2d601
...
...
@@ -86,7 +86,7 @@ function testEntityAccessDefaultController() {
$controller
=
$this
->
container
->
get
(
'entity.manager'
)
->
getAccessController
(
'entity_test_default_access'
);
$this
->
assertTrue
(
$controller
instanceof
EntityAccessController
,
'The default entity controller is used for the entity_test_default_access entity type.'
);
$entity
=
entity_create
(
'entity_test_default_access'
,
array
()
);
$entity
=
entity_create
(
'entity_test_default_access'
);
$this
->
assertEntityAccess
(
array
(
'create'
=>
FALSE
,
'update'
=>
FALSE
,
...
...
core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php
View file @
dca2d601
...
...
@@ -54,7 +54,7 @@ public function testDefaultValues() {
* The entity type to run the tests with.
*/
protected
function
assertDefaultValues
(
$entity_type
)
{
$entity
=
entity_create
(
$entity_type
,
array
()
);
$entity
=
entity_create
(
$entity_type
);
$this
->
assertEqual
(
$entity
->
langcode
->
value
,
Language
::
LANGCODE_NOT_SPECIFIED
,
String
::
format
(
'%entity_type: Default language'
,
array
(
'%entity_type'
=>
$entity_type
)));
$this
->
assertTrue
(
Uuid
::
isValid
(
$entity
->
uuid
->
value
),
String
::
format
(
'%entity_type: Default UUID'
,
array
(
'%entity_type'
=>
$entity_type
)));
$this
->
assertEqual
(
$entity
->
name
->
getValue
(),
array
(
0
=>
array
(
'value'
=>
NULL
)),
'Field has one empty value by default.'
);
...
...
core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
View file @
dca2d601
...
...
@@ -70,7 +70,7 @@ protected function createTestEntity($entity_type) {
// Pass in the value of the name field when creating. With the user
// field we test setting a field after creation.
$entity
=
entity_create
(
$entity_type
,
array
()
);
$entity
=
entity_create
(
$entity_type
);
$entity
->
user_id
->
target_id
=
$this
->
entity_user
->
id
();
$entity
->
name
->
value
=
$this
->
entity_name
;
...
...
@@ -362,7 +362,7 @@ protected function checkIntrospection($entity_type) {
// Test introspecting an entity object.
// @todo: Add bundles and test bundles as well.
$entity
=
entity_create
(
$entity_type
,
array
()
);
$entity
=
entity_create
(
$entity_type
);
$definitions
=
$entity
->
getPropertyDefinitions
();
$this
->
assertEqual
(
$definitions
[
'name'
]
->
getType
(),
'string'
,
$entity_type
.
': Name field found.'
);
...
...
core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
View file @
dca2d601
...
...
@@ -72,7 +72,7 @@ protected function createTestEntity($entity_type) {
// Pass in the value of the name field when creating. With the user
// field we test setting a field after creation.
$entity
=
entity_create
(
$entity_type
,
array
()
);
$entity
=
entity_create
(
$entity_type
);
$entity
->
user_id
->
target_id
=
$this
->
entity_user
->
id
();
$entity
->
name
->
value
=
$this
->
entity_name
;
...
...
core/modules/system/lib/Drupal/system/Tests/En