From a7b73146dc480f086a9d5d9d74e5ed73045f488f Mon Sep 17 00:00:00 2001 From: Ivaylo Mutafov Date: Wed, 13 Mar 2024 17:42:28 +0200 Subject: [PATCH] v2.12.x: Fixed expiration to be in seconds. (#29) --- .github/workflows/run-tests-l5.yml | 4 +-- .github/workflows/run-tests-l7.yml | 39 ------------------------------ composer.json | 8 +++--- src/Store.php | 2 +- tests/StoreTest.php | 2 +- 5 files changed, 8 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/run-tests-l7.yml diff --git a/.github/workflows/run-tests-l5.yml b/.github/workflows/run-tests-l5.yml index b275b1f..0f01be5 100644 --- a/.github/workflows/run-tests-l5.yml +++ b/.github/workflows/run-tests-l5.yml @@ -2,10 +2,10 @@ name: "Run Tests - Laravel 5" on: push: - branches: [ v2.12, master ] + branches: [ v2.12 ] pull_request: - branches: [ v2.12, master ] + branches: [ v2.12 ] jobs: tests: diff --git a/.github/workflows/run-tests-l7.yml b/.github/workflows/run-tests-l7.yml deleted file mode 100644 index 727b681..0000000 --- a/.github/workflows/run-tests-l7.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "Run Tests - Laravel 7" - -on: - push: - branches: [ v3.x ] - - pull_request: - branches: [ v3.x ] - -jobs: - tests: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php: [7.2, 7.3, 7.4, 8.0] - laravel: [7.*] - include: - - laravel: 7.* - testbench: 5 - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: pdo, sqlite, pdo_sqlite - - - name: Install Dependencies - run: composer install - - - name: Execute tests - run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index e31b34f..0314e86 100644 --- a/composer.json +++ b/composer.json @@ -2,13 +2,13 @@ "name": "1ff/laravel-mongodb-cache", "description": "A mongodb cache driver for laravel", "type": "library", - "version": "3.0.0", + "version": "2.12.5", "require": { - "jenssegers/mongodb": "~3.7", - "illuminate/cache": "^7.0" + "jenssegers/mongodb": "^3.5|^3.6", + "illuminate/cache": "^5.8|^6" }, "require-dev": { - "orchestra/testbench": "^5.0" + "orchestra/testbench": "^3.0|^4.0" }, "license": "MIT", "authors": [ diff --git a/src/Store.php b/src/Store.php index 115e7d3..bf26905 100644 --- a/src/Store.php +++ b/src/Store.php @@ -77,7 +77,7 @@ public function getExpiration($key) $expirationSeconds = $cacheData['expiration']->toDateTime()->getTimestamp(); - return round(($expirationSeconds - time()) / 60); + return round(($expirationSeconds - $this->currentTime())); } /** diff --git a/tests/StoreTest.php b/tests/StoreTest.php index dd40071..502f9d2 100644 --- a/tests/StoreTest.php +++ b/tests/StoreTest.php @@ -140,6 +140,6 @@ public function it_retrieves_an_items_expiration_time_by_given_key() $sut = $this->store->getExpiration('test-key'); // Assert - $this->assertEquals(2880.0, $sut); // 2 days in seconds. + $this->assertEquals(172800, $sut); // 2 days in seconds. } }