# |
Apr 17th 2019, 14:40 |
neon1024 |
If you want to unit test your maintenance method you’d just call it with expected output |
# |
Apr 17th 2019, 14:40 |
neon1024 |
Hence just sending a request and asserting the response |
# |
Apr 17th 2019, 14:39 |
neon1024 |
You’ll want an integration test |
# |
Apr 17th 2019, 14:39 |
neon1024 |
Well that’s a unit test |
# |
Apr 17th 2019, 14:39 |
Coddyx |
In my specific case, the isInMaintenance is a private function called in the beforeFilter of the AppController which is extended by the PagesController (what i want to test) |
# |
Apr 17th 2019, 14:39 |
neon1024 |
Then change the setting and asserts in each |
# |
Apr 17th 2019, 14:39 |
neon1024 |
Create those two test-case methods |
# |
Apr 17th 2019, 14:38 |
Coddyx |
How do I test for a isInMaintenance and isNotInMaintenance |
# |
Apr 17th 2019, 14:38 |
Coddyx |
What I didn't get is |
# |
Apr 17th 2019, 14:38 |
neon1024 |
When you upgrade the IntegrationTestCase is replaced with a Trait, so keep an eye out for that |
# |
Apr 17th 2019, 14:38 |
Coddyx |
That is what I understood from the documentation as well |
# |
Apr 17th 2019, 14:37 |
neon1024 |
Or similar |
# |
Apr 17th 2019, 14:37 |
neon1024 |
`$this->get('/'); $this->assertResponseCode(503)` |
# |
Apr 17th 2019, 14:37 |
neon1024 |
I tend to use the IntegrationTestCase for that, set the settings and do a get request |
# |
Apr 17th 2019, 14:36 |
Coddyx |
3.4.14* sorry |
# |
Apr 17th 2019, 14:36 |
Coddyx |
3.4.11 |
# |
Apr 17th 2019, 14:36 |
neon1024 |
What version of Cake are you using? |
# |
Apr 17th 2019, 14:36 |
Coddyx |
How should I approach this kind of test? |
# |
Apr 17th 2019, 14:35 |
Coddyx |
In the PagesController I want to test that I correctly get a 503 if the app is in maintenance |
# |
Apr 17th 2019, 14:35 |
Coddyx |
In my AppController before filter I do a database check to see if the app is in maintenance or not |
# |
Apr 17th 2019, 14:34 |
ricksaccous |
just ask |
# |
Apr 17th 2019, 14:34 |
Coddyx |
Hi, is there anyone available to answer a question cercerning testing a controller? |
# |
Apr 17th 2019, 14:33 |
ricksaccous |
it practically freezes up |
# |
Apr 17th 2019, 14:33 |
ricksaccous |
i have a linux laptop but it's a bit too slow, when i try running PHPStorm on it for instance |
# |
Apr 17th 2019, 14:33 |
ricksaccous |
anyone here develop on slow machines? |
# |
Apr 17th 2019, 14:27 |
neon1024 |
That’d be a question for the core team I’d guess |
# |
Apr 17th 2019, 14:27 |
neon1024 |
At some point perhaps |
# |
Apr 17th 2019, 14:27 |
neon1024 |
It might be deprecated in 4.x though |
# |
Apr 17th 2019, 14:27 |
neon1024 |
I don’t believe so |
# |
Apr 17th 2019, 14:26 |
waspinator |
yeah, that one seemed a bit more straightforward. I thought it was going away with cake 4 though. |
# |
Apr 17th 2019, 14:25 |
neon1024 |
I use the older AuthComponent |
# |
Apr 17th 2019, 14:25 |
waspinator |
what do you use instead? |
# |
Apr 17th 2019, 14:24 |
neon1024 |
Maybe see if there are test cases? |
# |
Apr 17th 2019, 14:23 |
neon1024 |
Not too sure, I haven’t used the plugin in a long while |
# |
Apr 17th 2019, 14:23 |
neon1024 |
Perhaps you didn’t do this? |
# |
Apr 17th 2019, 14:23 |
neon1024 |
> and using the identityDecorator middleware option |
# |
Apr 17th 2019, 14:22 |
waspinator |
again mostly copy-pasted from https://book.cakephp.org/authorization/1.1/en/middleware.html#identity-decorator |
# |
Apr 17th 2019, 14:22 |
waspinator |
I thought I did that. This is my User entity https://gist.github.com/waspinator/646012748f747a59e422f9ed9df62e98 |
# |
Apr 17th 2019, 14:18 |
neon1024 |
PHP Storm should be able to do this for you automatically if you’re using that IDE :slightly_smiling_face: |
# |
Apr 17th 2019, 14:17 |
neon1024 |
Or you did and didn’t implement the interface methods |
# |
Apr 17th 2019, 14:17 |
neon1024 |
`class User extends Entity implements IdentityInterface` |