|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use Carbon\Carbon; |
3 | 4 | use ElipZis\Setting\Facades\Setting;
|
4 | 5 | use ElipZis\Setting\Models\Setting as Model;
|
5 | 6 | use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
12 | 13 |
|
13 | 14 | it('has many settings', function () {
|
14 | 15 | $settings = Setting::all();
|
15 |
| - $this->assertNotEmpty($settings); |
16 |
| - $this->assertGreaterThanOrEqual(1, count($settings)); |
17 |
| - |
18 |
| - $this->assertIsString($settings->keys()->first()); |
19 |
| - $this->assertNotNull($settings->first()); |
| 16 | + expect($settings)->isNotEmpty()->toBeGreaterThanOrEqual(1); |
| 17 | + expect($settings->keys()->first())->toBeString(); |
| 18 | + expect($settings->first())->not()->toBeNull(); |
20 | 19 | });
|
21 | 20 |
|
22 |
| -it('can return a setting', function () { |
| 21 | +it('can set and return a setting', function () { |
23 | 22 | $setting = Setting::get('simple.setting');
|
24 |
| - $this->assertNull($setting); |
| 23 | + expect($setting)->toBeNull(); |
25 | 24 |
|
26 | 25 | Setting::set('simple.setting', 1);
|
27 | 26 | $setting = Setting::get('simple.setting');
|
28 |
| - $this->assertNotNull($setting); |
29 |
| - $this->assertEquals(1, $setting->value); |
| 27 | + expect($setting)->not()->toBeNull(); |
| 28 | + expect($setting->value)->toBe(1); |
30 | 29 | });
|
31 | 30 |
|
32 |
| -it('can return a setting value', function () { |
| 31 | +it('can set and return a setting value', function () { |
33 | 32 | $setting = Setting::getValue('simple.setting.value');
|
34 |
| - $this->assertNull($setting); |
| 33 | + expect($setting)->toBeNull(); |
35 | 34 | $setting = Setting::getValue('simple.setting.value', 1);
|
36 |
| - $this->assertEquals(1, $setting); |
| 35 | + expect($setting)->toBe(1); |
37 | 36 |
|
38 | 37 | Setting::set('simple.setting.value', 2);
|
39 | 38 | $setting = Setting::getValue('simple.setting.value');
|
40 |
| - expect($setting)->not()->toBeNull(); |
41 |
| - expect($setting)->toBe(2); |
| 39 | + expect($setting)->not()->toBeNull()->toBe(2); |
| 40 | +}); |
| 41 | + |
| 42 | +it('can set an array and return it', function () { |
| 43 | + Setting::set('simple.setting.array', ['key' => 'value']); |
| 44 | + $setting = Setting::getValue('simple.setting.array'); |
| 45 | + expect($setting)->not()->toBeNull()->toBeArray()->toBe(['key' => 'value']); |
| 46 | +}); |
| 47 | + |
| 48 | +it('can set a date and return it', function () { |
| 49 | + $now = Carbon::now(); |
| 50 | + Setting::set('simple.setting.datetime', $now); |
| 51 | + $setting = Setting::getValue('simple.setting.datetime'); |
| 52 | + expect($setting)->not()->toBeNull()->toBeInstanceOf(Carbon::class); |
| 53 | +}); |
| 54 | + |
| 55 | +it('can set a string and return it', function () { |
| 56 | + Setting::set('simple.setting.string', 'string'); |
| 57 | + $setting = Setting::getValue('simple.setting.string'); |
| 58 | + expect($setting)->not()->toBeNull()->toBeString(); |
42 | 59 | });
|
0 commit comments