# |
Jun 10th 2021, 17:45 |
greg138 |
https://book.cakephp.org/3/en/development/testing.html#setting-up-the-request |
# |
Jun 10th 2021, 17:44 |
tyler.adam.lazenby |
Hetting the appropriate header with phpunit? |
# |
Jun 10th 2021, 17:44 |
greg138 |
That's just a matter of setting the appropriate header in your simulated call to `send-email`. |
# |
Jun 10th 2021, 17:44 |
tyler.adam.lazenby |
exactly |
# |
Jun 10th 2021, 17:44 |
kevin.pfeifer |
so you check the url / referrer of that ajax call in your controller function? |
# |
Jun 10th 2021, 17:42 |
tyler.adam.lazenby |
to `/contacts/send-email` |
# |
Jun 10th 2021, 17:42 |
tyler.adam.lazenby |
I just want to simulate for example making a get request from /appname/contacts/view/1 |
# |
Jun 10th 2021, 17:41 |
greg138 |
Simulate which part of it? There's great support for testing controller actions with any method you want and any data you care to pass to them. |
# |
Jun 10th 2021, 17:41 |
kevin.pfeifer |
now i understand |
# |
Jun 10th 2021, 17:41 |
kevin.pfeifer |
ahhhhhh |
# |
Jun 10th 2021, 17:41 |
tyler.adam.lazenby |
sorry just lots of issues and my adhd brain is developing code and asking at the same time |
# |
Jun 10th 2021, 17:40 |
tyler.adam.lazenby |
problem is how do you simulate making the request from a page with unit testing? |
# |
Jun 10th 2021, 17:40 |
greg138 |
If it's something that's going to be invariant, why wouldn't you use a unit test? It confirms your initial code, and also makes sure it keeps working forever. |
# |
Jun 10th 2021, 17:39 |
kevin.pfeifer |
why should that be janky? |
# |
Jun 10th 2021, 17:39 |
kevin.pfeifer |
ok then i totally dont get what youre asking :,) |
# |
Jun 10th 2021, 17:39 |
tyler.adam.lazenby |
Just seems janky |
# |
Jun 10th 2021, 17:38 |
tyler.adam.lazenby |
hahaha yeah yeah I know |
# |
Jun 10th 2021, 17:38 |
kevin.pfeifer |
well you can set a xdebug breakpoint in a test as well if you want :) |
# |
Jun 10th 2021, 17:38 |
tyler.adam.lazenby |
and I use PHPstorm so unit testing is very easy |
# |
Jun 10th 2021, 17:37 |
tyler.adam.lazenby |
because I use a CI |
# |
Jun 10th 2021, 17:37 |
tyler.adam.lazenby |
ok, I get that, but I also am unit testing lol |
# |
Jun 10th 2021, 17:37 |
kevin.pfeifer |
in this case where you probably just return json data and want to check what is in a variable you can also just log the variable with `Log::write()` |
# |
Jun 10th 2021, 17:35 |
tyler.adam.lazenby |
I personally make heavy use of `debug()` and `dd()` |
# |
Jun 10th 2021, 17:34 |
tyler.adam.lazenby |
without having to pass that |
# |
Jun 10th 2021, 17:34 |
tyler.adam.lazenby |
I am basically trying to make an ajax command that will check if the page making the request is contact action called view, and then check to see what the ID of the viewed item is |
# |
Jun 10th 2021, 17:34 |
kevin.pfeifer |
but I know enough people who still prefer/löve `var_dump()` aka `pr()` |
# |
Jun 10th 2021, 17:34 |
tyler.adam.lazenby |
hahaha |
# |
Jun 10th 2021, 17:33 |
kevin.pfeifer |
I basically can't live without xdebug any more :) |
# |
Jun 10th 2021, 17:33 |
tyler.adam.lazenby |
exactly, like if for example I am making sure I am getting the referrer's parsed parameters |
# |
Jun 10th 2021, 17:28 |
kevin.pfeifer |
like when you are first creating the logic for that controller action? |
# |
Jun 10th 2021, 17:26 |
tyler.adam.lazenby |
when you are first going through creating a controller action, and want to make sure you are getting the right information passed, do you use unit testing (as opposed to just echoing it to the screen) or is there a more "standard" approach? |
# |
Jun 10th 2021, 13:52 |
philo.hamel |
see `colType` |
# |
Jun 10th 2021, 13:51 |
philo.hamel |
https://github.com/FriendsOfCake/search/tree/master/docs#like |
# |
Jun 10th 2021, 13:49 |
philo.hamel |
```->like('myfield', [ 'field' => 'myfield', 'colType' => ['myfield' => 'string'], ])``` |
# |
Jun 10th 2021, 13:47 |
philo.hamel |
that was easier in CakePHP 2, at least that's what I'm finding while migrating our application |
# |
Jun 10th 2021, 13:46 |
kevin.pfeifer |
sometimes its not possible to just jam everything into just one search input and you have to add more inputs to allow more precise searching |
# |
Jun 10th 2021, 13:42 |
kevin.pfeifer |
well I would guess you want to do something like that, right? ```'Users.myfield LIKE' => '%test%'``` where Users.myfield is a decimal but your search input is a string |
# |
Jun 10th 2021, 13:40 |
paolo.bragagni |
PS. we are only 3 that use this slack?? :( |
# |
Jun 10th 2021, 13:39 |
paolo.bragagni |
in friendsofcake search plugin which is the best way to manage errors (I mean Cannot convert value of type `string` to a decimal) |
# |
Jun 10th 2021, 13:11 |
kevin.pfeifer |
thanks for that explanation :) |
# |
Jun 10th 2021, 13:10 |
kevin.pfeifer |
i see |