バージョン
Cakephp3 3.5
背景
$this->loadComponent('Csrf')で
CSRFコンポーネントをロードしているコントローラにて
テストコードを書いた際、$this->postが403Forbiddenになり困った。
解決
$this->_csrfToken = true; //この行を追加
$this->get('users/add');
$email = 'test@email.com';
$button = 'confirm';
$this->session($this->_requestSession->read());
$this->post('users/add',compact(['email','button']);
※1行目が無いと403Forbiddenがレスポンスされる。