CakeDC\Users\Test\TestCase\Controller\Traits\RegisterTraitTest::testRegisterLoggedInUserNotAllowed PHP Метод

testRegisterLoggedInUserNotAllowed() публичный Метод

test
public testRegisterLoggedInUserNotAllowed ( ) : void
Результат void
    public function testRegisterLoggedInUserNotAllowed()
    {
        $allowLoggedIn = Configure::read('Users.Registration.allowLoggedIn');
        Configure::write('Users.Registration.allowLoggedIn', false);
        $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('error')->with('You must log out to register a new user account');
        $this->Trait->expects($this->once())->method('redirect')->with(Configure::read('Users.Profile.route'));
        $this->Trait->request->data = ['username' => 'testRegistration', 'password' => 'password', 'email' => '[email protected]', 'password_confirm' => 'password', 'tos' => 1];
        $this->Trait->register();
        $this->assertEquals(0, $this->table->find()->where(['username' => 'testRegistration'])->count());
        Configure::write('Users.Registration.allowLoggedIn', $allowLoggedIn);
    }