9 changed files with 93 additions and 19 deletions
-
2app/Entities/Payments/Payment.php
-
35app/Entities/Payments/Type.php
-
15app/helpers.php
-
4config/app.php
-
7resources/lang/id/payment.php
-
3resources/views/payments/create.blade.php
-
3resources/views/payments/edit.blade.php
-
41tests/Unit/References/PaymentTypeTest.php
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Payments; |
|||
|
|||
use App\Entities\ReferenceAbstract; |
|||
|
|||
class Type extends ReferenceAbstract |
|||
{ |
|||
protected static $lists = [ |
|||
1 => 'project', |
|||
2 => 'add_feature', |
|||
3 => 'maintenance', |
|||
]; |
|||
|
|||
protected static $colors = [ |
|||
1 => '#337ab7', |
|||
2 => '#4caf50', |
|||
3 => '#ff8181', |
|||
]; |
|||
|
|||
public static function getNameById($singleId) |
|||
{ |
|||
return trans('payment.types.'.static::getById($singleId)); |
|||
} |
|||
|
|||
public static function toArray() |
|||
{ |
|||
$lists = []; |
|||
foreach (static::$lists as $key => $value) { |
|||
$lists[$key] = trans('payment.types.'.$value); |
|||
} |
|||
|
|||
return $lists; |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Unit\Reference; |
|||
|
|||
use App\Entities\Payments\Type; |
|||
use Tests\TestCase; |
|||
|
|||
class PaymentTypeTest extends TestCase |
|||
{ |
|||
/** @test */ |
|||
public function retrieve_payment_type_list() |
|||
{ |
|||
$paymentType = new Type; |
|||
|
|||
$this->assertEquals([ |
|||
1 => trans('payment.types.project'), |
|||
2 => trans('payment.types.add_feature'), |
|||
3 => trans('payment.types.maintenance'), |
|||
], $paymentType->toArray()); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function retrieve_payment_type_name_by_id() |
|||
{ |
|||
$paymentType = new Type; |
|||
|
|||
$this->assertEquals(trans('payment.types.project'), $paymentType->getNameById(1)); |
|||
$this->assertEquals(trans('payment.types.add_feature'), $paymentType->getNameById(2)); |
|||
$this->assertEquals(trans('payment.types.maintenance'), $paymentType->getNameById(3)); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function retrieve_payment_type_color_class_by_id() |
|||
{ |
|||
$paymentType = new Type; |
|||
|
|||
$this->assertEquals('#337ab7', $paymentType->getColorById(1)); |
|||
$this->assertEquals('#4caf50', $paymentType->getColorById(2)); |
|||
$this->assertEquals('#ff8181', $paymentType->getColorById(3)); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue