-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Default Settings
- Loading branch information
Showing
8 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ class FieldSettingsManagerTest extends TestCase | |
'email' => "[email protected]", | ||
], | ||
]; | ||
/** @var array */ | ||
protected $defaultSettingsTestArray = [ | ||
'project' => 'Main Project', | ||
]; | ||
|
||
public function setUp(): void | ||
{ | ||
|
@@ -31,13 +35,25 @@ public function testInit() | |
} | ||
|
||
/** | ||
* @throws \Exception | ||
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException | ||
*/ | ||
public function testAll() | ||
{ | ||
$this->assertEquals($this->model->settings()->all(), []); | ||
} | ||
|
||
/** | ||
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException | ||
*/ | ||
public function testDefaultValue() | ||
{ | ||
$this->model->defaultSettings = $this->defaultSettingsTestArray; | ||
$this->assertEquals($this->defaultSettingsTestArray, $this->model->settings()->all()); | ||
|
||
$this->model->settings()->apply($this->testArray); | ||
$this->assertEquals($this->model->settings()->all(), array_merge($this->defaultSettingsTestArray, $this->testArray)); | ||
} | ||
|
||
/** | ||
* @expectedException \Glorand\Model\Settings\Exceptions\ModelSettingsException | ||
* @expectedExceptionMessage Unknown field | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,16 @@ | |
namespace Glorand\Model\Settings\Tests; | ||
|
||
use Glorand\Model\Settings\Models\ModelSettings; | ||
use Glorand\Model\Settings\Tests\Models\UsersWithDefaultSettingsTable; | ||
use Glorand\Model\Settings\Tests\Models\UsersWithTable as User; | ||
use Glorand\Model\Settings\Traits\HasSettingsTable; | ||
use Illuminate\Database\Eloquent\Relations\MorphOne; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class TableSettingsManagerTest extends TestCase | ||
{ | ||
/** @var \Glorand\Model\Settings\Tests\Models\UsersWithTable */ | ||
private $model; | ||
/** @var array */ | ||
protected $testArray = [ | ||
'user' => [ | ||
|
@@ -18,8 +21,10 @@ class TableSettingsManagerTest extends TestCase | |
'email' => "[email protected]", | ||
], | ||
]; | ||
/** @var \Glorand\Model\Settings\Tests\Models\UsersWithTable */ | ||
private $model; | ||
/** @var array */ | ||
protected $defaultSettingsTestArray = [ | ||
'project' => 'Main Project', | ||
]; | ||
|
||
public function setUp(): void | ||
{ | ||
|
@@ -41,6 +46,18 @@ public function testAll() | |
$this->assertEquals($this->model->settings()->all(), []); | ||
} | ||
|
||
/** | ||
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException | ||
*/ | ||
public function testDefaultValue() | ||
{ | ||
$this->model->defaultSettings = $this->defaultSettingsTestArray; | ||
$this->assertEquals($this->defaultSettingsTestArray, $this->model->settings()->all()); | ||
|
||
$this->model->settings()->apply($this->testArray); | ||
$this->assertEquals($this->model->settings()->all(), array_merge($this->defaultSettingsTestArray, $this->testArray)); | ||
} | ||
|
||
/** | ||
* @throws \Exception | ||
*/ | ||
|