mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Tests tests and more tests
This commit is contained in:
parent
b853dd80ed
commit
5f7a0b96d7
@ -60,6 +60,8 @@ class ClientSettings extends BaseSettings
|
||||
public $auto_bill;
|
||||
public $auto_archive_invoice;
|
||||
|
||||
public $groups;
|
||||
|
||||
/**
|
||||
* Counter Variables
|
||||
*
|
||||
|
@ -84,6 +84,8 @@ class CompanySettings extends BaseSettings
|
||||
public $inclusive_taxes;
|
||||
|
||||
public $translations;
|
||||
public $group_selectors;
|
||||
public $groups;
|
||||
|
||||
/**
|
||||
* Counter Variables
|
||||
@ -170,6 +172,34 @@ class CompanySettings extends BaseSettings
|
||||
'design' => 'views/pdf/design1.blade.php',
|
||||
|
||||
'translations' => (object) [],
|
||||
'group_selectors' => self::groupSelectors(),
|
||||
'groups' => self::groupObjects(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements App\DataMapper\Group objects
|
||||
* in order to customise grouped option behaviour
|
||||
* @return object Settings objects
|
||||
*/
|
||||
private static function groupObjects()
|
||||
{
|
||||
return (object)[
|
||||
'company_gateways' => NULL,
|
||||
'invoice_designs' => NULL
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Storage point for ALL Group options
|
||||
* @return object Settings objects
|
||||
*/
|
||||
private static function groupSelectors()
|
||||
{
|
||||
return (object)[
|
||||
'company_gateways' => NULL,
|
||||
'invoice_designs' => NULL
|
||||
];
|
||||
}
|
||||
}
|
||||
|
43
app/DataMapper/Group.php
Normal file
43
app/DataMapper/Group.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\DataMapper;
|
||||
|
||||
|
||||
/**
|
||||
* Class Group
|
||||
* @package App\DataMapper
|
||||
*/
|
||||
class Group
|
||||
{
|
||||
/**
|
||||
* Name of the group
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Group slug
|
||||
* @var string
|
||||
*/
|
||||
public $slug;
|
||||
|
||||
/**
|
||||
* Array of data
|
||||
*
|
||||
* Preferably stored as single dimension array
|
||||
* [1,2,3,4,5,6]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $data;
|
||||
|
||||
}
|
@ -19,6 +19,7 @@ use App\Models\Country;
|
||||
use App\Models\Currency;
|
||||
use App\Models\Filterable;
|
||||
use App\Models\Timezone;
|
||||
use App\Utils\Traits\CompanyGatewaySettings;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -36,6 +37,7 @@ class Client extends BaseModel
|
||||
use SoftDeletes;
|
||||
use Filterable;
|
||||
use GeneratesCounter;
|
||||
use CompanyGatewaySettings;
|
||||
|
||||
protected $presenter = 'App\Models\Presenters\ClientPresenter';
|
||||
|
||||
@ -173,7 +175,7 @@ class Client extends BaseModel
|
||||
|
||||
/* If we have a custom gateway list pass this back first */
|
||||
if($settings->payment_gateways)
|
||||
$gateways = $this->company->company_gateways->whereIn('id', $settings->payment_gateways);
|
||||
$gateways = $this->company->company_gateways->whereIn('id', $settings->payment_gateways);
|
||||
else
|
||||
$gateways = $this->company->company_gateways;
|
||||
|
||||
|
@ -173,7 +173,6 @@ class CompanyGateway extends BaseModel
|
||||
if ($this->fee_tax_rate1)
|
||||
$fee += $pre_tax_fee * $this->fee_tax_rate1 / 100;
|
||||
|
||||
|
||||
if ($this->fee_tax_rate2)
|
||||
$fee += $pre_tax_fee * $this->fee_tax_rate2 / 100;
|
||||
|
||||
|
31
app/Utils/Traits/CompanyGatewaySettings.php
Normal file
31
app/Utils/Traits/CompanyGatewaySettings.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits;
|
||||
|
||||
/**
|
||||
* Class CompanyGatewaySettings
|
||||
* @package App\Utils\Traits
|
||||
*/
|
||||
trait CompanyGatewaySettings
|
||||
{
|
||||
|
||||
public function findCompanyGateways()
|
||||
{
|
||||
$settings = $this->getMergedSettings();
|
||||
|
||||
if(isset($settings->groups->company_gateways))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -211,7 +211,7 @@ trait MakesInvoiceValues
|
||||
$data['$company_city'] = $this->company->city;
|
||||
$data['$company_state'] = $this->company->state;
|
||||
$data['$company_postal_code'] = $this->company->postal_code;
|
||||
$data['$company_country'] = $this->company->country->name;
|
||||
$data['$company_country'] = $this->company->country ? $this->company->country->name : '';
|
||||
$data['$company_phone'] = $this->company->work_phone;
|
||||
$data['$company_email'] = $this->company->work_email;
|
||||
$data['$company_vat_number'] = $this->company->vat_number;
|
||||
|
@ -24,7 +24,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c
|
||||
Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index');
|
||||
|
||||
Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index');
|
||||
Route::get('payments/{company_gateway_id}/{payment_method_id}/{}')->name('payments.process')->signed();
|
||||
Route::get('payments/{company_gateway_id}/{payment_method_id}', 'PaymentController@process')->name('payments.process')->middleware('signed');
|
||||
|
||||
Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit');
|
||||
Route::put('profile/{client_contact}/edit', 'ClientPortal\ProfileController@update')->name('profile.update');
|
||||
|
54
tests/Unit/GroupTest.php
Normal file
54
tests/Unit/GroupTest.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\DataMapper\Group
|
||||
*/
|
||||
class GroupTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
|
||||
parent::setUp();
|
||||
|
||||
// $this->settings = new ClientSettings(ClientSettings::defaults());
|
||||
$this->settings = ClientSettings::buildClientSettings(new CompanySettings(CompanySettings::defaults()), new ClientSettings(ClientSettings::defaults()));
|
||||
|
||||
}
|
||||
|
||||
public function testGroupsPropertiesExistsResponses()
|
||||
{
|
||||
//$this->assertEquals(print_r($this->settings));
|
||||
|
||||
$this->assertTrue(property_exists($this->settings->groups, 'company_gateways'));
|
||||
|
||||
$this->assertTrue(property_exists($this->settings, 'groups'));
|
||||
}
|
||||
|
||||
public function testPropertyValueAccessors()
|
||||
{
|
||||
|
||||
$this->settings->groups->company_gateways = 'slug';
|
||||
|
||||
$this->assertEquals('slug', $this->settings->groups->company_gateways);
|
||||
|
||||
}
|
||||
|
||||
public function testPropertyIsSet()
|
||||
{
|
||||
$this->assertFalse(isset($this->settings->groups->company_gateways));
|
||||
|
||||
$this->settings->groups->company_gateways = 'slug';
|
||||
|
||||
$this->assertTrue(isset($this->settings->groups->company_gateways));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user