Skip to content

Commit 3530b50

Browse files
committed
Updated changelog and tests.
1 parent 44f37aa commit 3530b50

File tree

2 files changed

+10
-82
lines changed

2 files changed

+10
-82
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.12.5] - 2022-07-30
8+
### Added
9+
- pivotSynced event listener to flush cache when performing BelongsToMany::sync
10+
11+
[...]
12+
713
## [0.10.3] - 2021-03-16
814
### Changed
915
- The from part of the query ($query->from) instead of the table name of the model ($model->table)

tests/Integration/CachedBuilder/BelongsToManyTest.php

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -182,106 +182,28 @@ public function testInvalidatingCacheWhenSyncing()
182182
$tags = [
183183
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesstore",
184184
];
185-
186185
$newStores = factory(Store::class, 2)
187186
->create();
188-
189187
$result = Book::find($bookId)
190188
->stores;
191189

192190
Book::find($bookId)
193191
->stores()
194192
->attach($newStores[0]->id);
195-
196193
Book::find($bookId)
197194
->stores()
198195
->sync($newStores->pluck('id'));
199-
200-
$this->assertEmpty(array_diff(
201-
Book::find($bookId)->stores()->pluck((new Store)->getTable() . '.id')->toArray(),
202-
$newStores->pluck('id')->toArray()
203-
));
204-
205196
$cachedResult = $this
206197
->cache()
207198
->tags($tags)
208199
->get($key)['value']
209200
?? null;
210201

202+
$this->assertEmpty(array_diff(
203+
Book::find($bookId)->stores()->pluck((new Store)->getTable() . '.id')->toArray(),
204+
$newStores->pluck('id')->toArray()
205+
));
211206
$this->assertNotEmpty($result);
212207
$this->assertNull($cachedResult);
213208
}
214-
215-
// /** @group test */
216-
// public function testUncachedDetachesFromCached()
217-
// {
218-
// // $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:book-store:genealabslaravelmodelcachingcachedbelongstomany-book_store.book_id_=_{$bookId}");
219-
// // $tags = [
220-
// // "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesstore",
221-
// // ];
222-
223-
// $store = (new StoreWithUncachedBooks)
224-
// ->with("books")
225-
// ->has("books")
226-
// ->first();
227-
// $store->books()
228-
// ->detach();
229-
// // $store->delete();
230-
// // dd($results);
231-
// // $cachedResult = $this
232-
// // ->cache()
233-
// // ->tags($tags)
234-
// // ->get($key)['value'];
235-
236-
// // $this->assertNotEmpty($result);
237-
// // $this->assertNull($cachedResult);
238-
// }
239-
240-
// /** @group test */
241-
// public function testCachedDetachesFromUncached()
242-
// {
243-
// // $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:book-store:genealabslaravelmodelcachingcachedbelongstomany-book_store.book_id_=_{$bookId}");
244-
// // $tags = [
245-
// // "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesstore",
246-
// // ];
247-
// $book = (new UncachedBookWithStores)
248-
// ->with("stores")
249-
// ->has("stores")
250-
// ->first();
251-
// $book->stores()
252-
// ->detach();
253-
// // $book->delete();
254-
// // dd($results);
255-
// // $cachedResult = $this
256-
// // ->cache()
257-
// // ->tags($tags)
258-
// // ->get($key)['value'];
259-
260-
// // $this->assertNotEmpty($result);
261-
// // $this->assertNull($cachedResult);
262-
// }
263-
264-
// public function testDetachingFiresEvent()
265-
// {
266-
// // $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:book-store:genealabslaravelmodelcachingcachedbelongstomany-book_store.book_id_=_{$bookId}");
267-
// // $tags = [
268-
// // "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesstore",
269-
// // ];
270-
271-
// $store = (new Store)
272-
// ->with("books")
273-
// ->has("books")
274-
// ->first();
275-
// $store->books()
276-
// ->detach();
277-
// $store->delete();
278-
// // dd($results);
279-
// // $cachedResult = $this
280-
// // ->cache()
281-
// // ->tags($tags)
282-
// // ->get($key)['value'];
283-
284-
// // $this->assertNotEmpty($result);
285-
// // $this->assertNull($cachedResult);
286-
// }
287209
}

0 commit comments

Comments
 (0)