CakeDC\Users\Test\TestCase\Controller\Traits\RegisterTraitTest::testRegisterLoggedInUserAllowed PHP Method

testRegisterLoggedInUserAllowed() public method

test
    public function testRegisterLoggedInUserAllowed()
    {
        $allowLoggedIn = Configure::read('Users.Registration.allowLoggedIn');
        Configure::write('Users.Registration.allowLoggedIn', true);
        $this->assertEquals(0, $this->table->find()->where(['username' => 'testRegistration'])->count());
        $this->_mockRequestPost();
        $this->_mockAuthLoggedIn();
        $this->_mockFlash();
        $this->_mockDispatchEvent();
        $this->Trait->Flash->expects($this->once())->method('success')->with('Please validate your account before log in');
        $this->Trait->expects($this->once())->method('redirect')->with(['action' => 'login']);
        $this->Trait->request->data = ['username' => 'testRegistration', 'password' => 'password', 'email' => '[email protected]', 'password_confirm' => 'password', 'tos' => 1];
        $this->Trait->register();
        $this->assertEquals(1, $this->table->find()->where(['username' => 'testRegistration'])->count());
        Configure::write('Users.Registration.allowLoggedIn', $allowLoggedIn);
    }