Commit fc189a4c authored by alexpott's avatar alexpott

Issue #2723611 by Ashish.Dalvi, Sagar Ramgade, gaurav.pahuja, Sonal.Sangale,...

Issue #2723611 by Ashish.Dalvi, Sagar Ramgade, gaurav.pahuja, Sonal.Sangale, marvin_B8, valthebald, Mile23, xjm: Remove entity_load* usage for node entity type
parent df0425cf
......@@ -592,7 +592,8 @@ function template_preprocess_form_element_label(&$variables) {
* // 1 (or no value explicitly set) means the operation is finished
* // and the batch processing can continue to the next operation.
*
* $nodes = entity_load_multiple_by_properties('node', array('uid' => $uid, 'type' => $type));
* $nodes = \Drupal::entityTypeManager()->getStorage('node')
* ->loadByProperties(['uid' => $uid, 'type' => $type]);
* $node = reset($nodes);
* $context['results'][] = $node->id() . ' : ' . SafeMarkup::checkPlain($node->label());
* $context['message'] = SafeMarkup::checkPlain($node->label());
......
......@@ -52,11 +52,13 @@ protected function setUp() {
* Test the changed time after API and FORM save without changes.
*/
public function testChangedTimeAfterSaveWithoutChanges() {
$node = entity_load('node', 1);
$storage = $this->container->get('entity_type.manager')->getStorage('node');
$storage->resetCache([1]);
$node = $storage->load(1);
$changed_timestamp = $node->getChangedTime();
$node->save();
$node = entity_load('node', 1, TRUE);
$storage->resetCache([1]);
$node = $storage->load(1);
$this->assertEqual($changed_timestamp, $node->getChangedTime(), "The entity's changed time wasn't updated after API save without changes.");
// Ensure different save timestamps.
......@@ -65,7 +67,8 @@ public function testChangedTimeAfterSaveWithoutChanges() {
// Save the node on the regular node edit form.
$this->drupalPostForm('node/1/edit', array(), t('Save'));
$node = entity_load('node', 1, TRUE);
$storage->resetCache([1]);
$node = $storage->load(1);
$this->assertNotEqual($changed_timestamp, $node->getChangedTime(), "The entity's changed time was updated after form save without changes.");
}
......
......@@ -39,9 +39,9 @@ function testNodeMultipleLoad() {
$this->assertText($node2->label(), 'Node title appears on the default listing.');
$this->assertNoText($node3->label(), 'Node title does not appear in the default listing.');
$this->assertNoText($node4->label(), 'Node title does not appear in the default listing.');
// Load nodes with only a condition. Nodes 3 and 4 will be loaded.
$nodes = entity_load_multiple_by_properties('node', array('promote' => 0));
$nodes = $this->container->get('entity_type.manager')->getStorage('node')
->loadByProperties(array('promote' => 0));
$this->assertEqual($node3->label(), $nodes[$node3->id()]->label(), 'Node was loaded.');
$this->assertEqual($node4->label(), $nodes[$node4->id()]->label(), 'Node was loaded.');
$count = count($nodes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment