2019-03-02 22:44:08 +01:00
|
|
|
<?php
|
2020-09-14 13:11:46 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-09-14 13:11:46 +02:00
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-09-14 13:11:46 +02:00
|
|
|
*/
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2019-03-02 22:44:08 +01:00
|
|
|
namespace Tests\Unit;
|
|
|
|
|
|
|
|
use App\DataMapper\ClientSettings;
|
|
|
|
use App\DataMapper\CompanySettings;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\DataMapper\ClientSettings
|
|
|
|
*/
|
2019-04-24 12:01:40 +02:00
|
|
|
class CompareObjectTest extends TestCase
|
2019-03-02 22:44:08 +01:00
|
|
|
{
|
2024-08-22 08:57:52 +02:00
|
|
|
protected function setUp(): void
|
2019-03-02 22:44:08 +01:00
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
parent::setUp();
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->client_settings = ClientSettings::defaults();
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->company_settings = CompanySettings::defaults();
|
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function buildClientSettings()
|
|
|
|
{
|
|
|
|
foreach ($this->company_settings as $key => $value) {
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! isset($this->client_settings->{$key}) && property_exists($this->company_settings, $key)) {
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->client_settings->{$key} = $this->company_settings->{$key};
|
|
|
|
}
|
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
return $this->client_settings;
|
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testProperties()
|
|
|
|
{
|
|
|
|
$build_client_settings = $this->buildClientSettings();
|
2019-04-24 12:01:40 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->assertEquals($build_client_settings->timezone_id, 1);
|
|
|
|
$this->assertEquals($build_client_settings->language_id, 1);
|
2020-07-21 01:00:59 +02:00
|
|
|
$this->assertEquals($build_client_settings->payment_terms, '');
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2019-04-24 12:01:40 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testDirectClientSettingsBuild()
|
|
|
|
{
|
|
|
|
$settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults());
|
2019-03-02 22:44:08 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->assertEquals($settings->timezone_id, 1);
|
|
|
|
$this->assertEquals($settings->language_id, 1);
|
2020-07-21 01:00:59 +02:00
|
|
|
$this->assertEquals($settings->payment_terms, '');
|
2020-06-11 23:56:25 +02:00
|
|
|
$this->assertFalse($settings->auto_archive_invoice);
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2019-03-02 22:44:08 +01:00
|
|
|
}
|