public function testGroupsActionMember()
 {
     $groups = array(array('Id' => 1, 'Name' => 'group1'), array('Id' => 2, 'Name' => 'group2'));
     $resultSet = new \Zend\Db\ResultSet\ResultSet();
     $resultSet->initialize($groups);
     $memberships = array(1 => \Model\Client\Client::MEMBERSHIP_AUTOMATIC, 2 => \Model\Client\Client::MEMBERSHIP_ALWAYS);
     $formGroups = array('group1' => \Model\Client\Client::MEMBERSHIP_AUTOMATIC, 'group2' => \Model\Client\Client::MEMBERSHIP_ALWAYS);
     $form = $this->getApplicationServiceLocator()->get('FormElementManager')->get('Console\\Form\\GroupMemberships');
     $form->expects($this->once())->method('render')->will($this->returnValue('<form></form>'));
     $form->expects($this->once())->method('setData')->with(array('Groups' => $formGroups));
     $form->expects($this->once())->method('setAttribute')->with('action', '/console/client/managegroups/?id=1');
     $client = $this->createMock('Model\\Client\\Client');
     $client->expects($this->once())->method('getGroupMemberships')->with(\Model\Client\Client::MEMBERSHIP_ANY)->willReturn($memberships);
     $client->method('offsetGet')->will($this->returnValueMap(array(array('Id', 1))));
     $this->_clientManager->method('getClient')->willReturn($client);
     $this->_groupManager->expects($this->once())->method('getGroups')->with(null, null, 'Name')->willReturn($resultSet);
     $this->dispatch('/console/client/groups/?id=1');
     $this->assertResponseStatusCode(200);
     $this->assertXpathQueryContentContains('//h2', "\nGruppenmitgliedschaften\n");
     $this->assertXpathQueryContentContains('//tr[2]/td[1]/a[@href="/console/group/general/?name=group1"]', 'group1');
     $this->assertXpathQueryContentContains('//tr[2]/td[2]', "\nautomatisch\n");
     $this->assertXpathQueryContentContains('//tr[3]/td[1]/a[@href="/console/group/general/?name=group2"]', 'group2');
     $this->assertXpathQueryContentContains('//tr[3]/td[2]', "\nmanuell\n");
     $this->assertXpathQueryContentContains('//h2', "\nMitgliedschaften verwalten\n");
     $this->assertXPathQuery('//form');
 }
 public function testDeleteActionPostYesError()
 {
     $group = $this->getMock('Model\\Group\\Group');
     $group->method('offsetGet')->with('Name')->willReturn('test');
     $this->_groupManager->expects($this->once())->method('getGroup')->with('test')->willReturn($group);
     $this->_groupManager->expects($this->once())->method('deleteGroup')->with($group)->will($this->throwException(new \Model\Group\RuntimeException()));
     $this->dispatch('/console/group/delete/?name=test', 'POST', array('yes' => 'Yes'));
     $this->assertRedirectTo('/console/group/index/');
     $this->assertEquals(array(), $this->_getControllerPlugin('FlashMessenger')->getCurrentSuccessMessages());
     $this->assertEquals(array(array('Group \'%s\' could not be deleted. Try again later.' => 'test')), $this->_getControllerPlugin('FlashMessenger')->getCurrentErrorMessages());
 }
Esempio n. 3
0
 public function testProcessExistingGroup()
 {
     $group = $this->createMock('Model\\Group\\Group');
     $group->expects($this->once())->method('setMembersFromQuery')->with('what', 'filter', 'search', 'operator', 'invert');
     $this->_groupManager->expects($this->never())->method('createGroup');
     $this->_groupManager->expects($this->once())->method('getGroup')->with('name')->willReturn($group);
     $data = array('What' => 'what', 'Where' => 'existing', 'ExistingGroup' => 'name');
     $form = $this->getMockBuilder('Console\\Form\\AddToGroup')->setMethods(array('getData'))->getMock();
     $form->expects($this->once())->method('getData')->will($this->returnValue($data));
     $form->setOption('GroupManager', $this->_groupManager);
     $this->assertEquals($group, $form->process('filter', 'search', 'operator', 'invert'));
 }