protected function AbstractOpignoTestCase::createOGNode in Opigno 7.0
File
- tests/
AbstractOpignoTestCase.inc, line 75 - Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests. This class will also configure all modules to work correctly for Opigno.
Class
- AbstractOpignoTestCase
- @file Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests. This class will also configure all modules to work correctly for Opigno.
Code
protected function createOGNode($type, $user = NULL, $edit = array()) {
if (!isset($user)) {
$user = $this->admin_user;
}
// Login the node author
$this
->drupalLogin($user);
// Set the form fields
$base = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(16),
);
$edit = $base + $edit;
$this
->drupalGet('node/add/' . str_replace('_', '-', $type));
// Add node
$this
->drupalPost($this
->getURL(), $edit, 'Save');
// Get new node nid
$matches = array();
if (preg_match_all('/node\\/([0-9]+)/', $this
->getURL(), $matches)) {
$nid = $matches[1];
$node = node_load($nid);
// Return group gid and nid
return array(
$node->group_group[LANGUAGE_NONE][0]['value'],
$nid,
);
}
else {
$this
->assertTrue(FALSE, 'Could not find the new node nid in the URL.');
}
}