# |
Jun 16th 2019, 16:06 |
rogerpro |
Thank you very much, @ndm and @admad. Actually, my specific goal is to run tests for a plugin intended for an app that uses token auth. At some point, it seemed easier to me to test controller actions directly instead of making the auth work in test dev. Or, more important, test plugin functionality no matter which auth config is set up in the app. |
# |
Jun 16th 2019, 15:41 |
admad |
https://github.com/ADmad/cakephp-i18n/blob/master/tests/bootstrap.php#L11-L24 |
# |
Jun 16th 2019, 15:39 |
ndm |
A bit old, but the concept is still the same: https://stackoverflow.com/questions/35565066/setting-up-cakephp-3-plugin-testing/35611216#35611216 |
# |
Jun 16th 2019, 15:39 |
slackebot1 |
directory (`../../vendor/bin/phpunit`). |
# |
Jun 16th 2019, 15:39 |
ndm |
@rogerpro If you plan to make a standalone plugin, then you need to clear the auto-generated `tests/bootstrap.php` file and use it to set up an application environment that pulls in the core's bootstrap. If you're making a plugin that's part of your app, then you need to use the phpunit installation of the app, and run it either from the app's root and pass the plugin path (`vendor/bin/phpunit plugins/ContactManager`), or run it from your plugin |
# |
Jun 16th 2019, 15:09 |
rogerpro |
So everyone using running tests from a standalone plugin that has a bootstrap file should face the issue, I guess. |
# |
Jun 16th 2019, 15:08 |
rogerpro |
Got it, it’s here but not loaded. Hope this is not happening only to me :) |
# |
Jun 16th 2019, 15:07 |
rogerpro |
``` total@aadd2f92f77f:~/mnt/my_app_name/plugins/ContactManager$ cat vendor/cakephp/cakephp/tests/phpunit_aliases.php <?php if (class_exists('PHPUnit_Runner_Version')) { if (version_compare(\PHPUnit_Runner_Version::id(), '5.7', '<')) { trigger_error(sprintf('Your PHPUnit Version must be at least 5.7.0 to use CakePHP Testsuite, found %s', \PHPUnit_Runner_Version::id()), E_USER_ERROR); ``` |
# |
Jun 16th 2019, 15:07 |
rogerpro |
It is actually here: |
# |
Jun 16th 2019, 14:58 |
admad |
I don't remember from where/how it's supposed to be auto loaded |
# |
Jun 16th 2019, 14:58 |
admad |
For some reason this file isn't being loaded for you https://github.com/cakephp/cakephp/blob/master/tests/phpunit_aliases.php |
# |
Jun 16th 2019, 14:47 |
rogerpro |
7.2.17-0ubuntu0.18.04.1 |
# |
Jun 16th 2019, 14:46 |
rogerpro |
I got the same error |
# |
Jun 16th 2019, 14:46 |
admad |
What's your PHP version? |
# |
Jun 16th 2019, 14:46 |
admad |
Try `composer update --with-dependencies` |
# |
Jun 16th 2019, 14:45 |
rogerpro |
Sure |
# |
Jun 16th 2019, 14:45 |
rogerpro |
Actually, I also ran `rm -rf vendor/ composer.lock andand composer clearcache andand composer install andand vendor/bin/phpunit` |
# |
Jun 16th 2019, 14:45 |
admad |
Ah right, I misread, it would install latest 3.7 even with `^3.5` |
# |
Jun 16th 2019, 14:44 |
rogerpro |
Of course |
# |
Jun 16th 2019, 14:43 |
admad |
Did you run composer update after changing it? |
# |
Jun 16th 2019, 14:41 |
rogerpro |
Nope. It actually installs 3.7.8. And updating it to `"^3.7"` keeps the PHPunit error. |
# |
Jun 16th 2019, 14:38 |
admad |
Well you know what to do with that :slightly_smiling_face: |
# |
Jun 16th 2019, 14:36 |
rogerpro |
“^3.5” |
# |
Jun 16th 2019, 14:33 |
admad |
@rogerpro what's the cakephp version specific in composer.json? |
# |
Jun 16th 2019, 14:30 |
rogerpro |
Got same error |
# |
Jun 16th 2019, 14:29 |
rogerpro |
Did not worked for me, @admad . I did `rm -rf vendor/ composer.lock andand composer clearcache andand composer install andand vendor/bin/phpunit` in the plugin’s directory. |
# |
Jun 16th 2019, 14:20 |
admad |
@rogerpro delete the vendor directory and composer.lock file, clear composer cache, then run composer install again |
# |
Jun 16th 2019, 13:55 |
rogerpro |
I just reported a bug: https://github.com/cakephp/cakephp/issues/13353 — no idea why this is happening |
# |
Jun 16th 2019, 08:39 |
graziel |
https://github.com/cakephp/cakephp/blob/master/tests/TestCase/ORM/TableTest.php |
# |
Jun 16th 2019, 08:38 |
maymeow |
complete tests examples |
# |
Jun 16th 2019, 08:37 |
graziel |
still not sure what you need, mock table? test finders? |
# |
Jun 16th 2019, 08:32 |
maymeow |
for models im using tests li this https://gist.github.com/MayMeow/a163111262275ec1ff70e25dd29b08ab (dont remember where i found it) |
# |
Jun 16th 2019, 08:29 |
maymeow |
For example how to test models Tables |
# |
Jun 16th 2019, 08:07 |
graziel |
and also in book https://book.cakephp.org/3.0/en/development/testing.html |
# |
Jun 16th 2019, 08:06 |
graziel |
but what do you need exactly? theres a bunch of tests in cake already https://github.com/cakephp/cakephp/tree/master/tests |
# |
Jun 16th 2019, 07:58 |
maymeow |
is there any good examples of CakePHP 3.x tests? |
# |
Jun 16th 2019, 07:57 |
maymeow |
Hi |
# |
Jun 16th 2019, 04:20 |
subhanahmed |
Hi All, I just updated an old app to cakephp 3.7. I’m getting the following error: `Property _transportConfig does not exist ` in `ROOT/vendor/cakephp/debug_kit/src/Panel/MailPanel.php, line 43 ` Any solutions? Thanks. |
# |
Jun 15th 2019, 23:29 |
joey.mukherjee |
@khalid These are my two ajax calls. I feel like they are pretty basic... I see the _Token in my page source. It is just after the form end. |
# |
Jun 15th 2019, 23:27 |
slackebot1 |
$('#gvmain_content').html (data); }, error: function (data) { alert ('Something went wrong!'); console.log (data); $('#gvmain_content').html (data); } }); }); |
# |
Jun 15th 2019, 23:27 |
slackebot1 |
$this->Url->build ('/plots/change_version', true); ?>", type: 'GET', beforeSend: function (xhr) { xhr.setRequestHeader ('X-CSRF-Token', $('[name="_csrfToken"]').val ()); }, data: {version: version}, dataType: 'html', success: function (data) { |