public function ViewsRulesViewLoopTestCase::testEvaluate in Views Rules 7
Tests evaluation of a view loop.
File
- tests/
views_rules.test, line 232 - Simpletest implementations.
Class
- ViewsRulesViewLoopTestCase
- Rules plugin tests.
Code
public function testEvaluate() {
$data = $this
->createSiteData();
$expectedData = array(
$data['node1']->title,
$data['node2']->title,
$data['node3']->title,
);
// Test view loop with fields.
$comp = $this
->createTestComponent();
$result = $comp
->execute($data['term']);
$this
->assertIdentical($expectedData, reset($result), 'View loop evaluates correctly.');
// Test view loop without fields.
$comp = $this
->createTestNonFieldComponent();
$result = $comp
->execute($data['term']);
$this
->assertIdentical($expectedData, reset($result), 'Non-field view loop evaluates correctly.');
// Test evaluating view loop after data has changed.
$newNode = (array) $data['node1'];
$newNode = array_intersect_key($newNode, array_flip(array(
'title',
'type',
'field_tags',
)));
$this
->drupalCreateNode($newNode);
$result = $comp
->execute($data['term']);
$this
->assertNotIdentical($expectedData, reset($result), 'View loop result data is not prematurely cached.');
}