Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
192
modules/storm/stormevent/stormevent.test
Normal file
192
modules/storm/stormevent/stormevent.test
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk event module
|
||||
*/
|
||||
class StormeventTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk event Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk event module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormevent', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormeventAccess() {
|
||||
$this->drupalGet('events');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk events list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('events');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk events list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm event: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('events');
|
||||
$this->assertText(t('events'), t('Make sure the correct page has been displayed by checking that the title is "events".'));
|
||||
}
|
||||
|
||||
public function testStormeventCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm event: add', 'Storm event: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$event = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormevent', $event, t('Save'));
|
||||
|
||||
$this->assertText(t('event @title has been created.', array('@title' => $event['title'])));;
|
||||
}
|
||||
|
||||
public function testStormeventList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view all', 'Storm event: edit all', 'Storm event: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view of user organization', 'Storm event: edit of user organization', 'Storm event: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view own', 'Storm event: edit own', 'Storm event: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view all', 'Storm event: edit own', 'Storm event: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create events
|
||||
$event1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormevent', $event1, t('Save'));
|
||||
$event1 = node_load(array('title' => $event1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$event2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormevent', $event2, t('Save'));
|
||||
$event2 = node_load(array('title' => $event2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$event3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormevent', $event3, t('Save'));
|
||||
$event3 = node_load(array('title' => $event3['title']));
|
||||
|
||||
// Test for 'Storm event: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertLink($event1->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertLink($event3->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm event: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertLink($event1->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($event3->title, 'The event does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm event: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertNoLink($event1->title, 'The event does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($event3->title, 'The event does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm event: view all', 'Storm event: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertLink($event1->title, 0, 'The event appears on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/delete', 'The event edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertNoRaw('node/'. $event2->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event2->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($event3->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
Reference in a new issue