/** * Makes sure adding a user happens without errors * * @link http://issues.thebuggenie.com/thebuggenie/issues/2494 * * @covers thebuggenie\core\modules\configuration\Actions::runAddUser * @dataProvider addUserRequestProvider */ public function testRunAddUser($username, $buddyname, $email, $password, $group_id) { \b2db\Core::resetMocks(); $scope = $this->getMockBuilder('thebuggenie\\core\\entities\\Scope')->setMethods(array('hasUsersAvailable'))->getMock(); $scope->method('hasUsersAvailable')->willReturn(true); \thebuggenie\core\framework\Context::setScope($scope); $request = new \thebuggenie\core\framework\Request(); $request->setParameter('username', $username); $request->setParameter('buddyname', $buddyname); $request->setParameter('email', $email); $request->setParameter('password', $password); $request->setParameter('password_repeat', $password); $request->setParameter('group_id', $group_id); $usertablestub = $this->getMockBuilder('b2db\\Table')->setMethods(array('isUsernameAvailable'))->getMock(); $userscopestablestub = $this->getMockBuilder('b2db\\Table')->getMock(); \b2db\Core::setTableMock('thebuggenie\\core\\entities\\tables\\UserScopes', $userscopestablestub); \b2db\Core::setTableMock('thebuggenie\\core\\entities\\User', $usertablestub); \b2db\Core::setTableMock('thebuggenie\\core\\entities\\tables\\Users', $usertablestub); $usertablestub->method('isUsernameAvailable')->will($this->returnValue(true)); // Expect action to verify that username is available $usertablestub->expects($this->once())->method('isUsernameAvailable')->with($username); $userscopestablestub->expects($this->once())->method('countUsers'); $this->object->runAddUser($request); $userobject = \b2db\Core::getTable('thebuggenie\\core\\entities\\tables\\Users')->getLastMockObject(); // Expect action to set correct user properties $this->assertEquals($userobject->getUsername(), $username); $this->assertEquals($userobject->getBuddyname(), $buddyname); $this->assertEquals($userobject->getRealname(), $username); $this->assertEquals($userobject->getEmail(), $email); }