Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature: Betterify Tests #457

Merged
merged 1 commit into from
May 5, 2022

Conversation

mansoorkhan96
Copy link
Contributor

@mansoorkhan96 mansoorkhan96 commented May 5, 2022

Hi👋
This PR improves some tests by replacing expectations on hardcoded dates with Carbon instances.

Example
From this:

Carbon::setTestNow(Carbon::create(2016, 1, 1));

$period = Period::days(10);

expect($period->startDate->format('Y-m-d'))->toBe('2015-12-22');
expect($period->endDate->format('Y-m-d'))->toBe('2016-01-01');

To This:

$expectedDate = Carbon::create(2016, 1, 1);
Carbon::setTestNow($expectedDate);

$period = Period::days(10);

expect($period)
    ->endDate->toEqual($expectedDate)
    ->startDate->toEqual($expectedDate->subDays(10));

Plus, also refactors to possibly use higher-order expectations.

@freekmurze freekmurze merged commit c89c3ae into spatie:main May 5, 2022
@freekmurze
Copy link
Member

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants