Skip to content

Commit

Permalink
Merge pull request #1192 from archey347/hotfix-tests
Browse files Browse the repository at this point in the history
Fix for AccountControllerTest when registration is disabled
  • Loading branch information
lcharette authored Jan 28, 2022
2 parents cfbc49a + 20192dc commit 5494cd9
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public function testRegisterWithNoMasterUser(AccountController $controller)
*/
public function testRegister()
{
// Force Registration
$this->ci->config['site.registration.enabled'] = true;

// Force locale config
$this->ci->config['site.registration.user_defaults.locale'] = 'en_US';
$this->ci->config['site.locales.available'] = [
Expand Down Expand Up @@ -146,6 +149,9 @@ public function testRegister()
*/
public function testRegisterWithNoEmailVerification()
{
// Force Registration
$this->ci->config['site.registration.enabled'] = true;

// Delete previous attempt so we can reuse the same shared test code
if ($user = User::where('email', '[email protected]')->first()) {
$user->delete(true);
Expand Down Expand Up @@ -763,6 +769,12 @@ public function testpageForgotPassword(AccountController $controller)
*/
public function testpageRegister(AccountController $controller)
{
// Force Registration
$this->ci->config['site.registration.enabled'] = true;

// Recreate controller to use new config
$controller = $this->getController();

$result = $controller->pageRegister($this->getRequest(), $this->getResponse(), []);
$this->assertInstanceOf(\Psr\Http\Message\ResponseInterface::class, $result);
$this->assertSame($result->getStatusCode(), 200);
Expand Down Expand Up @@ -793,6 +805,7 @@ public function testpageRegisterWithNoLocales()
{
// Force config
$this->ci->config['site.locales.available'] = [];
$this->ci->config['site.registration.enabled'] = true;

// Recreate controller to use new config
$controller = $this->getController();
Expand All @@ -809,6 +822,9 @@ public function testpageRegisterWithNoLocales()
*/
public function testpageRegisterWithLoggedInUser()
{
// Force Config
$this->ci->config['site.registration.enabled'] = true;

// Create a test user
$testUser = $this->createTestUser(false, true);

Expand Down Expand Up @@ -1179,6 +1195,9 @@ public function testRegisterWithLoggedInUser()
*/
public function testRegisterWithFailedThrottle()
{
// Force config
$this->ci->config['site.registration.enabled'] = true;

// Create fake throttler
$throttler = m::mock(Throttler::class);
$throttler->shouldReceive('getDelay')->once()->with('registration_attempt')->andReturn(90);
Expand Down Expand Up @@ -1211,6 +1230,12 @@ public function testRegisterWithFailedThrottle()
*/
public function testRegisterWithFailedCaptcha(AccountController $controller)
{
// Force config
$this->ci->config['site.registration.enabled'] = true;

// Recreate controller with new config
$controller = $this->getController();

// Bypass security feature
$fm = $this->ci->factory;
$dummyUser = $fm->create(User::class);
Expand Down Expand Up @@ -1240,6 +1265,12 @@ public function testRegisterWithFailedCaptcha(AccountController $controller)
*/
public function testRegisterWithFailedValidation(AccountController $controller)
{
// Force config
$this->ci->config['site.registration.enabled'] = true;

// Recreate controller with new config
$controller = $this->getController();

// Bypass security feature
$fm = $this->ci->factory;
$dummyUser = $fm->create(User::class);
Expand Down

0 comments on commit 5494cd9

Please sign in to comment.