Skip to main content
6 events
when toggle format what by license comment
Mar 15, 2018 at 22:15 history edited 9000 CC BY-SA 3.0
added 804 characters in body
Mar 15, 2018 at 22:10 comment added 9000 @bdsl: If you have an object with a constructor, you can inject data into it. But please note that you'd have to have a parameter to inject to. But your critique does have a merit: instead of passing a clock to a particular function, you can replace the clock in the global context. I'm updating my answer.
Mar 15, 2018 at 21:45 comment added bdsl It's not ideal to pass a parameter in a test that isn't passed in production, since then the code path being tested isn't the same one that runs in production and the test has limited value. I would probably inject an object representing either the current time or a clock into the constructor. If you're using a service container then it should be able to do that injection in production, and you'll pass a fixed value time or a fake clock manually for a unit test. For instance if we accidentally type $now = tiem(); the unit test won't fail, since that line isn't covered.
S Mar 15, 2018 at 21:43 history suggested bdsl CC BY-SA 3.0
fixed php code
Mar 15, 2018 at 21:42 review Suggested edits
S Mar 15, 2018 at 21:43
Mar 15, 2018 at 19:37 history answered 9000 CC BY-SA 3.0