Skip to content

Commit

Permalink
fix some more definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Baettig committed Mar 13, 2020
1 parent 5917d44 commit 579dc1d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions database/factories/SubscriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
'price' => $faker->randomElement([9900,29900,59900]),
'currency' => 'CHF',
'is_recurring' => $faker->randomElement([true,false]),
'payment_tolerance_ends_at' => Carbon::now()->addDay()->endOfDay()
];
'payment_tolerance_ends_at' => Carbon::now(),
'starts_at' => Carbon::now(),
'expires_at' => Carbon::parse('+10 days'),
'test_ends_at' => Carbon::now()
];
});

$factory->state(Subscription::class, 'paid', static function() {
Expand Down
7 changes: 3 additions & 4 deletions database/migrations/2019_10_01_123211_plan.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Carbon\Carbon;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
Expand Down Expand Up @@ -62,12 +61,12 @@ public function up(): void

$table->boolean('is_recurring')->default(true);

$table->timestamp('test_ends_at')->nullable()->default(Carbon::now());
$table->timestamp('test_ends_at');
$table->timestamp('payment_tolerance_ends_at');
$table->timestamp('paid_at')->nullable();
$table->timestamp('starts_at')->nullable();
$table->timestamp('starts_at');
$table->timestamp('renewed_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamp('expires_at');
$table->timestamp('cancelled_at')->nullable();
$table->timestamp('refunded_at')->nullable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function applyGeneralStartDateCorrections(): void
private function applyGeneralTestEndDateCorrections(): void
{
if (!$this->testingDays || $this->testingDays === 0) {
$this->testEndsDate = null;
$this->testEndsDate = Carbon::now();
}
if ($this->testingDays && $this->testingDays > 0) {
$this->testEndsDate = $this->testEndsDate->addDays($this->testingDays);
Expand Down
1 change: 1 addition & 0 deletions tests/feature/SubscribeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function can_subscribe_to_a_recurring_yearly_plan(): void
/** @var Subscription $subscription */
$subscription = $this->user->active_or_last_subscription;
$this->assertEqualsWithDelta(Carbon::now(), $subscription->starts_at, 1);
$this->assertEqualsWithDelta(Carbon::now(), $subscription->test_ends_at, 1);
$this->assertEqualsWithDelta(Carbon::now()->addYear()->endOfDay(), $subscription->expires_at, 1);
$this->assertTrue($plan->is($subscription->plan));
$this->assertEquals($plan->price, $subscription->price);
Expand Down

0 comments on commit 579dc1d

Please sign in to comment.