Log message #4052971

# At Username Text
# Jul 17th 2017, 16:10 stefan I did.
# Jul 17th 2017, 16:10 jeremyharris I believe it does detect hasOne automatically if you follow conventions
# Jul 17th 2017, 16:06 stefan I'm trying to modify bakery and I'm wondering if it's possible to detect `hasOne` relationship automatically? I can't find anything in the source code of the `ModelTask.php`
# Jul 17th 2017, 16:03 cleptric Hi :slightly_smiling_face:
# Jul 17th 2017, 16:02 stefan hello
# Jul 17th 2017, 15:27 jeremyharris only use case is probably tests
# Jul 17th 2017, 15:27 neon1024 lol ;)
# Jul 17th 2017, 15:26 jeremyharris yeah you can clear the cache, but once they’re in there, they’re in there
# Jul 17th 2017, 15:26 neon1024 er `clearDetectorCache`
# Jul 17th 2017, 15:26 neon1024 I thought so too, with deleteDetectorCache(), but it seems not
# Jul 17th 2017, 15:26 jeremyharris I thought there was a way to remove detectors, guess not
# Jul 17th 2017, 15:26 neon1024 Might refactor the tests once I’ve written the code to pass them
# Jul 17th 2017, 15:25 neon1024 But yes, a proper mock is probably in order
# Jul 17th 2017, 15:25 neon1024 I just set the detector to return true for mobile tests and false for not mobile test cases :P
# Jul 17th 2017, 15:23 jeremyharris unless you’re doing integration .. then … env vars I guess :)
# Jul 17th 2017, 15:23 jeremyharris maybe traditional mock is in order ($request->expects($this->any())->method(
# Jul 17th 2017, 15:21 neon1024 Ah well #care
# Jul 17th 2017, 15:19 neon1024 So all subsequent tests are now mobile
# Jul 17th 2017, 15:19 neon1024 Hah! It stays in global state as it’s static
# Jul 17th 2017, 15:16 neon1024 Thanks @jeremyharris just ‘mocking’ the detector works just fine
# Jul 17th 2017, 15:12 jeremyharris we’d be out of the job if whining was all it took :P programmers are expert whiners
# Jul 17th 2017, 15:11 neon1024 Although that would be nice
# Jul 17th 2017, 15:11 neon1024 Ah well, moaning about it won’t make the code write itsself
# Jul 17th 2017, 15:11 neon1024 Lé sigh.
# Jul 17th 2017, 15:10 jeremyharris and then maybe have one other test to test the mobile detect lib if you want
# Jul 17th 2017, 15:10 jeremyharris probably better just to expect it works and add a passing detector for the test
# Jul 17th 2017, 15:10 neon1024 Just a bit annoying as I’m building a data provider method, so shoe-horning all that logic into the array is horrid
# Jul 17th 2017, 15:08 jeremyharris looks like the UA like I thought
# Jul 17th 2017, 15:07 jeremyharris or, again, if you don’t care that the detector works properly (e.g., you trust MobileDetect to do its job), then mock / addDetector
# Jul 17th 2017, 15:06 neon1024 https://github.com/serbanghita/Mobile-Detect/blob/master/tests/BasicsTest.php#L27
# Jul 17th 2017, 15:06 jeremyharris yeah that’s where reading the library comes in :S
# Jul 17th 2017, 15:06 jeremyharris it doesn’t quite work like that because it checks various things, such as env, headers, etc
# Jul 17th 2017, 15:06 neon1024 I mean it’s config takes something from $_ENV, but I have no idea what I’d put in there
# Jul 17th 2017, 15:05 neon1024 I was hoping for `new ServerRequest(['type' => 'mobile']);` or something
# Jul 17th 2017, 15:04 neon1024 I need to unit test my code with a mobile request
# Jul 17th 2017, 15:04 jeremyharris do you want to test that the detector works, or just want to test what your page does if detection passes?
# Jul 17th 2017, 15:03 neon1024 https://github.com/serbanghita/Mobile-Detect/blob/master/namespaced/Detection/MobileDetect.php
# Jul 17th 2017, 15:03 neon1024 O_o
# Jul 17th 2017, 15:02 neon1024 If I knew how it ‘detected’ I could just mock it
# Jul 17th 2017, 15:02 jeremyharris such as setting an env var
# Jul 17th 2017, 15:02 jeremyharris at any rate, I think you can overwrite it by using addDetector again in this case. unless you want to test that the detector works, which in that case you’ll need to inspect how the `\Detection\MobileDetect()` library works (probably sniffs user agent) and set that