2019-02-17 11:34:46 +01:00
|
|
|
<?php
|
2020-09-14 13:11:46 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2019-02-17 11:34:46 +01:00
|
|
|
namespace Tests\Unit;
|
|
|
|
|
|
|
|
use App\DataMapper\CompanySettings;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\DataMapper\CompanySettings
|
|
|
|
*/
|
|
|
|
class CompanySettingsTest extends TestCase
|
|
|
|
{
|
2019-04-24 12:01:40 +02:00
|
|
|
public function setUp() :void
|
2019-02-17 11:34:46 +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->company_settings = CompanySettings::defaults();
|
|
|
|
}
|
2019-02-17 11:34:46 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testTimezoneId()
|
|
|
|
{
|
|
|
|
$this->assertEquals($this->company_settings->timezone_id, 1);
|
|
|
|
}
|
2019-02-17 11:34:46 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testLanguageId()
|
|
|
|
{
|
|
|
|
$this->assertEquals($this->company_settings->language_id, 1);
|
|
|
|
}
|
2019-02-17 11:34:46 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testPropertyIssetOk()
|
|
|
|
{
|
|
|
|
$this->assertTrue(isset($this->company_settings->custom_value1));
|
|
|
|
}
|
2019-10-09 14:21:21 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testPropertyIsSet()
|
|
|
|
{
|
|
|
|
$this->assertTrue(isset($this->company_settings->timezone_id));
|
|
|
|
}
|
2019-10-23 03:01:25 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function testSettingsArrayAgainstCastsArray()
|
|
|
|
{
|
|
|
|
$company_settings = json_decode(json_encode(CompanySettings::defaults()), true);
|
|
|
|
$casts = CompanySettings::$casts;
|
2019-11-06 23:57:09 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$diff = array_diff_key($company_settings, $casts);
|
2019-10-23 03:01:25 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->assertEquals(1, count($diff));
|
|
|
|
}
|
2019-02-17 11:34:46 +01:00
|
|
|
}
|