diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
index 7bd8c1d..979d377 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
@@ -24,6 +24,10 @@ class NodeAccessRecordsTest extends NodeTestBase {
     // hook_node_access_records(), hook_node_grants_alter() and
     // hook_node_access_records_alter().
     parent::setUp('node_test');
+
+    // Create more content types for testing.
+    $this->drupalCreateContentType(array('type' => 'insert_hook_order_test', 'name' => 'Insert Hook Order Test Content Type'));
+    $this->drupalCreateContentType(array('type' => 'update_hook_order_test', 'name' => 'Update Hook Order Test Content Type'));
   }
 
   /**
@@ -87,5 +91,26 @@ class NodeAccessRecordsTest extends NodeTestBase {
     $node6 = $this->drupalCreateNode(array('status' => 0, 'disable_node_access' => TRUE));
     $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node6->nid))->fetchAll();
     $this->assertEqual(count($records), 0, t('Returned no records for unpublished node.'));
+
+    // Create a hook order test node.
+    $node7 = $this->drupalCreateNode(array('type' => 'insert_hook_order_test'));
+    $this->assertTrue(node_load($node7->nid), t('Hook order test node created.'));
+
+    // Check to see if grant was updated by node_test_node_insert
+    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node7->nid))->fetchAll();
+    $this->assertEqual(count($records), 1, t('Returned the correct number of rows.'));
+    $this->assertEqual($records[0]->realm, 'test_hook_order_realm', t('Grant with test_hook_order_realm acquired for node.'));
+    $this->assertEqual($records[0]->gid, 2, t('Altered grant with gid = 2 acquired for node.'));
+
+    // Create a update hook order test node.
+    $node8 = $this->drupalCreateNode(array('type' => 'update_hook_order_test'));
+    node_save($node8);
+    $this->assertTrue(node_load($node8->nid), t('Hook order test node created.'));
+
+    // Check to see if grant was updated by node_test_node_update
+    $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node8->nid))->fetchAll();
+    $this->assertEqual(count($records), 1, t('Returned the correct number of rows.'));
+    $this->assertEqual($records[0]->realm, 'test_hook_order_realm', t('Grant with test_hook_order_realm acquired for node.'));
+    $this->assertEqual($records[0]->gid, 2, t('Altered grant with gid = 2 acquired for node.'));
   }
 }
diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module
index f541d10..564e177 100644
--- a/core/modules/node/tests/modules/node_test/node_test.module
+++ b/core/modules/node/tests/modules/node_test/node_test.module
@@ -62,6 +62,7 @@ function node_test_node_grants($account, $op) {
     'test_article_realm' => array(1),
     'test_page_realm' => array(1),
     'test_alter_realm' => array(2),
+    'test_hook_order_realm' => array(1, 2),
   );
 }
 
@@ -96,6 +97,44 @@ function node_test_node_access_records(Node $node) {
       'priority' => 0,
     );
   }
+  elseif ($node->type == 'insert_hook_order_test') {
+    // We vary the gid based on some property of the node which is changed
+    // by hook_insert. In this example the title.
+    if (!preg_match('/^.* \(nid:\d+\)$/', $node->title)) {
+      $gid = 1;
+    } else {
+      $gid = 2;
+    }
+
+    // Create grant in arbitrary test_hook_order_realm for hook order test 
+    // nodes.
+    $grants[] = array(
+      'realm' => 'test_hook_order_realm',
+      'gid' => $gid,
+      'grant_view' => 1,
+      'grant_update' => 0,
+      'grant_delete' => 0,
+      'priority' => 0,
+    );
+  }
+  elseif ($node->type == 'update_hook_order_test') {
+    if (substr($node->title, -7) != '_update') {
+      $gid = 1;
+    } else {
+      $gid = 2;
+    }
+
+    // Create grant in arbitrary test_hook_order_realm for update hook order 
+    // test nodes.
+    $grants[] = array(
+      'realm' => 'test_hook_order_realm',
+      'gid' => $gid,
+      'grant_view' => 1,
+      'grant_update' => 0,
+      'grant_delete' => 0,
+      'priority' => 0,
+    );
+  }
   return $grants;
 }
 
@@ -141,11 +180,39 @@ function node_test_node_presave(Node $node) {
 }
 
 /**
+ * Implements hook_node_insert().
+ */
+function node_test_node_insert(Node $node) {
+  if ($node->type == 'insert_hook_order_test') {
+    // We clone the original node object and save it rather than updating the
+    // original. This ensures that the node_access_records function receives
+    // different node objects independent of the order of hooks in 
+    // $node->save() and allows us to test that the correct data is stored.
+    //
+    // This is unneccessary in this use case but may not be in more complex
+    // siutations.
+    $updated_node = clone $node;
+
+    // Including the nid is an often requested task so we'll use that to 
+    // demonstrate.
+    $updated_node->title .= ' (nid:' . $updated_node->nid . ')';
+    $updated_node->save();
+  }
+}
+
+/**
  * Implements hook_node_update().
  */
 function node_test_node_update(Node $node) {
+  if ($node->type == 'update_hook_order_test' && substr($node->title, -7) != '_update') {
+    // See the node_test_node_insert comments for why we clone the node 
+    // object.
+    $updated_node = clone $node;
+    $updated_node->title .= '_update';
+    node_save($updated_node);
+  }
   // Determine changes on update.
-  if (!empty($node->original) && $node->original->title == 'test_changes') {
+  elseif (!empty($node->original) && $node->original->title == 'test_changes') {
     if ($node->original->title != $node->title) {
       $node->title .= '_update';
     }
