diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml
index 3589913..b2d1c37 100644
--- a/.github/workflows/laravel.yml
+++ b/.github/workflows/laravel.yml
@@ -44,7 +44,7 @@ jobs:
with:
postgresql version: '15'
postgresql db: 'testing'
- postgresql user: 'homestead'
+ postgresql user: 'forge'
postgresql password: 'secret'
- name: Remove Nova on a pull request
@@ -56,7 +56,7 @@ jobs:
- name: Install Dependencies
run: |
- composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_PASSWORD }}"
+ composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}"
composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
- name: Execute Integration and Feature tests via PHPUnit
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..1a75ca5
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,43 @@
+
+
+
+
+ ./tests/Feature
+
+
+ ./tests/Integration
+
+
+ ./tests/Nova
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ./src
+
+
+
diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php
index 5d5fccb..f85a54b 100644
--- a/src/Traits/Caching.php
+++ b/src/Traits/Caching.php
@@ -41,7 +41,7 @@ public function applyScopes()
if ($this->scopesAreApplied) {
return $this;
}
-
+
return parent::applyScopes();
}
@@ -170,7 +170,7 @@ protected function makeCacheKey(
?? Container::getInstance()
->make("db")
->query();
-
+
if (
$this->query
&& method_exists($this->query, "getQuery")
@@ -263,6 +263,10 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance)
protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $relationship = "")
{
+ if (! $this->isCachable()) {
+ return;
+ }
+
[$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);
if (! $cacheCooldown) {
@@ -295,6 +299,11 @@ public function isCachable() : bool
$isCacheDisabled = ! Container::getInstance()
->make("config")
->get("laravel-model-caching.enabled");
+
+ if ($isCacheDisabled) {
+ return false;
+ }
+
$allRelationshipsAreCachable = true;
if (
@@ -311,7 +320,7 @@ public function isCachable() : bool
) {
return $carry;
}
-
+
$relatedModel = $this->model->$related()->getRelated();
if (
@@ -327,7 +336,6 @@ public function isCachable() : bool
}
return $this->isCachable
- && ! $isCacheDisabled
&& $allRelationshipsAreCachable;
}
diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php
index b402ab3..7b70d64 100644
--- a/tests/CreatesApplication.php
+++ b/tests/CreatesApplication.php
@@ -139,18 +139,26 @@ protected function getEnvironmentSetUp($app)
]);
}
- public function appVersionEightAndUp(): bool
+ public function appVersionEightAndNine(): bool
{
- return version_compare(app()->version(), '8.0.0', '>=');
+ return version_compare(app()->version(), '8.0.0', '>=')
+ && version_compare(app()->version(), '10.0.0', '<');
}
public function appVersionFiveBetweenSeven(): bool
{
- return version_compare(app()->version(), '5.6.0', '>=') && version_compare(app()->version(), '8.0.0', '<');
+ return version_compare(app()->version(), '5.6.0', '>=')
+ && version_compare(app()->version(), '8.0.0', '<');
}
public function appVersionOld(): bool
{
- return version_compare(app()->version(), '5.4.0', '>=') && version_compare(app()->version(), '5.6.0', '<');
+ return version_compare(app()->version(), '5.4.0', '>=')
+ && version_compare(app()->version(), '5.6.0', '<');
+ }
+
+ public function appVersionTen(): bool
+ {
+ return version_compare(app()->version(), '10.0.0', '>=');
}
}
diff --git a/tests/Feature/PaginationTest.php b/tests/Feature/PaginationTest.php
index 465ec82..ab8e751 100644
--- a/tests/Feature/PaginationTest.php
+++ b/tests/Feature/PaginationTest.php
@@ -7,8 +7,14 @@ class PaginationTest extends FeatureTestCase
{
public function testPaginationProvidesDifferentLinksOnDifferentPages()
{
+ // Checking the version start with 10.0.
+ if ($this->appVersionTen()) {
+ $page1ActiveLink = '1';
+ $page2ActiveLink = '2';
+ }
+
// Checking the version start with 8.0.
- if ($this->appVersionEightAndUp()) {
+ if ($this->appVersionEightAndNine()) {
$page1ActiveLink = '1';
$page2ActiveLink = '2';
}
@@ -39,8 +45,14 @@ public function testPaginationProvidesDifferentLinksOnDifferentPages()
public function testAdvancedPagination()
{
+ // Checking the version start with 10.0.
+ if ($this->appVersionTen()) {
+ $page1ActiveLink = '1';
+ $page2ActiveLink = '2';
+ }
+
// Checking the version start with 8.0.
- if ($this->appVersionEightAndUp()) {
+ if ($this->appVersionEightAndNine()) {
$page1ActiveLink = '1';
$page2ActiveLink = '2';
}
@@ -62,8 +74,14 @@ public function testAdvancedPagination()
public function testCustomPagination()
{
+ // Checking the version start with 10.0.
+ if ($this->appVersionTen()) {
+ $page1ActiveLink = '1';
+ $page2ActiveLink = '2';
+ }
+
// Checking the version start with 8.0.
- if ($this->appVersionEightAndUp()) {
+ if ($this->appVersionEightAndNine()) {
$page1ActiveLink = '1';
$page2ActiveLink = '2';
}
diff --git a/tests/Integration/CachedBuilder/PaginateTest.php b/tests/Integration/CachedBuilder/PaginateTest.php
index 0ac4ead..5d95b3d 100644
--- a/tests/Integration/CachedBuilder/PaginateTest.php
+++ b/tests/Integration/CachedBuilder/PaginateTest.php
@@ -36,7 +36,14 @@ public function testPaginationIsCached()
public function testPaginationReturnsCorrectLinks()
{
- if ($this->appVersionEightAndUp()) {
+ // Checking the version start with 10.0.
+ if ($this->appVersionTen()) {
+ $page1ActiveLink = '1';
+ $page2ActiveLink = '2';
+ $page24ActiveLink = '24';
+ }
+
+ if ($this->appVersionEightAndNine()) {
$page1ActiveLink = '1';
$page2ActiveLink = '2';
$page24ActiveLink = '24';
@@ -71,7 +78,14 @@ public function testPaginationReturnsCorrectLinks()
public function testPaginationWithOptionsReturnsCorrectLinks()
{
- if ($this->appVersionEightAndUp()) {
+ // Checking the version start with 10.0.
+ if ($this->appVersionTen()) {
+ $page1ActiveLink = '1';
+ $page2ActiveLink = '2';
+ $page24ActiveLink = '24';
+ }
+
+ if ($this->appVersionEightAndNine()) {
$page1ActiveLink = '1';
$page2ActiveLink = '2';
$page24ActiveLink = '24';
@@ -106,7 +120,14 @@ public function testPaginationWithOptionsReturnsCorrectLinks()
public function testPaginationWithCustomOptionsReturnsCorrectLinks()
{
- if ($this->appVersionEightAndUp()) {
+ // Checking the version start with 10.0.
+ if ($this->appVersionTen()) {
+ $page1ActiveLink = '1';
+ $page2ActiveLink = '2';
+ $page24ActiveLink = '24';
+ }
+
+ if ($this->appVersionEightAndNine()) {
$page1ActiveLink = '1';
$page2ActiveLink = '2';
$page24ActiveLink = '24';