title: Cakephp 4 - authentication 2 - How to test login?
body: <p>I have a login method that works fine with <a href="https://book.cakephp.org/authentication/2/en/index.html#building-a-login-action" rel="nofollow noreferrer">authentication 2</a>.</p>
  <p>I need to write an integration test of the login method, but it fail with FAILURE_IDENTITY_NOT_FOUND</p>
  <p>Here is the test:</p>
  <pre><code>public function testLoginOk()
  {
      $this-&gt;enableCsrfToken();
      $this-&gt;enableSecurityToken();
      $this-&gt;enableRetainFlashMessages();
  
      $this-&gt;post('/users/login', [
          'user_login' =&gt; 'user1',
          'password' =&gt; 'P!tU!i!ZIMI&amp;',
  
      ]);
      $this-&gt;assertFlashMessage(__('You are connected'));
  }
  </code></pre>
  <p>In the fixture, the user1 password if hasshed
  [</p>
  <pre><code>'id' =&gt; 1,
  'user_login' =&gt; 'user1',
  'user_pass' =&gt; 'e430ff579ef1db71e654852e548e0f327b0e3d18', # P!tU!i!ZIMI&amp;
  'user_status' =&gt; 1,
  ...
  </code></pre>
  <p>In Application.php</p>
  <pre><code>        $fields = [
              'username' =&gt; 'user_login',
              'password' =&gt; 'password'
          ];
  
          // Load the authenticators, you want session first
          $service-&gt;loadAuthenticator('Authentication.Session');
          $service-&gt;loadAuthenticator('Authentication.Cookie');
          $service-&gt;loadAuthenticator('Authentication.Form', [
              'fields' =&gt; $fields,
              'loginUrl' =&gt; '/users/login'
          ]);
  </code></pre>
  <p>I can't figure out why the test do not work, any ideas ?
  Thanks</p>