File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ namespace CodeIgniter \Commands ;
3+
4+ use Config \Services ;
5+ use CodeIgniter \CLI \CommandRunner ;
6+
7+ class BaseCommandTest extends \CIUnitTestCase
8+ {
9+ protected $ logger ;
10+ protected $ runner ;
11+
12+ protected function setUp ()
13+ {
14+ parent ::setUp ();
15+ $ this ->logger = Services::logger ();
16+ $ this ->runner = new CommandRunner ();
17+ }
18+
19+ public function testMagicIssetTrue ()
20+ {
21+ $ command = new \Tests \Support \Commands \AppInfo ($ this ->logger , $ this ->runner );
22+
23+ $ this ->assertTrue (isset ($ command ->group ));
24+ }
25+
26+ public function testMagicIssetFalse ()
27+ {
28+ $ command = new \Tests \Support \Commands \AppInfo ($ this ->logger , $ this ->runner );
29+
30+ $ this ->assertFalse (isset ($ command ->foobar ));
31+ }
32+
33+ public function testMagicGet ()
34+ {
35+ $ command = new \Tests \Support \Commands \AppInfo ($ this ->logger , $ this ->runner );
36+
37+ $ this ->assertEquals ('demo ' , $ command ->group );
38+ }
39+
40+ public function testMagicGetMissing ()
41+ {
42+ $ command = new \Tests \Support \Commands \AppInfo ($ this ->logger , $ this ->runner );
43+
44+ $ this ->assertNull ($ command ->foobar );
45+ }
46+ }
Original file line number Diff line number Diff line change @@ -128,4 +128,40 @@ public function testStoresConnectionTimings()
128128 $ this ->assertGreaterThan ($ start , $ db ->getConnectStart ());
129129 $ this ->assertGreaterThan (0.0 , $ db ->getConnectDuration ());
130130 }
131+
132+ //--------------------------------------------------------------------
133+
134+ public function testMagicIssetTrue ()
135+ {
136+ $ db = new MockConnection ($ this ->options );
137+
138+ $ this ->assertTrue (isset ($ db ->charset ));
139+ }
140+
141+ //--------------------------------------------------------------------
142+
143+ public function testMagicIssetFalse ()
144+ {
145+ $ db = new MockConnection ($ this ->options );
146+
147+ $ this ->assertFalse (isset ($ db ->foobar ));
148+ }
149+
150+ //--------------------------------------------------------------------
151+
152+ public function testMagicGet ()
153+ {
154+ $ db = new MockConnection ($ this ->options );
155+
156+ $ this ->assertEquals ('utf8 ' , $ db ->charset );
157+ }
158+
159+ //--------------------------------------------------------------------
160+
161+ public function testMagicGetMissing ()
162+ {
163+ $ db = new MockConnection ($ this ->options );
164+
165+ $ this ->assertNull ($ db ->foobar );
166+ }
131167}
Original file line number Diff line number Diff line change @@ -78,11 +78,6 @@ public function testKeyCreation()
7878 $ this ->assertEquals (16 , strlen ($ this ->encryption ->createKey (16 )));
7979 }
8080
81- public function testBogusProperty ()
82- {
83- $ this ->assertNull ($ this ->encryption ->bogus );
84- }
85-
8681 // --------------------------------------------------------------------
8782
8883 public function testServiceSuccess ()
@@ -129,4 +124,26 @@ public function testServiceShared()
129124 $ this ->assertEquals ('anything ' , $ encrypter ->key );
130125 }
131126
127+ //--------------------------------------------------------------------
128+
129+ public function testMagicIssetTrue ()
130+ {
131+ $ this ->assertTrue (isset ($ this ->encryption ->digest ));
132+ }
133+
134+ public function testMagicIssetFalse ()
135+ {
136+ $ this ->assertFalse (isset ($ this ->encryption ->bogus ));
137+ }
138+
139+ public function testMagicGet ()
140+ {
141+ $ this ->assertEquals ('SHA512 ' , $ this ->encryption ->digest );
142+ }
143+
144+ public function testMagicGetMissing ()
145+ {
146+ $ this ->assertNull ($ this ->encryption ->bogus );
147+ }
148+
132149}
Original file line number Diff line number Diff line change @@ -200,4 +200,21 @@ public function testGetter()
200200 $ this ->assertNull ($ diff ->nonsense );
201201 }
202202
203+ public function testMagicIssetTrue ()
204+ {
205+ $ current = Time::parse ('March 10, 2017 ' , 'America/Chicago ' );
206+ $ diff = $ current ->difference ('March 18, 2017 ' , 'America/Chicago ' );
207+
208+ $ this ->assertTrue (isset ($ diff ->days ));
209+ $ this ->assertFalse (isset ($ diff ->nonsense ));
210+ }
211+
212+ public function testMagicIssetFalse ()
213+ {
214+ $ current = Time::parse ('March 10, 2017 ' , 'America/Chicago ' );
215+ $ diff = $ current ->difference ('March 18, 2017 ' , 'America/Chicago ' );
216+
217+ $ this ->assertFalse (isset ($ diff ->nonsense ));
218+ }
219+
203220}
Original file line number Diff line number Diff line change @@ -221,6 +221,22 @@ public function testTestNow()
221221
222222 //--------------------------------------------------------------------
223223
224+ public function testMagicIssetTrue ()
225+ {
226+ $ time = Time::parse ('January 1, 2016 ' );
227+
228+ $ this ->assertTrue (isset ($ time ->year ));
229+ }
230+
231+ public function testMagicIssetFalse ()
232+ {
233+ $ time = Time::parse ('January 1, 2016 ' );
234+
235+ $ this ->assertFalse (isset ($ time ->foobar ));
236+ }
237+
238+ //--------------------------------------------------------------------
239+
224240 public function testGetYear ()
225241 {
226242 $ time = Time::parse ('January 1, 2016 ' );
Original file line number Diff line number Diff line change @@ -185,6 +185,26 @@ public function testHasReturnsFalseOnNotFound()
185185 $ this ->assertFalse ($ session ->has ('bar ' ));
186186 }
187187
188+ public function testIssetReturnsTrueOnSuccess ()
189+ {
190+ $ session = $ this ->getInstance ();
191+ $ session ->start ();
192+
193+ $ _SESSION ['foo ' ] = 'bar ' ;
194+
195+ $ this ->assertTrue (isset ($ session ->foo ));
196+ }
197+
198+ public function testIssetReturnsFalseOnNotFound ()
199+ {
200+ $ session = $ this ->getInstance ();
201+ $ session ->start ();
202+
203+ $ _SESSION ['foo ' ] = 'bar ' ;
204+
205+ $ this ->assertFalse (isset ($ session ->bar ));
206+ }
207+
188208 public function testPushNewValueIntoArraySessionValue ()
189209 {
190210 $ session = $ this ->getInstance ();
You can’t perform that action at this time.
0 commit comments