12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- class EntityLoadTestCase extends DrupalWebTestCase {
- protected $profile = 'testing';
- public static function getInfo() {
- return array(
- 'name' => 'Entity loading',
- 'description' => 'Tests the entity_load() function.',
- 'group' => 'Entity API',
- );
- }
-
- public function testEntityLoadConditions() {
-
-
-
- $node_1 = $this->drupalCreateNode(array('title' => 'Array'));
- $node_2 = $this->drupalCreateNode(array('title' => 'Node 2'));
- $node_3 = $this->drupalCreateNode(array('title' => 'Node 3'));
-
- $all_nodes = entity_load('node', FALSE);
-
- $nodes_loaded = entity_load('node', FALSE, array('title' => 'Array'));
- $this->assertEqual(array_keys($nodes_loaded), array($node_1->nid));
-
-
-
- $nodes_loaded = entity_load('node', FALSE, array('title' => array('Node 2', 'Node 3')));
- ksort($nodes_loaded);
- $this->assertEqual(array_keys($nodes_loaded), array($node_2->nid, $node_3->nid));
- $this->assertIdentical($nodes_loaded[$node_2->nid], $all_nodes[$node_2->nid], 'Loaded node 2 is identical to cached node.');
- $this->assertIdentical($nodes_loaded[$node_3->nid], $all_nodes[$node_3->nid], 'Loaded node 3 is identical to cached node.');
- }
- }
|