Skip to content

Commit

Permalink
1. update test case.
Browse files Browse the repository at this point in the history
2. optimize code.
  • Loading branch information
chenbidepro committed Dec 17, 2018
1 parent fc6e222 commit b28a0c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/Models/SystemSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ public function __construct(array $attributes = [])
*/
public function getValueAttribute($value)
{
if (!is_null($value)) {
return json_decode($value, true);
}

return '';
return json_decode($value, true);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,4 @@ protected function registerMigrations()
{
return $this->loadMigrationsFrom(__DIR__.'/../migrations');
}

/**
* @return array
*/
public function provides()
{
return [SettingInterface::class, 'system_setting'];
}
}
10 changes: 10 additions & 0 deletions tests/SettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* file that was distributed with this source code.
*/

use iBrand\Component\Setting\Repositories\SettingInterface;

/**
* Created by PhpStorm.
* User: Administrator
Expand Down Expand Up @@ -85,7 +87,15 @@ public function testGet()
$setting4 = settings(['key4' => false]);
$this->assertFalse(settings('key4'));

}

public function testHelpers()
{
$result = settings();
$this->assertInstanceOf(SettingInterface::class,$result);

$result = settings(app(SettingInterface::class));
$this->assertEquals('',$result);
}

}

0 comments on commit b28a0c9

Please sign in to comment.