File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -84,11 +84,11 @@ public function onGenericTrial()
84
84
*/
85
85
public function trialEndsAt ($ name = 'default ' )
86
86
{
87
- if ($ this ->onGenericTrial ( )) {
88
- return $ this -> customer ->trial_ends_at ;
87
+ if ($ subscription = $ this ->subscription ( $ name )) {
88
+ return $ subscription ->trial_ends_at ;
89
89
}
90
90
91
- return $ this ->subscription ( $ name ) ->trial_ends_at ;
91
+ return $ this ->customer ->trial_ends_at ;
92
92
}
93
93
94
94
/**
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ public function test_billable_models_can_create_a_customer_record()
11
11
$ customer = $ user ->createAsCustomer (['trial_ends_at ' => $ trialEndsAt = now ()->addDays (15 )]);
12
12
13
13
$ this ->assertSame ($ trialEndsAt ->timestamp , $ customer ->trial_ends_at ->timestamp );
14
+ $ this ->assertSame ($ trialEndsAt ->timestamp , $ user ->trialEndsAt ()->timestamp );
14
15
$ this ->assertTrue ($ user ->onGenericTrial ());
15
16
}
16
17
@@ -27,4 +28,12 @@ public function test_billable_models_without_having_a_customer_record_can_still_
27
28
$ this ->assertEmpty ($ user ->receipts );
28
29
$ this ->assertNull ($ user ->subscription ());
29
30
}
31
+
32
+ public function test_trial_ends_at_works_if_generic_trial_is_expired ()
33
+ {
34
+ $ user = $ this ->createUser ();
35
+ $ user ->createAsCustomer (['trial_ends_at ' => $ trialEndsAt = now ()->subDays (15 )]);
36
+
37
+ $ this ->assertSame ($ trialEndsAt ->timestamp , $ user ->trialEndsAt ()->timestamp );
38
+ }
30
39
}
You can’t perform that action at this time.
0 commit comments