public function testNewGlobalGroupManagement() { $this->openGlobalGroupsManagement(); //Admin can create new global group $this->assertCssCount('css=#groups-grid table.x-grid-item', 4); $this->click('css=#groups-grid a#create-group-btn'); $this->type('css=#groups-grid .x-grid-row-editor input[type="text"]', $grName = 'Global Group 2'); $this->waitForElementPresent($updateBtnSel = 'css=#groups-grid .x-grid-row-editor .x-grid-row-editor-buttons a.x-btn'); $this->waitForElementHasNoClass($updateBtnSel, 'x-item-disabled'); $this->click($updateBtnSel); $this->waitForCssCount('css=#groups-grid table.x-grid-item', 5); $rowSel = 'css=#groups-grid table.x-grid-item:nth-of-type(5) '; $this->waitForElementNotPresent($rowSel . '.x-grid-dirty-cell'); $this->assertEquals($newGroupId = 6, $this->getText($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(2)')); $this->assertEquals($grName, $this->getText($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(3)')); $this->assertEquals('Global', $this->getText($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(4)')); $voterGroup = VoterGroup::model()->findByPk($newGroupId); $this->assertEquals($grName, $voterGroup->name); $this->assertEquals(VoterGroup::TYPE_GLOBAL, $voterGroup->type); $this->assertNull($voterGroup->election_id); //edit $this->click($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(6) img:nth-of-type(2)'); $this->type('css=#groups-grid .x-grid-row-editor input[type="text"]', $grName .= ' Edited'); $this->waitForElementPresent($updateBtnSel = 'css=#groups-grid .x-grid-row-editor .x-grid-row-editor-buttons a.x-btn'); $this->waitForElementHasNoClass($updateBtnSel, 'x-item-disabled'); $this->click($updateBtnSel); $this->waitForNotVisible('css=#groups-grid .x-grid-row-editor'); $this->waitForElementNotPresent($rowSel . '.x-grid-dirty-cell'); $this->assertEquals($newGroupId, $this->getText($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(2)')); $this->assertEquals($grName, $this->getText($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(3)')); $this->assertEquals('Global', $this->getText($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(4)')); $voterGroup->refresh(); $this->assertEquals($grName, $voterGroup->name); $this->assertEquals(VoterGroup::TYPE_GLOBAL, $voterGroup->type); $this->assertNull($voterGroup->election_id); //add users $this->assertCount(0, $voterGroup->voterGroupMembers); $this->click($rowSel . 'tr.x-grid-row td.x-grid-cell:nth-of-type(6) img:nth-of-type(1)'); $this->waitForElementPresent($tabHeaderSel = 'css=#members-tabs .x-tab-bar a.x-tab'); $this->assertElementContainsText($tabHeaderSel, $grName); $this->sleep(1500); $this->assertCssCount('css=#members-tabs div[id|="groupmembersgrid"] table.x-grid-item', 0); $this->click('css=#members-tabs div[id|="groupmembersgrid"] a.x-btn'); $this->waitForPresent('css=#add-electors-window div[id|="aes-operableusersgrid"]', 20000); $this->waitForCssCount('css=#add-electors-window div[id|="aes-operableusersgrid"] table.x-grid-item', 6, 20000); $this->click('css=#add-electors-window div[id|="aes-operableusersgrid"] .x-grid-header-ct .x-column-header-checkbox span'); $this->assertCssCount('css=#add-electors-window div[id|="aes-operableusersgrid"] table.x-grid-item-selected', 6); $this->click('css=#add-electors-window-body #add-users-btn'); $this->waitForCssCount('css=#add-electors-window div[id|="aes-operableusersgrid"] table.x-grid-item', 0, 10000); $this->click('css=#add-electors-window img.x-tool-close'); $this->waitForCssCount('css=#members-tabs div[id|="groupmembersgrid"] table.x-grid-item', 6); $this->sleep(1000); $this->assertCount(6, $voterGroup->getRelated('voterGroupMembers', true)); //remove several users $this->click("css=#members-tabs div[id|=\"groupmembersgrid\"] table.x-grid-item:nth-of-type(1) " . "td.x-grid-cell-row-checker div.x-grid-row-checker"); $this->controlKeyDown(); $this->click("css=#members-tabs div[id|=\"groupmembersgrid\"] table.x-grid-item:nth-of-type(2) " . "td.x-grid-cell-row-checker div.x-grid-row-checker"); $this->click("css=#members-tabs div[id|=\"groupmembersgrid\"] table.x-grid-item:nth-of-type(3) " . "td.x-grid-cell-row-checker div.x-grid-row-checker"); $this->controlKeyUp(); $this->assertCssCount('css=#members-tabs div[id|="groupmembersgrid"] table.x-grid-item-selected', 3); $this->click('css=#members-tabs div[id|="groupmembersgrid"] a.x-btn:nth-of-type(2)'); $this->confirm(); $this->waitForCssCount('css=#members-tabs div[id|="groupmembersgrid"] table.x-grid-item', 3); $this->assertCount(3, $voterGroup->getRelated('voterGroupMembers', true)); //delete group $this->click($rowSel . "td.x-grid-cell-row-checker div.x-grid-row-checker"); $this->click('id=remove-groups-btn'); $this->confirm(); $this->waitForCssCount('css=#groups-grid table.x-grid-item', 4); $this->assertElementNotContainsText('css=#groups-grid', $grName); $this->sleep(1500); $this->assertNull(VoterGroup::model()->findByPk($newGroupId)); $this->assertCount(0, VoterGroupMember::model()->findAllByAttributes(array('voter_group_id' => $newGroupId))); }
public function testUserAddsToGroupsAfterConfirmationInElectionWithConfirmationNeeded() { $userId = 2; $err = new ElectorRegistrationRequest(); $err->election_id = $electionId = 3; $err->initiator_id = $userId; $err->user_id = $userId; $err->data = array('groups' => array(1, 2)); $this->assertTrue($err->save()); $groupMembers = VoterGroupMember::model()->findAllByAttributes(array('user_id' => $userId)); $this->assertCount(0, $groupMembers); $err->status = ElectorRegistrationRequest::STATUS_REGISTERED; $this->assertTrue($err->save()); $groupMembers = VoterGroupMember::model()->findAllByAttributes(array('user_id' => $userId)); $this->assertCount(2, $groupMembers); $this->assertInstanceOf(VoterGroupMember, VoterGroupMember::model()->findByAttributes(array('user_id' => $userId, 'voter_group_id' => 1))); $this->assertInstanceOf(VoterGroupMember, VoterGroupMember::model()->findByAttributes(array('user_id' => $userId, 'voter_group_id' => 2))); }
public function testRegisterInElectionWithAddingToGroupWithoutConfirmation() { $electionId = 11; $this->login('*****@*****.**', 'qwerty'); $this->open('election/electorate/' . $electionId); $this->waitForPageToLoad(); $this->waitForCssCount('css=#electoral-list-tab .items div.user-info', 0); $this->click('css=#register-elector'); $this->sleep(500); $this->assertCssCount('css=div.flash-messages div.alert', 0); // Wait for visible modal $this->waitForPresent($modalSel = 'css=.modal'); $this->waitForVisible($modalSel); // With visible local groups to select $election = Election::model()->findByPk($electionId); $availGroups = $election->localVoterGroups; $this->assertGreaterThan(0, $count = count($availGroups)); $this->assertEquals(3, $count); $checkboxSel = 'css=div.modal-body > label.checkbox:nth-of-type({%index%}) > input'; foreach ($availGroups as $index => $group) { $this->assertElementContainsText('css=.modal-body', $group->name); $this->assertEquals($group->id, $this->getAttribute($this->parseSel($checkboxSel, array('index' => $index + 1)), 'value')); } //Check that register button is inactive $this->assertElementAttributeEquals($regBtn = 'css=.modal-footer > button', 'disabled', 'disabled'); // Select several $this->click($this->parseSel($checkboxSel, array('index' => 1))); $this->click($this->parseSel($checkboxSel, array('index' => 2))); //Check that register button was activated $this->assertElementAttributeEquals($regBtn, 'disabled', false); // Press submit button $this->click($regBtn); // Wait for modal hide $this->waitForNotPresent($modalSel); // Wait for #register-elector hide $this->waitForNotPresent('css=#register-elector'); // Wait for notification present $this->assertCssCount('css=div.flash-messages div.alert', 1); $this->assertElementContainsText('css=div.flash-messages div.alert', 'You have been registered as elector.'); $this->click('css=div.flash-messages div.alert a.close'); $this->waitForNotPresent('css=div.flash-messages div.alert'); $this->waitForCssCount('css=#dest-tab .items div.user-info', 1); $this->assertElementContainsText('css=#dest-tab .items div.user-info:nth-of-type(1) a', 'Another User'); // Look into DB and check that Elector really was added to selected groups $this->assertInstanceOf(VoterGroupMember, VoterGroupMember::model()->findByAttributes(array('user_id' => 2, 'voter_group_id' => $availGroups[0]->id))); $this->assertInstanceOf(VoterGroupMember, VoterGroupMember::model()->findByAttributes(array('user_id' => 2, 'voter_group_id' => $availGroups[1]->id))); }