function EntityLoadTestCase::testEntityLoadIds

File

modules/simpletest/tests/entity_crud.test, line 50

Class

EntityLoadTestCase
Tests the entity_load() function.

Code

public function testEntityLoadIds() {
  $this->drupalCreateNode(array(
    'title' => 'Node 1',
  ));
  $this->drupalCreateNode(array(
    'title' => 'Node 2',
  ));
  $nodes_loaded = entity_load('node', array(
    '1',
    '2',
  ));
  $this->assertEqual(count($nodes_loaded), 2);
  // Ensure that an id with a trailing decimal place is ignored.
  $nodes_loaded = entity_load('node', array(
    '1.',
    '2',
  ));
  $this->assertEqual(count($nodes_loaded), 1);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.