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

[ical] Add DateParser #534

Merged
merged 1 commit into from Aug 24, 2019
Merged

[ical] Add DateParser #534

merged 1 commit into from Aug 24, 2019

Conversation

mwjames
Copy link
Contributor

@mwjames mwjames commented Aug 24, 2019

This PR is made in reference to: #

This PR addresses or contains:

  • Isolates the date parsing and moves it into a separate class, adds a unit test, and fixes a copy-paste error DataValueFactoryg::getInstance

This PR includes:

  • Tests (unit/integration)
  • CI build passed

@mwjames mwjames merged commit ba3c732 into master Aug 24, 2019
@mwjames mwjames deleted the ical-dateparser branch August 24, 2019 04:07
@kghbln kghbln added this to the 3.2.0 milestone Aug 24, 2019
DateParser::class,
new DateParser()
);
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this test is better omitted

Copy link
Contributor Author

@mwjames mwjames Aug 24, 2019

Choose a reason for hiding this comment

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

I do test the constructor for a while now and it served me well, it even found some issues in other tests.


$timeValue = $this->getMockBuilder( '\SMWTimeValue' )
->disableOriginalConstructor()
->getMock();
Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure you can use createMock rather than this deprecated form

You can also use SMWTimeValue::class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know but the intent is clearer that constructor is disabled, and we don't count lines so it doesn't really matter.

Copy link
Member

Choose a reason for hiding this comment

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

Eh... both the authors of PHPUnit and me beg to differ

->disableOriginalConstructor()
->getMock();

$timeValue->expects( $this->any() )
Copy link
Member

Choose a reason for hiding this comment

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

SMWTimeValue is a value object right? Then why are you creating a mock? This adds a bunch of hidden coupling (method names as strings, plus their signatures...) which is best avoided if there is no good reason for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SMWTimeValue is a value object right?

Sort of but using an a mock ensures that specific coupling to let's say a Title object, or the Store are not pulled in hereby avoids creating a possible DB connection, especially the Title object is nasty, and by using a mock I'm certain I have an encapsulate object that doesn't create any connection.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, sounds like SMWTimeValue is not a value object then.

* @group semantic-result-formats
*
* @license GNU GPL v2+
* @since 3.1
Copy link
Member

Choose a reason for hiding this comment

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

This class is not package public so this is clutter IMO

Copy link
Contributor Author

@mwjames mwjames Aug 24, 2019

Choose a reason for hiding this comment

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

I'm not a fan of the "no comment" purist approach, so I do think some minimal style block should be retained.

Copy link
Member

Choose a reason for hiding this comment

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

I was talking just about the @SInCE tag

*
* @return string
*/
public function parseDate( TimeValue $dataValue, $isEnd = false ) {
Copy link
Member

Choose a reason for hiding this comment

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

public function parseDate( TimeValue $dataValue, bool $isEnd = false ): string {

Copy link
Contributor Author

@mwjames mwjames Aug 24, 2019

Choose a reason for hiding this comment

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

Doing strict typing, I know you like it but I have not come to terms on how to approach this without creating a piece here and there. Without a clear map of how to transform an entire "package" (it would refer here to the entire ical format and its depending classes) and not just for one class I'm a bit reluctant to just drop it like a breadcrumb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants