How to test Signup function in UserController


#1

Here is my UserController.php
public function signup()
{
$user = $this->Users->newEntity();
if ($this->request->is(‘post’)) {
$user = $this->Users->patchEntity($user, $this->request->getData());
if ($this->Users->save($user)) {
$this->Flash->success(__(‘The user has been saved.’));

            return $this->redirect(['action' => 'index']);
        }
        $this->Flash->error(__('The user could not be saved. Please, try again.'));
    }
    $this->set(compact('user'));//pass to the view
    $this->set('_serialize', ['user']);
}

#2

https://book.cakephp.org/3.0/en/development/testing.html#controller-integration-testing


#3

Thank you so much for quick help!