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

testRegisterValidationErrors() public method

test
public testRegisterValidationErrors ( ) : void
return void
    public function testRegisterValidationErrors()
    {
        Configure::write('Users.reCaptcha.registration', true);
        $this->assertEquals(0, $this->table->find()->where(['username' => 'testRegistration'])->count());
        $this->_mockRequestPost();
        $this->_mockAuth();
        $this->_mockFlash();
        $this->_mockDispatchEvent();
        $this->Trait->Flash->expects($this->once())->method('error')->with('The user could not be saved');
        $this->Trait->expects($this->once())->method('validateRecaptcha')->will($this->returnValue(true));
        $this->Trait->expects($this->never())->method('redirect');
        $this->Trait->request->data = ['username' => 'testRegistration', 'password' => 'password', 'email' => '[email protected]', 'password_confirm' => 'not-matching', 'tos' => 1];
        $this->Trait->register();
        $this->assertEquals(0, $this->table->find()->where(['username' => 'testRegistration'])->count());
        Configure::write('Users.reCaptcha.registration', false);
    }