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)
203203 {
204204 if (strpos ($ key , '. ' ) !== false ) {
205205 $ setting = $ this ->getSubValue ($ key );
206-
207- return (empty ($ setting )) ? false : true ;
208206 } else {
209207 if ($ this ->cache ->has ($ key .'@ ' .$ this ->lang )) {
210208 $ setting = $ this ->cache ->get ($ key .'@ ' .$ this ->lang );
211209 } else {
212210 $ setting = $ this ->storage ->retrieve ($ key , $ this ->lang );
213211 }
214-
215- return (empty ($ setting )) ? false : true ;
216212 }
213+ return ($ setting === null ) ? false : true ;
217214 }
218215
219216 protected function forgetByKey ($ key )
Original file line number Diff line number Diff line change @@ -140,6 +140,29 @@ protected function setMock()
140140 Schema::swap (Manager::Schema ());
141141 }
142142
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+
143166 protected function migrationUp ()
144167 {
145168 (new CreateSettingsTable ())->up ();
You can’t perform that action at this time.
0 commit comments