Phpunit Laravel出纳伪造测试用户订阅

Phpunit Laravel出纳伪造测试用户订阅,phpunit,laravel-5,stripe-payments,Phpunit,Laravel 5,Stripe Payments,我用拉威尔的收银员结账,这很好。我试图表现良好,并对代码进行测试,但我很难用订阅“伪装”用户 我试过: $user = App\Models\User::create([ 'first_name' => $this->faker->firstName, 'last_name' => $this->faker->lastName, 'email' => $this->faker->email, 'p

我用拉威尔的收银员结账,这很好。我试图表现良好,并对代码进行测试,但我很难用订阅“伪装”用户

我试过:

$user = App\Models\User::create([
  'first_name'    => $this->faker->firstName,
  'last_name'     => $this->faker->lastName,
  'email'         => $this->faker->email,
  'password'      => 'password1234',
  'stripe_plan'   => 'name_of_plan',
  'stripe_active' => 1
]);

$this->be($user);
但是如果我随后选中
$user->onPlan('name\u of \u plan')
我会得到
false
:(


有什么方法可以做到这一点吗?我相信你会理解,在我有测试来备份之前,我并不真的想启动支付系统!

检查“stripe\u plan”和“stripe\u active”是否定义为可供用户填充。如果它们没有定义,那么它可能实际上没有在User::create()中设置这些值,这就是测试失败的原因

class User extends Model implements AuthenticatableContract, CanResetPasswordContract, BillableContract {
    use Authenticatable, CanResetPassword, Billable;

    protected $table = 'users';

    protected $fillable = [
        'first_name', 
        'last_name', 
        'email', 
        'password', 
        'stripe_plan', 
        'stripe_active'
    ];

}

天才!非常感谢。