protected function AbstractOpignoTestCase::createOGContent in Opigno 7.0
File
- tests/AbstractOpignoTestCase.inc, line 111
- 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 createOGContent($type, $gid, $user = NULL, $edit = array()) {
if (!isset($user)) {
$user = $this->admin_user;
}
$this
->drupalLogin($user);
$base = array(
'title' => $this
->randomName(8),
'body[und][0][value]' => $this
->randomName(16),
'group_audience[und][]' => $gid,
);
$edit = $base + $edit;
$this
->drupalGet('node/add/' . str_replace('_', '-', $type));
$this
->drupalPost($this
->getURL(), $edit, 'Save');
$matches = array();
if (preg_match_all('/node\\/([0-9]+)/', $this
->getURL(), $matches)) {
$nid = $matches[1];
return $nid;
}
else {
$this
->assertTrue(FALSE, 'Could not find the new node nid in the URL.');
return 0;
}
}