1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/tests/Unit/BaseSettingsTest.php
David Bomba 0d508d67f1
Client Settings (#2711)
* Fixes for travis

* Additional settings variables at the company and client level

* Implement accessor for client settings

* Currency symbol or code setter

* Implement custom JS number and currency formatter

* Implement VueX state management for client settings

* Move settings logic into its own class

* Working on client settings

* client settings

* Move Client Settings helper into PHP

* Move translation helper into its own class

* Working on Client Settings

* fixes for client settings

* Client setting defaults

* fixes for .env

* Fixes for Travis
2019-03-03 08:44:08 +11:00

62 lines
1.1 KiB
PHP

<?php
namespace Tests\Unit;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Tests\TestCase;
/**
* @test
* @covers App\DataMapper\BaseSettings
*/
class BaseSettingsTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->settings = ClientSettings::defaults();
}
public function testPropertyExists()
{
$blank_object = new \stdClass;
$this->assertEquals(count(get_object_vars($this->migrate($blank_object))), 14);
}
public function testPropertyNamesExist()
{
$blank_object = new \stdClass;
$updated_object = $this->migrate($blank_object);
$this->assertTrue(property_exists($updated_object, 'language_id'));
}
public function testPropertyNamesNotExist()
{
$blank_object = new \stdClass;
$updated_object = $this->migrate($blank_object);
$this->assertFalse(property_exists($updated_object, 'non_existent_prop'));
}
public function migrate(\stdClass $object) : \stdClass
{
foreach($this->settings as $property => $value)
{
if(!property_exists($object, $property))
$object->{$property} = NULL;
}
return $object;
}
}