Skip to content

Commit 23efcee

Browse files
committed
WIP
1 parent 81e6878 commit 23efcee

File tree

13 files changed

+234
-70
lines changed

13 files changed

+234
-70
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/build
12
/vendor
23
composer.lock

.travis.yml

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ language: php
33
matrix:
44
include:
55
- php: 7.1.3
6-
env: ILLUMINATE_VERSION=5.6.* ORCHESTRA_VERSION=3.6.* PHPUNIT_VERSION=^7.0 REDIS_HOST=127.0.0.1
6+
env: PU_FILE=56 REDIS_HOST=127.0.0.1
77
- php: 7.1.3
8-
env: ILLUMINATE_VERSION=5.5.* ORCHESTRA_VERSION=3.5.* PHPUNIT_VERSION=~6.0 REDIS_HOST=127.0.0.1
8+
env: PU_FILE=55 REDIS_HOST=127.0.0.1
99
- php: 7.1.3
10-
env: ILLUMINATE_VERSION=5.4.* ORCHESTRA_VERSION=3.4.* PHPUNIT_VERSION=~5.7 REDIS_HOST=127.0.0.1
10+
env: PU_FILE=54 REDIS_HOST=127.0.0.1
1111
- php: 7.2
12-
env: ILLUMINATE_VERSION=5.6.* ORCHESTRA_VERSION=3.6.* PHPUNIT_VERSION=^7.0 REDIS_HOST=127.0.0.1
12+
env: PU_FILE=56 REDIS_HOST=127.0.0.1
1313
- php: 7.2
14-
env: ILLUMINATE_VERSION=5.5.* ORCHESTRA_VERSION=3.5.* PHPUNIT_VERSION=~6.0 REDIS_HOST=127.0.0.1
14+
env: PU_FILE=55 REDIS_HOST=127.0.0.1
1515
- php: 7.2
16-
env: ILLUMINATE_VERSION=5.4.* ORCHESTRA_VERSION=3.4.* PHPUNIT_VERSION=~5.7 REDIS_HOST=127.0.0.1
16+
env: PU_FILE=54 REDIS_HOST=127.0.0.1
1717

1818
services:
1919
- redis-server
@@ -23,26 +23,7 @@ before_script:
2323
- travis_retry composer install --no-interaction --prefer-source
2424

2525
script:
26-
- mkdir -p ./build/logs
27-
- ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml
28-
29-
before_install:
30-
- sed '/ printerClass="Codedungeon\\PHPUnitPrettyResultPrinter\\Printer"/d' phpunit.xml > new-phpunit.xml
31-
- rm phpunit.xml
32-
- mv new-phpunit.xml phpunit.xml
33-
- composer remove codedungeon/phpunit-result-printer --no-update
34-
- composer require "orchestra/database:${ORCHESTRA_VERSION}" --no-update --dev
35-
- composer require "orchestra/testbench:${ORCHESTRA_VERSION}" --no-update --dev
36-
- composer require "orchestra/testbench-browser-kit:${ORCHESTRA_VERSION}" --no-update --dev
37-
- composer require "illuminate/cache:${ILLUMINATE_VERSION}" --no-update
38-
- composer require "illuminate/config:${ILLUMINATE_VERSION}" --no-update
39-
- composer require "illuminate/console:${ILLUMINATE_VERSION}" --no-update
40-
- composer require "illuminate/database:${ILLUMINATE_VERSION}" --no-update
41-
- composer require "illuminate/support:${ILLUMINATE_VERSION}" --no-update
42-
- composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --no-update --dev
43-
44-
install:
45-
- composer update --prefer-source --no-interaction
26+
- phpunit-${PU_FILE}.sh
4627

