Skip to content

Commit c903ba5

Browse files
authored
Merge pull request #132 from defstudio/fix-#131
fix #131
2 parents 6e5c5fd + c9ffe06 commit c903ba5

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<testsuites>
44
<testsuite name="default">
55
<directory suffix=".php">./tests/Expect</directory>
6+
<directory suffix=".php">./tests/Regression</directory>
67
</testsuite>
78
</testsuites>
89
<source>

src/Expectations/Time.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ function (Closure $next, mixed $date) {
1616
try {
1717
$value = Carbon::make($this->value);
1818
$expected = Carbon::make($date);
19-
} catch (Exception) { // @phpstan-ignore-line
20-
return $next();
21-
}
2219

23-
if ($value === null) {
24-
return $next();
25-
}
20+
if (! $value instanceof Carbon) {
21+
return $next();
22+
}
23+
24+
if (is_string($this->value) && str($this->value)->startsWith('@') && $value->format('Y-m-d H:i:s') === '1970-01-01 00:00:00') {
25+
return $next();
26+
}
2627

27-
if ($expected === null) {
28+
if (! $expected instanceof Carbon) {
29+
return $next();
30+
}
31+
32+
if (is_string($date) && str($date)->startsWith('@') && $value->format('Y-m-d H:i:s') === '1970-01-01 00:00:00') {
33+
return $next();
34+
}
35+
} catch (Exception) { // @phpstan-ignore-line
2836
return $next();
2937
}
3038

tests/Pest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Tests\TestCase;
66

77
uses(TestCase::class)->in('Expect');
8+
uses(TestCase::class)->in('Regression');
89

910
/**
1011
* @param callable(Response $response) $setup
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
test('at character in toBe expectation', function () {
4+
expect('@pussyCat')->not->toBe('@littleDog');
5+
});

0 commit comments

Comments
 (0)