Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<testsuites>
<testsuite name="default">
<directory suffix=".php">./tests/Expect</directory>
<directory suffix=".php">./tests/Regression</directory>
</testsuite>
</testsuites>
<source>
Expand Down
22 changes: 15 additions & 7 deletions src/Expectations/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ function (Closure $next, mixed $date) {
try {
$value = Carbon::make($this->value);
$expected = Carbon::make($date);
} catch (Exception) { // @phpstan-ignore-line
return $next();
}

if ($value === null) {
return $next();
}
if (! $value instanceof Carbon) {
return $next();
}

if (is_string($this->value) && str($this->value)->startsWith('@') && $value->format('Y-m-d H:i:s') === '1970-01-01 00:00:00') {
return $next();
}

if ($expected === null) {
if (! $expected instanceof Carbon) {
return $next();
}

if (is_string($date) && str($date)->startsWith('@') && $value->format('Y-m-d H:i:s') === '1970-01-01 00:00:00') {
return $next();
}
} catch (Exception) { // @phpstan-ignore-line
return $next();
}

Expand Down
1 change: 1 addition & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Tests\TestCase;

uses(TestCase::class)->in('Expect');
uses(TestCase::class)->in('Regression');

/**
* @param callable(Response $response) $setup
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

test('at character in toBe expectation', function () {
expect('@pussyCat')->not->toBe('@littleDog');
});
Loading