Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
wip
  • Loading branch information
StanBarrows committed Aug 3, 2025
commit 01e60668d4fd7e3c6911b49fb50ea720081161d3
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to `laravel-docuware` will be documented in this file.

## [Unreleased]

### Laravel 12 Compatibility
- Updated cache configuration to use `CACHE_STORE` instead of deprecated `CACHE_DRIVER` for Laravel 12 compatibility
- This ensures DocuWare cache uses the same store as the application, preventing MAC invalid errors when using encrypted cache values
- Maintains backward compatibility with Laravel 9-11 by falling back to `CACHE_DRIVER` if `CACHE_STORE` is not available

## 2.0.0 pre-release
### General
- Dropped support below PHP 8.1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ return [
|
*/

'cache_driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_DRIVER', 'file')),
'cache_driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file'))),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -1765,7 +1765,7 @@ return [
'additional_result_fields' => [],
],
'cache' => [
'driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_DRIVER', 'file')),
'driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file'))),
'lifetime_in_seconds' => env('DOCUWARE_CACHE_LIFETIME_IN_SECONDS', 60),
],
],
Expand Down
5 changes: 3 additions & 2 deletions config/laravel-docuware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
| Cache driver
|--------------------------------------------------------------------------
| You may like to define a different cache driver than the default Laravel cache driver.
| In Laravel 12+, CACHE_STORE is used instead of CACHE_DRIVER.
|
*/

'cache_driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_DRIVER', 'file')),
'cache_driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file'))),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -73,7 +74,7 @@
'additional_result_fields' => [],
],
'cache' => [
'driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_DRIVER', 'file')),
'driver' => env('DOCUWARE_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file'))),
'lifetime_in_seconds' => env('DOCUWARE_CACHE_LIFETIME_IN_SECONDS', 60),
],
'request' => [
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/TextshotPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function fromJson(array $data): self
}

public function __construct(
public string $language,
public ?string $language,
public string $content,
) {}

Expand Down
94 changes: 94 additions & 0 deletions tests/Feature/Laravel12CacheCompatibilityTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

test('cache configuration uses CACHE_STORE in Laravel 12', function () {
// Mock the configuration to simulate Laravel 12 with CACHE_STORE
config([
'laravel-docuware.configurations.cache.driver' => 'redis',
]);

// Test that the configuration is properly loaded
$cacheDriver = config('laravel-docuware.configurations.cache.driver');
expect($cacheDriver)->toBe('redis');
});

test('cache configuration falls back to CACHE_DRIVER when CACHE_STORE is not set', function () {
// Mock the configuration to simulate older Laravel versions
config([
'laravel-docuware.configurations.cache.driver' => 'file',
]);

// Test that the configuration is properly loaded
$cacheDriver = config('laravel-docuware.configurations.cache.driver');
expect($cacheDriver)->toBe('file');
});

test('cache configuration uses DOCUWARE_CACHE_DRIVER when explicitly set', function () {
// Mock the configuration to prioritize DOCUWARE_CACHE_DRIVER
config([
'laravel-docuware.configurations.cache.driver' => 'array',
]);

// Test that the configuration is properly loaded
$cacheDriver = config('laravel-docuware.configurations.cache.driver');
expect($cacheDriver)->toBe('array');
});

test('cache configuration respects the new CACHE_STORE fallback chain', function () {
// Test that the configuration properly uses the new fallback chain:
// DOCUWARE_CACHE_DRIVER -> CACHE_STORE -> CACHE_DRIVER -> 'file'

// Mock the configuration to simulate the fallback chain
config([
'laravel-docuware.configurations.cache.driver' => 'redis', // This would be set by CACHE_STORE
]);

// Test that the configuration is properly loaded
$cacheDriver = config('laravel-docuware.configurations.cache.driver');
expect($cacheDriver)->toBe('redis');
});

test('cache configuration uses default file driver when no configuration is set', function () {
// Reset the configuration to test default behavior
config([
'laravel-docuware.configurations.cache.driver' => 'file',
]);

// Test that the configuration is properly loaded
$cacheDriver = config('laravel-docuware.configurations.cache.driver');
expect($cacheDriver)->toBe('file');
});

test('environment variable fallback chain works correctly', function () {
// Test that the environment variable fallback chain works as expected
// This simulates the actual configuration loading logic

// Mock the environment variables
putenv('DOCUWARE_CACHE_DRIVER=array');
putenv('CACHE_STORE=redis');
putenv('CACHE_DRIVER=file');

// The configuration should prioritize DOCUWARE_CACHE_DRIVER
$expectedDriver = env('DOCUWARE_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file')));
expect($expectedDriver)->toBe('array');

// Clean up
putenv('DOCUWARE_CACHE_DRIVER');
putenv('CACHE_STORE');
putenv('CACHE_DRIVER');
});

test('CACHE_STORE takes precedence over CACHE_DRIVER when DOCUWARE_CACHE_DRIVER is not set', function () {
// Mock the environment variables
putenv('DOCUWARE_CACHE_DRIVER=');
putenv('CACHE_STORE=redis');
putenv('CACHE_DRIVER=file');

// The configuration should use CACHE_STORE when DOCUWARE_CACHE_DRIVER is not set
$expectedDriver = env('DOCUWARE_CACHE_DRIVER', env('CACHE_STORE', env('CACHE_DRIVER', 'file')));
expect($expectedDriver)->toBe('redis');

// Clean up
putenv('DOCUWARE_CACHE_DRIVER');
putenv('CACHE_STORE');
putenv('CACHE_DRIVER');
});