# |
Jun 18th 2019, 11:42 |
peppejaripappalardo |
Hi everyone, I'm new in this comunity, I write just to greet everyone :slightly_smiling_face: |
# |
Jun 18th 2019, 11:40 |
neothermic |
usually that's a sign of a N+1 query :P |
# |
Jun 18th 2019, 11:40 |
neothermic |
but be aware, if the ORM decides to break your SQL out into multiple queries, you'll get the last query the ORM ran, not the last query you think you ran :slightly_smiling_face: |
# |
Jun 18th 2019, 11:39 |
neothermic |
pidlo, if you're in a model, you can do $logs = $this->getDatasource()->getLog(false, false); and then $lastQuery = end($logs['log']); |
# |
Jun 18th 2019, 11:07 |
pidlo |
hello all i have one question in 2.10 version how can i get last sql in this version? |
# |
Jun 18th 2019, 10:56 |
conehead |
Is this useful for anyone? Should this be added to the docs? I personally find it really useful as you can skip other stuff like sending emails or licensing |
# |
Jun 18th 2019, 10:50 |
slackebot1 |
->setMethods(['check']) ->getMock(); $aclComponentMock ->expects($this->any()) ->method('check') ->willReturn(true); $this->_controller->Acl = $aclComponentMock; } ``` |
# |
Jun 18th 2019, 10:50 |
conehead |
``` use \Cake\TestSuite\IntegrationTestTrait { controllerSpy as traitControllerSpy; } /** * Inject Acl-Component to skip all authorization checks * * @param $event * @param null $controller */ public function controllerSpy($event, $controller = null) { $this->traitControllerSpy($event, $controller); $aclComponentMock = $this->getMockBuilder(AclComponent::class) ->disableOriginalConstructor() |
# |
Jun 18th 2019, 10:50 |
conehead |
If anyone else can use this: This works by injecting the component after controller has been generated |
# |
Jun 18th 2019, 10:01 |
conehead |
Well...I can add session data...which does not really help, because I am using ACL. Which would mean I would have to fill couple of hundred of entries in the database first. This would be a solution but a really bad solution imho |
# |
Jun 18th 2019, 10:00 |
challgren |
But you can pass authorization |
# |
Jun 18th 2019, 10:00 |
conehead |
Hm that would suck :P |
# |
Jun 18th 2019, 10:00 |
challgren |
From my understanding it isn’t possible when doing Integration testing |
# |
Jun 18th 2019, 09:59 |
conehead |
Wanna do an Integratration-Test ` use IntegrationTestTrait;` ``` public function testShowIndex() { $this->get('/documents'); $this->assertResponseOk(); } ``` |
# |
Jun 18th 2019, 09:54 |
challgren |
Depends how your testing |
# |
Jun 18th 2019, 09:42 |
conehead |
Or even better, just the method that is called in it |
# |
Jun 18th 2019, 09:41 |
conehead |
Need to disable `isAuthorized` somehow for testing |
# |
Jun 18th 2019, 09:37 |
conehead |
Hm is there an easy way to mock a whole component? |
# |
Jun 18th 2019, 09:37 |
challgren |
I havent messed with that setting in php.ini and from the looks of it. My entire cluster its -1 |
# |
Jun 18th 2019, 09:36 |
martin |
but by default on a linux server it is -1 |
# |
Jun 18th 2019, 09:36 |
martin |
lets move it also to -1 :P |
# |
Jun 18th 2019, 09:36 |
challgren |
theres your problem |
# |
Jun 18th 2019, 09:35 |
martin |
and on my local pc it is 100 |
# |
Jun 18th 2019, 09:35 |
slackebot1 |
<challgren> |
# |
Jun 18th 2019, 09:35 |
martin |
php -i | grep serialize_precision serialize_precision => -1 => -1 |
# |
Jun 18th 2019, 09:35 |
slackebot1 |
<challgren> |
# |
Jun 18th 2019, 09:34 |
martin |
lets check what server has :P |
# |
Jun 18th 2019, 09:34 |
challgren |
Yeah my ini has -1 |
# |
Jun 18th 2019, 09:33 |
martin |
ini_set(‘serialize_precision’, -1); does fix it, but it is strange to do? :P |
# |
Jun 18th 2019, 09:32 |
neon1024 |
No idea then, sorry. Good luck with it :slightly_smiling_face: |
# |
Jun 18th 2019, 09:32 |
neon1024 |
> A formatted version of number. |
# |
Jun 18th 2019, 09:32 |
neon1024 |
Ah I’ve misread this bit |
# |
Jun 18th 2019, 09:32 |
martin |
`number_format ( float $number [, int $decimals = 0 ] ) : string` |
# |
Jun 18th 2019, 09:31 |
neon1024 |
number_format doesn’t return a string :thinking_face: |
# |
Jun 18th 2019, 09:30 |
martin |
I don’t like parsing te float as a string and then calculating with it? |
# |
Jun 18th 2019, 09:29 |
martin |
returns long float |
# |
Jun 18th 2019, 09:29 |
martin |
$test = 3.95; echo json_encode($test);exit; |
# |
Jun 18th 2019, 09:28 |
neon1024 |
@martin Have you trierd using `number_format()` in an entity accessor method? |
# |
Jun 18th 2019, 09:26 |
martin |
when I do echo json_decode($array) I get the long float |
# |
Jun 18th 2019, 09:26 |
conehead |
What does the debugger say? |
# |
Jun 18th 2019, 09:25 |
conehead |
So pr the array you get 3.95 and when returning the result you get an incorrect value? |