Laravel向我的功能测试中添加tearDown()导致BindingResolutionException:目标类[config]不存在

时间:2020-05-06 19:53:27

标签: laravel

我正在进行涉及添加条带客户的测试,测试完成后,我想从条带中删除他们。

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

use App\Plan;


class AccountsTest extends TestCase
{
    use RefreshDatabase;

    protected $account;
    protected $user;

    public function setUp() :void
    {
        parent::setUp();
        $this->seed();
    }

    public function tearDown(): void
    {
        parent::tearDown();
        if (isset($this->account) && $this->account->hasStripeId()) {
            $this->account->asStripeCustomer()->delete();
        }

    }

    // sets up user and account and stripe customer
    private function setUpSubscribedAccount($stripe_plan = 'Enterprise') {
     ...
    }



    /**
     * @test
     */
    public function a_user_can_visit_account_page() {

        $this->setUpSubscribedAccount();
        $this->actingAs($this->user);

        $this->get(route('account.show'))
            ->assertStatus(200);

    }
    ...


}

具有tearDown的结果

“ Illuminate \ Contracts \ Container \ BindingResolutionException:目标类[config]不存在。” “由ReflectionException引起:类配置不存在”

一旦删除它,我的测试就会通过,并且不会发生任何错误。

0 个答案:

没有答案