You are here

protected function ProtectedNodeFieldCollection::createProtectedNodeWithFieldCollection in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.field_collection.test \ProtectedNodeFieldCollection::createProtectedNodeWithFieldCollection()

Helper for creating a new protected node with a field collection item.

Please make sure the user has the permission to create the node before calling the method.

Parameters

string $password: A password.

Return value

array An array containing the node and the field_collection_item object.

4 calls to ProtectedNodeFieldCollection::createProtectedNodeWithFieldCollection()
ProtectedNodeFieldCollection::testAllowedView in tests/protected_node.field_collection.test
Test function.
ProtectedNodeFieldCollection::testAllowedViewWrongPassword in tests/protected_node.field_collection.test
Test function.
ProtectedNodeFieldCollection::testAuthenticatedMultipleNodesAllowedView in tests/protected_node.field_collection.test
Test function.
ProtectedNodeFieldCollection::testAuthenticatedNonAllowedView in tests/protected_node.field_collection.test
Test function.

File

tests/protected_node.field_collection.test, line 243
Test protected node behavior with field collection private files.

Class

ProtectedNodeFieldCollection
Configure protected_node to use per node password and use private file field.

Code

protected function createProtectedNodeWithFieldCollection($password) {
  $node = $this
    ->createProtectedNode($password);

  // Retrieve the field collection item.
  $field_collection_item_id = $node->{$this->field_collection_field_name}[LANGUAGE_NONE][0]['value'];
  $field_collection_items = entity_load('field_collection_item', array(
    $field_collection_item_id,
  ));
  $field_collection_item = array_shift($field_collection_items);
  return array(
    'node' => $node,
    'field_collection_item' => $field_collection_item,
  );
}