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
|
|
|
|
*
|
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-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));
|
|
|
|
}
|
2021-04-05 23:36:20 +02:00
|
|
|
|
|
|
|
public function testStringEquivalence()
|
|
|
|
{
|
|
|
|
$value = (strval(4) != strval(3));
|
|
|
|
|
|
|
|
$this->assertTrue($value);
|
|
|
|
|
|
|
|
$value = (strval(4) != strval(4));
|
|
|
|
|
|
|
|
$this->assertFalse($value);
|
|
|
|
|
|
|
|
$value = (strval('4') != strval(4));
|
|
|
|
$this->assertFalse($value);
|
|
|
|
|
|
|
|
$value = (strval('4') != strval('4'));
|
|
|
|
|
|
|
|
$this->assertFalse($value);
|
|
|
|
|
|
|
|
$value = (strval('4') != strval(3));
|
|
|
|
|
|
|
|
$this->assertTrue($value);
|
|
|
|
|
|
|
|
$value = (strval(4) != strval('3'));
|
|
|
|
|
|
|
|
$this->assertTrue($value);
|
|
|
|
|
|
|
|
$value = (strval('4') != strval('3'));
|
|
|
|
|
|
|
|
$this->assertTrue($value);
|
|
|
|
}
|
2019-02-17 11:34:46 +01:00
|
|
|
}
|