You are here

function OgTestCase::_addOgContent in Organic groups 6

Same name and namespace in other branches
  1. 6.2 tests/og_testcase.php \OgTestCase::_addOgContent()

Helper function - create a group content.

Parameters

$type: The type name of the content type.

$og_type: The og type - group or post.

$edit: An array of settings to add to the defaults.

$keys: An array with the keys that need to be present in the $node object after node_load().

Return value

The newly created node id.

2 calls to OgTestCase::_addOgContent()
OgTestCase::addOgGroup in tests/og_testcase.php
Create a group node.
OgTestCase::addOgPost in tests/og_testcase.php
Create a group post.

File

tests/og_testcase.php, line 79
Common functions for all the organic groups tests.

Class

OgTestCase
@file Common functions for all the organic groups tests.

Code

function _addOgContent($type, $og_type, $edit = array(), $keys = array()) {
  $edit['title'] = $this
    ->randomName(8);
  $edit['body'] = $this
    ->randomName(32);
  $type_hyphen = str_replace('_', '-', $type);
  $this
    ->drupalPost('node/add/' . $type_hyphen, $edit, t('Save'));

  // Check that the form has been submitted.
  $this
    ->assertRaw(t('!type %title has been created.', array(
    '!type' => $type,
    '%title' => $edit['title'],
  )), t('%og_type created.', array(
    '%og_type' => $og_type,
  )));

  // Assert the node has loaded properly.
  $node = node_load(array(
    'title' => $edit['title'],
  ));
  $node = (array) $node;
  $this
    ->assertTrue($this
    ->assertKeysExist($keys, $node), t('%og_type loaded properly.', array(
    '%og_type' => $og_type,
  )));

  // Node was casted to an array.
  return $node['nid'];
}