? path_api_test.patch
? modules/path/tests
Index: modules/path/path.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.test,v
retrieving revision 1.42
diff -u -p -r1.42 path.test
--- modules/path/path.test	4 Feb 2011 18:42:21 -0000	1.42
+++ modules/path/path.test	7 Feb 2011 22:15:07 -0000
@@ -503,3 +503,58 @@ class PathMonolingualTestCase extends Dr
     $this->assertText(t('Add language'), 'Page contains the add language text');
   }
 }
+
+/**
+ * Tests for path hook invocation.
+ */
+class PathHooksTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Path hooks',
+      'description' => 'Test hooks for path deletion',
+      'group' => 'Path'
+    );      
+  }
+
+  function setUp() {
+    parent::setUp('path_test');
+    $web_user = $this->drupalCreateUser(array('create page content', 'delete own page content', 'administer url aliases', 'create url aliases'));
+    $this->drupalLogin($web_user);
+  }
+
+  function testPathHooks() {
+    // Create test node.
+    $node1 = $this->drupalCreateNode();
+
+    // Generate two test aliases.
+    $alias1 = $this->randomName(8);
+    $alias2 = $this->randomName(8);
+
+    // Insert aliases.
+    $edit = array();
+    $edit['source'] = 'node/' . $node1->nid;
+    $edit['alias'] = $alias1;
+    $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
+    $edit['alias'] = $alias2;
+    $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
+
+    // Test hook_path_insert.
+    $this->assertText('hook_path_insert: node/' . $node1->nid . ' => ' . $alias2);
+
+    // Test hook_path_update.
+    /*
+    $edit['alias'] = $alias2 = $this->randomName(8);
+    $this->drupalPost('admin/config/search/path/edit/' . ##PID##, $edit, t('Save'));
+    $this->assertText('hook_path_update: ' . $edit['source'] . ' => ' . $edit['alias'], 'hook_path_update called.');
+    */
+    // Test hook_path_delete
+    $this->drupalPost('node/' . $node1->nid . '/delete', array(), t('Delete'));
+    $this->assertText('hook_path_delete: node/' . $node1->nid . ' => ' . $alias1);
+    $this->assertText('hook_path_delete: node/' . $node1->nid . ' => ' . $alias2);
+
+    // Test nonalias node deletion.
+    $node2 = $this->drupalCreateNode();
+    $this->drupalPost('node/' . $node2->nid . '/delete', array(), t('Delete'));
+    $this->assertNoText('hook_path_delete called', 'hook_path_delete not called');
+  }
+}
