initializeOpenApiValidator($_ENV['OPENAPI_SPEC'] ?? APP . '../webroot/docs/openapi.yaml'); $this->collection = new ComponentRegistry(); $this->auth = new FormAuthenticate($this->collection, [ 'userModel' => 'Users', ]); } public function testChangePasswordOwnUser(): void { $this->setAuthToken(AuthKeysFixture::REGULAR_USER_API_KEY); $newPassword = 'Test12345678!'; $this->put( self::ENDPOINT, [ 'password' => $newPassword, ] ); $this->assertResponseOk(); //TODO: $this->assertRequestMatchesOpenApiSpec(); $this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'put'); // Test new password with form login $request = new ServerRequest([ 'url' => 'users/login', 'post' => [ 'username' => UsersFixture::USER_REGULAR_USER_USERNAME, 'password' => $newPassword ], ]); $result = $this->auth->authenticate($request, new Response()); $this->assertEquals(UsersFixture::USER_REGULAR_USER_ID, $result['id']); $this->assertEquals(UsersFixture::USER_REGULAR_USER_USERNAME, $result['username']); } }