4728
after_success:
4829
- travis_retry php vendor/bin/php-coveralls -v

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@
1010
],
1111
"require": {
1212
"fico7489/laravel-pivot": "*",
13-
"illuminate/cache": "5.5 - 5.6",
14-
"illuminate/config": "5.5 - 5.6",
15-
"illuminate/console": "5.5 - 5.6",
16-
"illuminate/database": "5.5 - 5.6",
17-
"illuminate/support": "5.5 - 5.6",
13+
"illuminate/cache": "5.6.*",
14+
"illuminate/config": "5.6.*",
15+
"illuminate/console": "5.6.*",
16+
"illuminate/database": "5.6.*",
17+
"illuminate/support": "5.6.*",
1818
"php": ">=7.1.3"
1919
},
2020
"require-dev": {
21-
"codedungeon/phpunit-result-printer": "*",
2221
"fzaninotto/faker": "*",
2322
"mockery/mockery": "*",
24-
"orchestra/database": "^3.6",
25-
"orchestra/testbench": "^3.6",
26-
"orchestra/testbench-browser-kit": "^3.6",
23+
"orchestra/database": "3.6.*",
24+
"orchestra/testbench": "3.6.*",
25+
"orchestra/testbench-browser-kit": "3.6.*",
2726
"php-coveralls/php-coveralls" : "*",
2827
"phpmd/phpmd": "*",
29-
"phpunit/phpunit": "*",
28+
"phpunit/phpunit": "7.*",
3029
"sebastian/phpcpd": "*",
3130
"symfony/thanks": "*",
32-
"predis/predis": "*"
31+
"predis/predis": "*",
32+
"codedungeon/phpunit-result-printer": "^0.19.10"
3333
},
3434
"autoload": {
3535
"psr-4": {

phpunit-54.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
syntaxCheck="false"
13+
>
14+
<testsuites>
15+
<testsuite name="Feature">
16+
<directory suffix="Test.php">./tests/Feature</directory>
17+
</testsuite>
18+
<testsuite name="Integration">
19+
<directory suffix="Test.php">./tests/Integration</directory>
20+
</testsuite>
21+
</testsuites>
22+
<filter>
23+
<whitelist processUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">./src</directory>
25+
</whitelist>
26+
</filter>
27+
<php>
28+
<env name="APP_KEY" value="base64:Xgs1LQt1GdVHhD6qyYCXnyq61DE3UKqJ5k2SJc+Nw2g="/>
29+
<env name="APP_ENV" value="testing"/>
30+
<env name="APP_URL" value="http://localhost"/>
31+
<env name="CACHE_DRIVER" value="redis"/>
32+
<env name="SESSION_DRIVER" value="array"/>
33+
<env name="QUEUE_DRIVER" value="sync"/>
34+
<env name="DB_CONNECTION" value="testing"/>
35+
</php>
36+
</phpunit>

phpunit-55.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
syntaxCheck="false"
13+
>
14+
<testsuites>
15+
<testsuite name="Feature">
16+
<directory suffix="Test.php">./tests/Feature</directory>
17+
</testsuite>
18+
<testsuite name="Integration">
19+
<directory suffix="Test.php">./tests/Integration</directory>
20+
</testsuite>
21+
</testsuites>
22+
<filter>
23+
<whitelist processUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">./src</directory>
25+
</whitelist>
26+
</filter>
27+
<php>
28+
<env name="APP_KEY" value="base64:Xgs1LQt1GdVHhD6qyYCXnyq61DE3UKqJ5k2SJc+Nw2g="/>
29+
<env name="APP_ENV" value="testing"/>
30+
<env name="APP_URL" value="http://localhost"/>
31+
<env name="CACHE_DRIVER" value="redis"/>
32+
<env name="SESSION_DRIVER" value="array"/>
33+
<env name="QUEUE_DRIVER" value="sync"/>
34+
<env name="DB_CONNECTION" value="testing"/>
35+
</php>
36+
</phpunit>

phpunit-56.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
syntaxCheck="false"
13+
>
14+
<testsuites>
15+
<testsuite name="Feature">
16+
<directory suffix="Test.php">./tests/Feature</directory>
17+
</testsuite>
18+
<testsuite name="Integration">
19+
<directory suffix="Test.php">./tests/Integration</directory>
20+
</testsuite>
21+
</testsuites>
22+
<filter>
23+
<whitelist processUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">./src</directory>
25+
</whitelist>
26+
</filter>
27+
<php>
28+
<env name="APP_KEY" value="base64:Xgs1LQt1GdVHhD6qyYCXnyq61DE3UKqJ5k2SJc+Nw2g="/>
29+
<env name="APP_ENV" value="testing"/>
30+
<env name="APP_URL" value="http://localhost"/>
31+
<env name="CACHE_DRIVER" value="redis"/>
32+
<env name="SESSION_DRIVER" value="array"/>
33+
<env name="QUEUE_DRIVER" value="sync"/>
34+
<env name="DB_CONNECTION" value="testing"/>
35+
</php>
36+
</phpunit>

pu-54.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sed '/ printerClass="Codedungeon\\PHPUnitPrettyResultPrinter\\Printer"/d' phpunit.xml > phpunit-54.xml
2+
composer remove codedungeon/phpunit-result-printer --no-update --dev
3+
composer require "orchestra/database:3.4.*" --no-update --dev
4+
composer require "orchestra/testbench:3.4.*" --no-update --dev
5+
composer require "orchestra/testbench-browser-kit:3.4.*" --no-update --dev
6+
composer require "illuminate/cache:5.4.*" --no-update
7+
composer require "illuminate/config:5.4.*" --no-update
8+
composer require "illuminate/console:5.4.*" --no-update
9+
composer require "illuminate/database:5.4.*" --no-update
10+
composer require "illuminate/support:5.4.*" --no-update
11+
composer require "phpunit/phpunit:5.7.*" --no-update --dev
12+
composer update --prefer-source --no-interaction
13+
14+
mkdir -p ./build/logs
15+
vendor/bin/phpunit --configuration phpunit-54.xml --coverage-text --coverage-clover ./build/logs/clover.xml

pu-55.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sed '/ printerClass="Codedungeon\\PHPUnitPrettyResultPrinter\\Printer"/d' phpunit.xml > phpunit-55.xml
2+
composer remove codedungeon/phpunit-result-printer --no-update --dev
3+
composer require "orchestra/database:3.5.*" --no-update --dev
4+
composer require "orchestra/testbench:3.5.*" --no-update --dev
5+
composer require "orchestra/testbench-browser-kit:3.5.*" --no-update --dev
6+
composer require "illuminate/cache:5.5.*" --no-update
7+
composer require "illuminate/config:5.5.*" --no-update
8+
composer require "illuminate/console:5.5.*" --no-update
9+
composer require "illuminate/database:5.5.*" --no-update
10+
composer require "illuminate/support:5.5.*" --no-update
11+
composer require "phpunit/phpunit:6.*" --no-update --dev
12+
composer update --prefer-source --no-interaction
13+
14+
mkdir -p ./build/logs
15+
vendor/bin/phpunit --configuration phpunit-55.xml --coverage-text --coverage-clover ./build/logs/clover.xml

pu-56.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
composer require codedungeon/phpunit-result-printer --no-update --dev
2+
composer require "orchestra/database:3.6.*" --no-update --dev
3+
composer require "orchestra/testbench:3.6.*" --no-update --dev
4+
composer require "orchestra/testbench-browser-kit:3.6.*" --no-update --dev
5+
composer require "illuminate/cache:5.6.*" --no-update
6+
composer require "illuminate/config:5.6.*" --no-update
7+
composer require "illuminate/console:5.6.*" --no-update
8+
composer require "illuminate/database:5.6.*" --no-update
9+
composer require "illuminate/support:5.6.*" --no-update
10+
composer require "phpunit/phpunit:7.*" --no-update --dev
11+
composer update --prefer-source --no-interaction
12+
13+
mkdir -p ./build/logs
14+
vendor/bin/phpunit --configuration phpunit.xml --coverage-text --coverage-clover ./build/logs/clover.xml

src/Traits/Caching.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace GeneaLabs\LaravelModelCaching\Traits;
22

3+
use Carbon\Carbon;
34
use GeneaLabs\LaravelModelCaching\CacheKey;
45
use GeneaLabs\LaravelModelCaching\CacheTags;
56
use Illuminate\Cache\TaggableStore;
@@ -49,7 +50,7 @@ public function flushCache(array $tags = [])
4950

5051
$this->cache()
5152
->rememberForever($cacheKey, function () {
52-
return now();
53+
return (new Carbon)->now();
5354
});
5455
}
5556
}
@@ -128,7 +129,7 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance)
128129
[$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance);
129130

130131
if (! $cacheCooldown
131-
|| now()->diffInSeconds($invalidatedAt) < $cacheCooldown
132+
|| (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown
132133
) {
133134
return;
134135
}
@@ -160,7 +161,7 @@ protected function checkCooldownAndFlushAfterPersiting(Model $instance)
160161

161162
$this->setCacheCooldownSavedAtTimestamp($instance);
162163

163-
if (now()->diffInSeconds($invalidatedAt) >= $cacheCooldown) {
164+
if ((new Carbon)->now()->diffInSeconds($invalidatedAt) >= $cacheCooldown) {
164165
$instance->flushCache();
165166
}
166167
}
@@ -179,7 +180,7 @@ protected function setCacheCooldownSavedAtTimestamp(Model $instance)
179180

180181
$instance->cache()
181182
->rememberForever($cacheKey, function () {
182-
return now();
183+
return (new Carbon)->now();
183184
});
184185
}
185186
}

src/Traits/ModelCaching.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace GeneaLabs\LaravelModelCaching\Traits;
22

3+
use Carbon\Carbon;
34
use GeneaLabs\LaravelModelCaching\CachedBuilder;
45
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
56

@@ -90,7 +91,7 @@ public function scopeWithCacheCooldownSeconds(
9091
$cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at";
9192
$this->cache()
9293
->rememberForever($cacheKey, function () {
93-
return now();
94+
return (new Carbon)->now();
9495
});
9596

9697
return $query;

0 commit comments

Comments
 (0)