# |
Jul 17th 2017, 16:11 |
jeremyharris |
yes |
# |
Jul 17th 2017, 16:11 |
stefan |
but this is very similar to `hasMany` relationship - isn't that the case? |
# |
Jul 17th 2017, 16:11 |
phantomwatson |
Anyone know how phpunit works with testing php_codesniffer standards? I can't seem to get them to run for cakephp-codesniffer. I clone https://github.com/cakephp/cakephp-codesniffer.git, run `composer install`, then run `vendor/bin/phpunit` and it only runs the tests defined in `vendor/squizlabs/php_codesniffer`. Anyone know how I would get it to run the tests under `CakePHP/Tests`? |
# |
Jul 17th 2017, 16:10 |
jeremyharris |
it might suggest belongsTo first, just say “no” |
# |
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 |