File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -203,17 +203,14 @@ protected function hasByKey($key)
203
203
{
204
204
if (strpos ($ key , '. ' ) !== false ) {
205
205
$ setting = $ this ->getSubValue ($ key );
206
-
207
- return (empty ($ setting )) ? false : true ;
208
206
} else {
209
207
if ($ this ->cache ->has ($ key .'@ ' .$ this ->lang )) {
210
208
$ setting = $ this ->cache ->get ($ key .'@ ' .$ this ->lang );
211
209
} else {
212
210
$ setting = $ this ->storage ->retrieve ($ key , $ this ->lang );
213
211
}
214
-
215
- return (empty ($ setting )) ? false : true ;
216
212
}
213
+ return ($ setting === null ) ? false : true ;
217
214
}
218
215
219
216
protected function forgetByKey ($ key )
Original file line number Diff line number Diff line change @@ -140,6 +140,29 @@ protected function setMock()
140
140
Schema::swap (Manager::Schema ());
141
141
}
142
142
143
+ public function testNullValue ()
144
+ {
145
+ $ cache = m::mock (CacheContract::class);
146
+ $ cache ->shouldReceive ('has ' )->andReturn (false );
147
+ $ cache ->shouldReceive ('add ' )->andReturn (true );
148
+
149
+ $ setting = new Setting (new EloquentStorage (), $ cache );
150
+ $ setting ->set ('a ' , null );
151
+ $ this ->assertTrue ($ setting ->get ('a ' ) === null );
152
+ $ this ->assertTrue ($ setting ->get ('b ' ) === null );
153
+
154
+ $ setting ->set ('foo.bar ' , null );
155
+ $ this ->assertTrue ($ setting ->get ('foo.bar ' ) === null );
156
+
157
+ $ this ->assertTrue ($ setting ->get ('foo.xxx ' ) === null );
158
+
159
+ $ setting ->set ('foo.zzz ' , 0 );
160
+ $ this ->assertTrue ($ setting ->get ('foo.zzz ' ) === 0 );
161
+
162
+ $ setting ->set ('foo.yyy ' , []);
163
+ $ this ->assertTrue ($ setting ->get ('foo.yyy ' ) === []);
164
+ }
165
+
143
166
protected function migrationUp ()
144
167
{
145
168
(new CreateSettingsTable ())->up ();
You can’t perform that action at this time.
0 commit comments