1
1
<?php
2
2
3
- use Illuminate \Support \Facades \DB ;
4
-
5
- class CacheTest extends PHPUnit_Framework_TestCase {
6
-
7
- protected $ cache ;
8
-
9
- public function setUp ()
10
- {
11
- global $ app ;
12
- $ this ->cache = $ app ['cache ' ];
13
-
14
- User::create (array ('name ' => 'John Doe ' , 'age ' => 35 , 'title ' => 'admin ' ));
15
- User::create (array ('name ' => 'Jane Doe ' , 'age ' => 33 , 'title ' => 'admin ' ));
16
- User::create (array ('name ' => 'Harry Hoe ' , 'age ' => 13 , 'title ' => 'user ' ));
17
- }
3
+ class CacheTest extends TestCase {
18
4
19
5
public function tearDown ()
20
6
{
21
7
User::truncate ();
22
- $ this -> cache -> forget ('db.users ' );
8
+ Cache:: forget ('db.users ' );
23
9
}
24
10
25
11
public function testCache ()
26
12
{
13
+ User::create (array ('name ' => 'John Doe ' , 'age ' => 35 , 'title ' => 'admin ' ));
14
+ User::create (array ('name ' => 'Jane Doe ' , 'age ' => 33 , 'title ' => 'admin ' ));
15
+ User::create (array ('name ' => 'Harry Hoe ' , 'age ' => 13 , 'title ' => 'user ' ));
16
+
27
17
$ users = DB ::collection ('users ' )->where ('age ' , '> ' , 10 )->remember (10 )->get ();
28
18
$ this ->assertEquals (3 , count ($ users ));
29
19
@@ -33,7 +23,7 @@ public function testCache()
33
23
$ users = User::where ('age ' , '> ' , 10 )->remember (10 , 'db.users ' )->get ();
34
24
$ this ->assertEquals (3 , count ($ users ));
35
25
36
- $ users = $ this -> cache -> get ('db.users ' );
26
+ $ users = Cache:: get ('db.users ' );
37
27
$ this ->assertEquals (3 , count ($ users ));
38
28
}
39
29
0 commit comments