Skip to content

Commit

Permalink
limits attribute in subscription as array instead of object
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Baettig committed Jan 9, 2020
1 parent aced607 commit 8682707
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Models/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ public function getLimitsAttribute(): array
$limits = [];
/** @noinspection PhpUndefinedMethodInspection */
foreach ($this->features()->limitType()->get() as $feature) {
$limits[$feature->code] = (object)[
$limits[] = (object)[
'code' => $feature->code,
'restricted_model' => $feature->restricted_model,
'restricted_relation' => $feature->restricted_relation,
'available' => $feature->limit
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/SubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,17 @@ public function it_know_its_limits(): void
$limits = $subscription->limits;
$this->assertCount(2, $limits);
$this->assertEquals((object)[
'code' => 'feature.limited',
'available' => 10,
'restricted_model' => 'modelA',
'restricted_relation' => 'relationA'
], $limits['feature.limited']);
], $limits[0]);
$this->assertEquals((object)[
'code' => 'feature.unlimited',
'available' => 0,
'restricted_model' => 'modelB',
'restricted_relation' => 'relationB'
], $limits['feature.unlimited']);
], $limits[1]);
}

/** @test
Expand Down

0 comments on commit 8682707

Please sign in to comment.