Skip to content

Commit d281c5b

Browse files
6.x
1 parent d94ca2c commit d281c5b

6 files changed

Lines changed: 24 additions & 23 deletions

File tree

.github/workflows/php.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,15 @@ jobs:
5050
strategy:
5151
matrix:
5252
php-version:
53-
- 8.2
5453
- 8.3
5554
- 8.4
55+
- 8.5
5656
laravel-constraint:
57-
- 11.*
5857
- 12.*
58+
- 13.*
5959
dependencies:
6060
- lowest
6161
- highest
62-
exclude:
63-
- laravel-constraint: 12.*
64-
php-version: 8.2
6562
steps:
6663
- name: Set up PHP
6764
uses: shivammathur/setup-php@v2

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
"issues": "https://github.com/laragear/cache-query/issues"
1818
},
1919
"require": {
20-
"php": "^8.2",
21-
"illuminate/cache": "11.*|12.*",
22-
"illuminate/config": "11.*|12.*",
23-
"illuminate/database": "11.*|12.*",
24-
"illuminate/support": "11.*|12.*",
25-
"illuminate/container": "11.*|12.*",
26-
"illuminate/contracts": "11.*|12.*"
20+
"php": "^8.3",
21+
"illuminate/cache": "12.*|13.*",
22+
"illuminate/config": "12.*|13.*",
23+
"illuminate/database": "12.*|13.*",
24+
"illuminate/support": "12.*|13.*",
25+
"illuminate/container": "12.*|13.*",
26+
"illuminate/contracts": "12.*|13.*"
2727
},
2828
"require-dev": {
29-
"orchestra/testbench": "9.*|10.*"
29+
"orchestra/testbench": "10.*|11.*"
3030
},
3131
"autoload": {
3232
"psr-4": {

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
33
<testsuites>
44
<testsuite name="Test Suite">
55
<directory>tests</directory>

src/CacheQueryServiceProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class CacheQueryServiceProvider extends ServiceProvider
2626
{
27-
public const CONFIG = __DIR__.'/../config/cache-query.php';
28-
public const STUBS = __DIR__.'/../.stubs/stubs';
27+
public const string CONFIG = __DIR__.'/../config/cache-query.php';
28+
public const string STUBS = __DIR__.'/../.stubs/stubs';
2929

3030
/**
3131
* Register the service provider.
@@ -95,7 +95,6 @@ protected function macro(): Closure
9595
default => $cache = $ttl
9696
};
9797

98-
// Normalize the TTL argument to a Cache instance.
9998
$this->connection = Proxy::crateNewInstance($this->connection, $cache);
10099

101100
return $this;

src/Proxy.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Support\Str;
1212

1313
use function app;
14+
use function array_filter;
1415
use function array_shift;
1516
use function is_array;
1617
use function max;
@@ -66,7 +67,7 @@ public function getCacheHelperInstance(): Cache
6667
*
6768
* @throws \Psr\SimpleCache\InvalidArgumentException
6869
*/
69-
public function select($query, $bindings = [], $useReadPdo = true): mixed
70+
public function select($query, $bindings = [], $useReadPdo = true, array $fetchUsing = [])
7071
{
7172
// Create the unique hash for the query to avoid any duplicate query.
7273
$this->computedKey = (static::$queryHasher)($this->connection, $query, $bindings);
@@ -159,7 +160,11 @@ protected function retrieveResultsFromCache(string $key): array
159160
return [$key => null, $this->cache->key => null];
160161
}
161162

162-
return $this->repository->getMultiple([$key, $this->cache->key]);
163+
$result = $this->repository->getMultiple(array_filter([$key, $this->cache->key]));
164+
165+
$result[$this->cache->key] ??= null;
166+
167+
return $result;
163168
}
164169

165170
/**

tests/ProxyTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function test_uses_custom_time_to_live(): void
370370
$interval = $now->diffAsCarbonInterval(now());
371371

372372
$repository = $this->mock(Repository::class);
373-
$repository->expects('getMultiple')->with([$hash, ''])->times(4)->andReturn(['' => null, $hash => null]);
373+
$repository->expects('getMultiple')->with([$hash])->times(4)->andReturn(['' => null, $hash => null]);
374374
$repository->allows('getStore')->never();
375375
$repository->expects('put')->with($hash, Mockery::type('array'), null);
376376
$repository->expects('put')->with($hash, Mockery::type('array'), $seconds);
@@ -560,7 +560,7 @@ public function test_uses_custom_store(): void
560560
$repository = $this->mock(Repository::class);
561561
$repository->expects('flexible')->never();
562562
$repository->expects('put')->with($hash, Mockery::type('array'), 60)->once();
563-
$repository->expects('getMultiple')->with([$hash, ''])->times(1)->andReturn(['' => null, $hash => null]);
563+
$repository->expects('getMultiple')->with([$hash])->times(1)->andReturn(['' => null, $hash => null]);
564564

565565
$this->mock('cache')->expects('store')->with('test-store')->andReturn($repository);
566566

@@ -630,7 +630,7 @@ public function test_doesnt_uses_flexible_caching_if_repository_is_not_flexible(
630630
$repository = $this->mock(Repository::class);
631631
$repository->expects('flexible')->never();
632632
$repository->expects('put')->with($hash, Mockery::type('array'), [5, 300])->once();
633-
$repository->expects('getMultiple')->with([$hash, ''])->times(1)->andReturn(['' => null, $hash => null]);
633+
$repository->expects('getMultiple')->with([$hash])->times(1)->andReturn(['' => null, $hash => null]);
634634

635635
$this->mock('cache')->expects('store')->with(null)->andReturn($repository);
636636

@@ -921,7 +921,7 @@ public function test_base_query_uses_cache_callback(): void
921921
$repository = $this->mock(Repository::class);
922922
$repository->expects('flexible')->never();
923923
$repository->expects('put')->with($hash, Mockery::type('array'), [5, 300])->once();
924-
$repository->expects('getMultiple')->with([$hash, ''])->times(1)->andReturn(['' => null, $hash => null]);
924+
$repository->expects('getMultiple')->with([$hash])->times(1)->andReturn(['' => null, $hash => null]);
925925

926926
$this->mock('cache')->expects('store')->with(null)->andReturn($repository);
927927

0 commit comments

Comments
 (0)