-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fixed: "date", "time" and "datetime" fields can be initialized with \DateTime objects #3290
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
Changes from all commits
b9facfc
88ef52d
3b1b570
22c8f80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,4 +401,12 @@ public function testIsPartiallyFilled_returnsTrueIfChoiceAndSecondsEmpty() | |
|
||
$this->assertTrue($form->isPartiallyFilled()); | ||
} | ||
|
||
// Bug fix | ||
public function testInitializeWithDateTime() | ||
{ | ||
// Throws an exception if "data_class" option is not explicitely set | ||
// to null in the type | ||
$this->factory->create('time', new \DateTime()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a test without any assertion would be marked as failing if running PHPUnit in strict mode IIRC There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not too nice, but perhaps ..
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long as we don't use PHPUnit strict mode per default, I don't see the point in overcomplicating the test that way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helmer your way is wrong as it will make it impossible to see why the test really failed (you will hide the error and replace it with an expectation failure) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind to open a thread on the ML? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof True (although majority of tests I've seen throw out "asserting that true is false has failed", and you need to dive into code anyhow) .. let me throw another ugly solution:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bschussek Nah, I don't want to be the evangelist behind this proposition :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helmer the difference here is that getting an exception in this place is an error, not a test failure. So the exception should not be catched. And btw, your snippet is wrong as it will always fail. You could go this way but it should be $this->factory->create('time', new \DateTime());
$this->assertTrue(true); |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
array $options
to method signature (same for before block), for sake of clarity.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.