mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
* Clean up Client Show * Working on Show Client menu action * working on client view permissions * Finishing up Client Statement View * Workig on client settings * add mix manifest * css for client settings * Client Settings * Working on Client Settings * Implement StartupCheck and static seeders * Implement cached statics in view composers * Working on client settings * Payment Terms * Working on Payment Terms View Composer * Payment Terms builder * Client Settings * refactor companies table * Refactor for company settings, move settings to json * Set object cast on settings column of Company table * Fixes for refactor of companies and clients table * Test * Client Settings Datamapper * Client Settings * Default client language * Client Settings * Working on client settings options * Client Settings * Settings Json serialization/deserialization handling
62 lines
1.1 KiB
PHP
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))), 4);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|