# |
Jul 12th 2017, 15:29 |
neon1024 |
Sounds like you need `require($myPhpFile)` |
# |
Jul 12th 2017, 15:29 |
jlroberts |
the only place I see it is in autoload_files.php @generated by composer |
# |
Jul 12th 2017, 15:27 |
jlroberts |
Here is my github issue for more details, https://github.com/cakephp/app/issues/525 |
# |
Jul 12th 2017, 15:27 |
jlroberts |
ok fellas, I got a question for yall, I am trying to dispatch shells from app/src/Console/Installer.php, but it appears that the cakephp/src/Core/functions.php file is not autoloaded, however, the use statements in Installer.php is autoloaded... anyone know how cakephp/src/Core/functions.php is loaded outside of Installer.php? |
# |
Jul 12th 2017, 15:26 |
jeremyharris |
:+1: lemme know! |
# |
Jul 12th 2017, 15:26 |
ericadeefox |
ok backpedal, I'm gonna give rewriting these a shot before I gist em |
# |
Jul 12th 2017, 15:26 |
jeremyharris |
also, make sure there’s only one `$this->post()` and friends during each test case |
# |
Jul 12th 2017, 15:25 |
jeremyharris |
that’s usually how integration tests look. maybe gist one so I can see :slightly_smiling_face: |
# |
Jul 12th 2017, 15:25 |
ericadeefox |
does this mean I should rewrite my tests so that they _start_ with requests? like `$this->post()` or `$this->get()` at the beginning, so the session object is created right off the jump? |
# |
Jul 12th 2017, 15:24 |
ericadeefox |
so in testing, since the session object isn't created until a request is--oh, wait |
# |
Jul 12th 2017, 15:23 |
ericadeefox |
^that's basically what's happening. the plugin checks to see if a session has been started, then 500s and throws an error when it isn't. |
# |
Jul 12th 2017, 15:23 |
jeremyharris |
perhaps an FB class is instantiated early and checks the session? |
# |
Jul 12th 2017, 15:22 |
jeremyharris |
you shouldn’t need session_start anywhere. other integration tests work successfully using the session, no? |
# |
Jul 12th 2017, 15:22 |
jeremyharris |
ok so this is the process: `$this->session` just stores what you want to write, `$this->post()` starts by building a request, it sees you want to write session data, so it creates a session object and `$session->write()`s to it. `$session->write()` sees the session isn’t started yet, so it starts it for you. the request is then dispatched |
# |
Jul 12th 2017, 15:19 |
ericadeefox |
hmm... my tests don't work unless I use `session_start()` at the top of the first test. but then using that, a few of the tests still don't work, because they have to write stuff using `$this->session()`. idk if there is any way to make them compatible. |
# |
Jul 12th 2017, 15:17 |
jlroberts |
word |
# |
Jul 12th 2017, 15:17 |
jeremyharris |
that’s why `$this->session` exists, to write into the session when the request is actually built |
# |
Jul 12th 2017, 15:17 |
ericadeefox |
ahhh. ::nod:: |
# |
Jul 12th 2017, 15:17 |
jeremyharris |
no it’s not, because the request isn’t built until the test method (e.g., get, post) executes |
# |
Jul 12th 2017, 15:16 |
ericadeefox |
I mean, is it _possible_ to write session data using `$this->request->session()->write()` in integration tests? because I just keep getting the error message `Undefined property: App\Test\TestCase\Controller\EventsControllerTest::$request` when I do this. |
# |
Jul 12th 2017, 15:09 |
jeremyharris |
np! |
# |
Jul 12th 2017, 15:09 |
jeremyharris |
I don’t think it makes sense for it to be a mysql field :slightly_smiling_face: |
# |
Jul 12th 2017, 15:09 |
pedroseco |
:) |
# |
Jul 12th 2017, 15:09 |
pedroseco |
thanks |
# |
Jul 12th 2017, 15:09 |
pedroseco |
ah ok that can work too |
# |
Jul 12th 2017, 15:09 |
jeremyharris |
ok, then I would do the fetch first, then just sum it up like $sum = $results->sum(‘totalhours’) |
# |
Jul 12th 2017, 15:09 |
pedroseco |
the sum gives the right answer, and your solution to get all fields works too. |
# |
Jul 12th 2017, 15:08 |
pedroseco |
yes |
# |
Jul 12th 2017, 15:06 |
jeremyharris |
but still want those records as well |
# |
Jul 12th 2017, 15:06 |
jeremyharris |
if I’m getting this correctly, you want the sum of totalhours on all the records of $this (dunno the table name) right? |
# |
Jul 12th 2017, 15:06 |
pedroseco |
maybe that’s the reason i’m only get 1 row of results? |
# |
Jul 12th 2017, 15:05 |
jeremyharris |
@pedroseco that looks ok to me, except it’s missing a group clause which you usually need for aggregate functions |
# |
Jul 12th 2017, 15:04 |
jeremyharris |
and the session is started if it needs to be during write() |
# |
Jul 12th 2017, 15:04 |
ericadeefox |
ok I'm gonna try to write this differently then... |
# |
Jul 12th 2017, 15:03 |
jeremyharris |
the request won’t be available until after the integration test method (e.g., get, post) runs so by then it will be too late. but here’s where it’s written: https://api.cakephp.org/3.4/source-class-Cake.TestSuite.IntegrationTestCase.html#546 |
# |
Jul 12th 2017, 15:02 |
pedroseco |
@jeremyharris sure: https://gist.github.com/pedroseco/7f2d0cb0e01361c98fc7cd346f24bc24 |
# |
Jul 12th 2017, 15:02 |
ericadeefox |
@jeremyharris wait does it? wouldn't that mean that one _could_ use `$this->session()` with `session_start()` and it would work? because it totally wasn't working for me so now I'm just trying to figure out how to use `$this->request->session()` |
# |
Jul 12th 2017, 15:00 |
jeremyharris |
@pedroseco maybe I misunderstood. can you gist your query that has the sum on it? |
# |
Jul 12th 2017, 15:00 |
jeremyharris |
@ericadeefox still dealing with FB stuff? :( I was reading the code and the integration test writes the data you pass in $this->session to the session right before dispatching the request |
# |
Jul 12th 2017, 15:00 |
pedroseco |
instead of manipulating the entity on the query object? |
# |
Jul 12th 2017, 14:59 |
pedroseco |
should I use a collection here? |