Skip to content

Commit

Permalink
Support Carbon v3 (#5)
Browse files Browse the repository at this point in the history
* add carbon verion 3 to composer.json

* cast CarbonInterval to integer

since v3 uses floats for the total* properties
  • Loading branch information
matthewpaulking committed Mar 25, 2024
1 parent 3b276cd commit c411f92
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"illuminate/support": "^9|^10|^11|12.x-dev|dev-master",
"illuminate/contracts": "^9|^10|^11|12.x-dev|dev-master",
"ext-json": "*",
"nesbot/carbon": "^2.62.1"
"nesbot/carbon": "^2.62.1|^3.0"
},
"require-dev": {
"orchestra/testbench": "^7.10|^8|^9|9.x-dev|10.x-dev|dev-master",
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CustomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function test_it_waits_for_valid_sequence_when_limit_is_reached(): void

$this->assertEquals(0, $first_after_second_sleep->values[2]);

Sleep::assertSlept(fn(CarbonInterval $interval) => $interval->totalMicroseconds === 1, 2);
Sleep::assertSlept(fn(CarbonInterval $interval) => (int) $interval->totalMicroseconds === 1, 2);
}

public function test_custom_bits_can_be_coerced_to_snowflakes_or_sonyflakes(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/SnowflakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function test_it_sleeps_1ms_when_sequence_limit_is_reached(): void

Snowflake::make();

Sleep::assertSlept(fn(CarbonInterval $interval) => $interval->totalMicroseconds === 1000);
Sleep::assertSlept(fn(CarbonInterval $interval) => (int) $interval->totalMicroseconds === 1000);
}

public function test_a_snowflake_can_be_created_for_a_specific_timestamp(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/SonyflakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function test_it_sleeps_10ms_when_sequence_limit_is_reached(): void

Sonyflake::make();

Sleep::assertSlept(fn(CarbonInterval $interval) => $interval->totalMicroseconds === 10000);
Sleep::assertSlept(fn(CarbonInterval $interval) => (int) $interval->totalMicroseconds === 10000);
}

public function test_a_snowflake_can_be_created_for_a_specific_timestamp(): void
Expand Down

0 comments on commit c411f92

Please sign in to comment.