11 changed files with 147 additions and 47 deletions
-
2app/Entities/Projects/Status.php
-
7app/Entities/Subscriptions/Subscription.php
-
33app/Entities/Subscriptions/Type.php
-
19app/Http/Controllers/SubscriptionsController.php
-
1resources/lang/id/app.php
-
4resources/views/subscriptions/create.blade.php
-
3resources/views/subscriptions/edit.blade.php
-
6resources/views/subscriptions/index.blade.php
-
19tests/Unit/Models/SubscriptionTest.php
-
38tests/Unit/References/SubscriptionTypeTest.php
@ -0,0 +1,33 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Entities\Subscriptions; |
||||
|
|
||||
|
use App\Entities\ReferenceAbstract; |
||||
|
|
||||
|
class Type extends ReferenceAbstract |
||||
|
{ |
||||
|
protected static $lists = [ |
||||
|
1 => 'domain', |
||||
|
2 => 'hosting', |
||||
|
]; |
||||
|
|
||||
|
protected static $colors = [ |
||||
|
1 => '#337ab7', |
||||
|
2 => '#4caf50', |
||||
|
]; |
||||
|
|
||||
|
public static function getNameById($singleId) |
||||
|
{ |
||||
|
return trans('subscription.types.'.static::getById($singleId)); |
||||
|
} |
||||
|
|
||||
|
public static function toArray() |
||||
|
{ |
||||
|
$lists = []; |
||||
|
foreach (static::$lists as $key => $value) { |
||||
|
$lists[$key] = trans('subscription.types.'.$value); |
||||
|
} |
||||
|
|
||||
|
return $lists; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Tests\Unit\Reference; |
||||
|
|
||||
|
use App\Entities\Subscriptions\Type; |
||||
|
use Tests\TestCase; |
||||
|
|
||||
|
class SubscriptionTypeTest extends TestCase |
||||
|
{ |
||||
|
/** @test */ |
||||
|
public function retrieve_subscription_type_list() |
||||
|
{ |
||||
|
$subscriptionType = new Type; |
||||
|
|
||||
|
$this->assertEquals([ |
||||
|
1 => trans('subscription.types.domain'), |
||||
|
2 => trans('subscription.types.hosting'), |
||||
|
], $subscriptionType->toArray()); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function retrieve_subscription_type_name_by_id() |
||||
|
{ |
||||
|
$subscriptionType = new Type; |
||||
|
|
||||
|
$this->assertEquals(trans('subscription.types.domain'), $subscriptionType->getNameById(1)); |
||||
|
$this->assertEquals(trans('subscription.types.hosting'), $subscriptionType->getNameById(2)); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function retrieve_subscription_type_color_class_by_id() |
||||
|
{ |
||||
|
$subscriptionType = new Type; |
||||
|
|
||||
|
$this->assertEquals('#337ab7', $subscriptionType->getColorById(1)); |
||||
|
$this->assertEquals('#4caf50', $subscriptionType->getColorById(2)); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue