Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Getter for 'from', 'to' event's configuration #68

Merged
merged 15 commits into from
Nov 10, 2023
Merged

Getter for 'from', 'to' event's configuration #68

merged 15 commits into from
Nov 10, 2023

Conversation

lucatacconi
Copy link
Contributor

Q A
Fixed issue #59

Inside the Event class there are several methods that allow you to have details on the individual task such as getId(), getSummaryForDisplay(), getExpression(), etc..

However, by setting the task lifetime with the beetween(), from() or to() methods there is no way to read this configuration from the class.

I added two protected variables that allow saving the from and to information, which will only be used for displaying the information and will not influence the behavior of the Event class in any way. I then added the two methods getFrom() and getTo() to display the information.

src/Event.php Outdated
*
* @var \DateTime|string|null
*/
protected $disply_from = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add display prefix, in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/Event.php Outdated
*
* @var \DateTime|string|null
*/
protected $disply_from = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use union type instead of @var, in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/Event.php Outdated
*
* @return \DateTime|string|null
*/
public function getFrom()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use union type for return, in both cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/Event.php Outdated
*
* @return \DateTime|string|null
*/
public function getTo()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both methods need unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/Event.php Outdated
*
* @var \DateTime|string|null
*/
protected $from = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add union type (protected \DateTime|string|null $from = null;) in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -154,6 +154,35 @@ public function test_cron_life_time(): void
);
}

public function test_cron_life_time_getters(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this test into two tests, one per method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sir :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@PabloKowalczyk
Copy link
Member

@@ -154,6 +154,50 @@ public function test_cron_life_time(): void
);
}

public function test_cron_life_time_get_from(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there :)

  • name test cases like test_get_from and test_get_to
  • test between in other test case
  • use data provider (can be one for both cases) to test string and \DateTime in from/to
  • use camelCase for variables' names
  • use assertSame in cases like self::assertTrue($date_from === $event->getFrom());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test cases renamed.
Test case between introduced.
Variables' name renamed in camelCase.

Do you prefer to have the dataproviders all together at the end of the controls file near the other one or near the functions that use them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer to have the dataproviders all together at the end of the controls file near the other one or near the functions that use them?

End of file, before private methods, please.


public function test_get_to(): void
{
$timezone = new \DateTimeZone('UTC');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like $timezone is not used in any test, should be removed.

@@ -154,6 +154,45 @@ public function test_cron_life_time(): void
);
}

public function test_get_from(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "use data provider (can be one for both cases) to test string and \DateTime in from/to"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In progress.

@lucatacconi
Copy link
Contributor Author

All jobs done

@lucatacconi
Copy link
Contributor Author

Are there any other changes you think are needed?

@PabloKowalczyk PabloKowalczyk added this to the v3.6 milestone Nov 10, 2023
@PabloKowalczyk PabloKowalczyk merged commit 9de26de into crunzphp:3.6 Nov 10, 2023
16 checks passed
@PabloKowalczyk
Copy link
Member

Thanks @lucatacconi

This was referenced Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants