Skip to content

Commit 9c3322a

Browse files
authored
Merge pull request #3 from poldixd/laravel-12-support
Laravel 12 support
2 parents 8947e6c + 616be20 commit 9c3322a

File tree

11 files changed

+30
-30
lines changed

11 files changed

+30
-30
lines changed

.github/workflows/run-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jobs:
1111
fail-fast: true
1212
matrix:
1313
php: [8.2, 8.3, 8.4]
14-
laravel: [11.*, 10.*]
14+
laravel: [11.*, 12.*]
1515
dependency-version: [prefer-stable]
1616
include:
17+
- laravel: 12.*
18+
testbench: 10.*
1719
- laravel: 11.*
1820
testbench: 9.*
19-
- laravel: 10.*
20-
testbench: 8.*
2121

2222
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2323

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ composer.phar
22
/vendor/
33
composer.lock
44
package-lock.json
5-
.phpunit.result.cache
5+
.phpunit.result.cache
6+
.phpunit.cache

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
All notable changes to `human-readable-time` will be documented in this file
44

5-
## 1.2.0 - 2022-04-03
5+
## 1.3.0 - 2025-05-07
6+
7+
- Added Laravel 12 Support
8+
- Removed Laravel 10 Support
9+
10+
## 1.2.0 - 2025-05-05
611

712
- Added Laravel 11 Support
813
- Removed PHP 8.1 Support

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
],
1010
"require": {
1111
"php": "^8.1",
12-
"illuminate/support": "^10.0|^11.0"
12+
"illuminate/support": "^11.0|^12.0"
1313
},
1414
"require-dev": {
15-
"orchestra/testbench": "^8.0|^9.0",
16-
"pestphp/pest": "^2.0",
17-
"pestphp/pest-plugin-laravel": "^2.0",
18-
"spatie/pest-plugin-snapshots": "^2.0",
19-
"spatie/pest-plugin-test-time": "^2.0"
15+
"orchestra/testbench": "^9.0|^10.0",
16+
"pestphp/pest": "^3.0",
17+
"pestphp/pest-plugin-laravel": "^3.0",
18+
"laravel/pint": "^1.22"
2019
},
2120
"autoload": {
2221
"psr-4": {

src/poldixd/HumanReadableTime/Components/HumanReadableTime.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
namespace poldixd\HumanReadableTime\Components;
44

5-
use Illuminate\View\Component;
65
use Carbon\Carbon;
76
use DateTime;
7+
use Illuminate\View\Component;
88

99
class HumanReadableTime extends Component
1010
{
1111
public Carbon $datetime;
12+
1213
public string $humanUntil;
14+
1315
public string $format;
16+
1417
public string $output;
1518

1619
public function __construct(Datetime $datetime, string $humanUntil = '-1 hour', string $format = 'Y-m-d H:i:s')
@@ -24,7 +27,7 @@ public function __construct(Datetime $datetime, string $humanUntil = '-1 hour',
2427
: $datetime->diffForHumans(now());
2528
}
2629

27-
public function render()
30+
public function render(): string
2831
{
2932
return <<<'blade'
3033
<time {{ $attributes->merge(['datetime' => $datetime->toDateTimeString()]) }}>{{ $output }}</time>

src/poldixd/HumanReadableTime/Providers/HumanReadableTimeServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class HumanReadableTimeServiceProvider extends ServiceProvider
1010
{
11-
public function boot()
11+
public function boot(): void
1212
{
1313
Blade::component('human-readable-time', HumanReadableTime::class);
1414
}

tests/__snapshots__/HumanReadableTimeTest__it_can_render_human_readable_time__1.txt renamed to tests/.pest/snapshots/HumanReadableTimeTest/it_can_render_human_readable_time.snap

File renamed without changes.

tests/__snapshots__/HumanReadableTimeTest__it_can_render_time__1.txt renamed to tests/.pest/snapshots/HumanReadableTimeTest/it_can_render_time.snap

File renamed without changes.

tests/__snapshots__/HumanReadableTimeTest__it_can_render_time_with_custom_format__1.txt renamed to tests/.pest/snapshots/HumanReadableTimeTest/it_can_render_time_with_custom_format.snap

File renamed without changes.

tests/HumanReadableTimeTest.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
<?php
22

3-
use function Spatie\PestPluginTestTime\testTime;
4-
use function Spatie\Snapshots\assertMatchesSnapshot;
53
use Illuminate\Support\Carbon;
64
use Illuminate\Support\Facades\Blade;
75

86
it('can render human readable time', function () {
9-
testTime()->freeze('2023-01-27 09:27:34');
7+
$this->travelTo('2023-01-27 09:27:34');
108

119
$datetime = Carbon::parse('2023-01-27 09:12:34');
1210

13-
$html = Blade::render('<x:human-readable-time :datetime="$datetime" />', compact('datetime'));
14-
15-
assertMatchesSnapshot($html);
11+
expect(Blade::render('<x:human-readable-time :datetime="$datetime" />', compact('datetime')))->toMatchSnapshot();
1612
});
1713

1814
it('can render time', function () {
19-
testTime()->freeze('2023-01-27 10:13:34');
15+
$this->travelTo('2023-01-27 10:13:34');
2016

2117
$datetime = Carbon::parse('2023-01-27 09:12:34');
2218

23-
$html = Blade::render('<x:human-readable-time :datetime="$datetime" />', compact('datetime'));
24-
25-
assertMatchesSnapshot($html);
19+
expect(Blade::render('<x:human-readable-time :datetime="$datetime" />', compact('datetime')))->toMatchSnapshot();
2620
});
2721

2822
it('can render time with custom format', function () {
2923
$format = 'd.m.Y H:i:s';
3024

31-
testTime()->freeze('2023-01-27 10:13:34');
25+
$this->travelTo('2023-01-27 10:13:34');
3226

3327
$datetime = Carbon::parse('2023-01-27 09:12:34');
3428

35-
$html = Blade::render('<x:human-readable-time :datetime="$datetime" :format="$format" />', compact('datetime', 'format'));
36-
37-
assertMatchesSnapshot($html);
38-
});
29+
expect(Blade::render('<x:human-readable-time :datetime="$datetime" :format="$format" />', compact('datetime', 'format')))->toMatchSnapshot();
30+
});

0 commit comments

Comments
 (0)