function RulesIntegrationTestCase::testPathIntegration

Same name in other branches
  1. 8.x-3.x d7-tests/rules_integration_test_case.test \RulesIntegrationTestCase::testPathIntegration()

Tests the path module integration.

File

tests/rules.test, line 2112

Class

RulesIntegrationTestCase
Tests provided module integration.

Code

public function testPathIntegration() {
    rules_action('path_alias')->execute('foo', 'bar');
    $path = path_load('foo');
    $this->assertTrue($path['alias'] == 'bar', 'URL alias has been created.');
    $alias_exists = rules_condition('path_alias_exists', array(
        'alias' => 'bar',
    ))->execute();
    $this->assertTrue($alias_exists, 'Created URL alias exists.');
    $has_alias = rules_condition('path_has_alias', array(
        'source' => 'foo',
    ))->execute();
    $this->assertTrue($has_alias, 'System path has an alias.');
    // Test node alias action.
    $node = $this->drupalCreateNode();
    rules_action('node_path_alias')->execute($node, 'test');
    $path = path_load("node/{$node->nid}");
    $this->assertTrue($path['alias'] == 'test', 'Node URL alias has been created.');
    // Test term alias action.
    $term = entity_property_values_create_entity('taxonomy_term', array(
        'name' => $this->randomName(),
        'vocabulary' => 1,
    ))
        ->value();
    rules_action('taxonomy_term_path_alias')->execute($term, 'term-test');
    $path = path_load("taxonomy/term/{$term->tid}");
    $this->assertTrue($path['alias'] == 'term-test', 'Term URL alias has been created.');
    RulesLog::logger()->checkLog();
}