@@ -8,13 +8,13 @@ class SoftDeletesTest extends IntegrationTestCase
8
8
{
9
9
public function testWithTrashedIsCached ()
10
10
{
11
- $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.id_=_1-first " );
12
- $ tags = [
13
- "genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor " ,
14
- ];
15
11
$ author = (new UncachedAuthor )
16
12
->first ();
17
13
$ author ->delete ();
14
+ $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-find_1-withTrashed " );
15
+ $ tags = [
16
+ "genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor " ,
17
+ ];
18
18
19
19
$ deletedAuthor = (new Author )
20
20
->withTrashed ()
@@ -31,26 +31,56 @@ public function testWithTrashedIsCached()
31
31
$ this ->assertEquals ($ cachedResults ->toArray (), $ deletedUncachedAuthor ->toArray ());
32
32
}
33
33
34
- // public function testWithoutTrashedIsCached()
35
- // {
36
- // $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor_1-first");
37
- // $tags = [
38
- // "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor",
39
- // ];
40
- // $author = (new UncachedAuthor)
41
- // ->first();
42
- // $author->delete();
43
-
44
- // $deletedAuthor = (new Author)
45
- // ->first($author->id);
46
- // $cachedResults = $this
47
- // ->cache()
48
- // ->tags($tags)
49
- // ->get($key)['value'];
50
- // $deletedUncachedAuthor = (new UncachedAuthor)
51
- // ->first($author->id);
52
-
53
- // $this->assertEquals($cachedResults->toArray(), $deletedAuthor->toArray());
54
- // $this->assertEquals($cachedResults->toArray(), $deletedUncachedAuthor->toArray());
55
- // }
34
+ public function testWithoutTrashedIsCached ()
35
+ {
36
+ $ author = (new UncachedAuthor )
37
+ ->first ();
38
+ $ author ->delete ();
39
+ $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-find_ {$ author ->id }-withoutTrashed " );
40
+ $ tags = [
41
+ "genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor " ,
42
+ ];
43
+
44
+ $ result = (new Author )
45
+ ->withoutTrashed ()
46
+ ->find ($ author ->id );
47
+ $ cachedResult = $ this
48
+ ->cache ()
49
+ ->tags ($ tags )
50
+ ->get ($ key )['value ' ];
51
+ $ uncachedResult = (new UncachedAuthor )
52
+ ->withoutTrashed ()
53
+ ->find ($ author ->id );
54
+
55
+ $ this ->assertEquals ($ uncachedResult , $ result );
56
+ $ this ->assertEquals ($ uncachedResult , $ cachedResult );
57
+ $ this ->assertNull ($ result );
58
+ $ this ->assertNull ($ cachedResult );
59
+ $ this ->assertNull ($ uncachedResult );
60
+ }
61
+
62
+ public function testonlyTrashedIsCached ()
63
+ {
64
+ $ author = (new UncachedAuthor )
65
+ ->first ();
66
+ $ author ->delete ();
67
+ $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_notnull-find_ {$ author ->id }-onlyTrashed " );
68
+ $ tags = [
69
+ "genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor " ,
70
+ ];
71
+
72
+ $ deletedAuthor = (new Author )
73
+ ->onlyTrashed ()
74
+ ->find ($ author ->id );
75
+ $ cachedResults = $ this
76
+ ->cache ()
77
+ ->tags ($ tags )
78
+ ->get ($ key )['value ' ];
79
+ $ deletedUncachedAuthor = (new UncachedAuthor )
80
+ ->onlyTrashed ()
81
+ ->find ($ author ->id );
82
+
83
+ $ this ->assertEquals ($ cachedResults ->toArray (), $ deletedAuthor ->toArray ());
84
+ $ this ->assertEquals ($ cachedResults ->toArray (), $ deletedUncachedAuthor ->toArray ());
85
+ }
56
86
}
0 commit comments