0

我在 laravel 中运行 adldap2 的后备选项,我没有覆盖 setupUp 或 tearDown 函数,我的测试如下所示:

 /** @test */
    public function login_via_created_user_and_logout()
    {
        $user = factory(User::class)->create(['password' => bcrypt(123456)]);

        $response = $this->post('/api/auth/login', [
            'email' => $user->username,
            'password' => 123456
        ]);
        $response->dump();
        $this->assertAuthenticatedAs(User::where('email', $user->username)->first());

        $this->json('POST', '/api/auth/logout', ['Authorization' => 'Bearer ' . $response->original['access_token']]);
        $this->assertGuest();
    }

    /** @test */
    public function login_ldap_and_logout_user()
    {
        // need at static user
        $response = $this->post('/api/auth/login', [
            'email' => '[username]',
            'password' => '[password]'
        ]);
        $response->assertOk();
        $this->assertAuthenticatedAs(User::find(1));

        $this->json('POST', '/api/auth/logout', ['Authorization' => 'Bearer ' . $response->original['access_token']]);

        $this->assertGuest();
    }

什么时候运行它们clear && php artisan config:clear && phpunit --filter=login_ldap_and_logout_user,它们会通过,但是当我在不过滤的情况下运行它们时,它们会失败testing.ERROR: Class config does not exist {"exception":"[object] (ReflectionException(code: -1): Class config does not exist at


4

0 回答 0