How to test the extension classes ?
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
How to test the extension classes ?
Laravel : 8.12
Aimeos : 2020.10
PHP Version : 7.4.13
Environment : Windows
I have created Item, Manager, JQAdm Panel, Frontend Controller and JSONAPI client classes for my new data domain.
I created test classes for all of these in their own test folders as in the directory structure of aimeos extension.
I saw in the aimeos documentation that in order to test my classes i need to first checkout in the aimeos-core repository and copy my custom extension folder there and configure test database. This way of testing seems to be an overkill.
Is there any other good way to test the classes in the custom aimeos extension inside the same project ?
Aimeos : 2020.10
PHP Version : 7.4.13
Environment : Windows
I have created Item, Manager, JQAdm Panel, Frontend Controller and JSONAPI client classes for my new data domain.
I created test classes for all of these in their own test folders as in the directory structure of aimeos extension.
I saw in the aimeos documentation that in order to test my classes i need to first checkout in the aimeos-core repository and copy my custom extension folder there and configure test database. This way of testing seems to be an overkill.
Is there any other good way to test the classes in the custom aimeos extension inside the same project ?
Re: How to test the extension classes ?
Yes, it's possible if you run
to create the unittest data and call phpunit with the required parameters, e.g.
Code: Select all
php artisan aimeos:setup unittest unittest
Code: Select all
vendor/bin/phpunit --bootstrap=vendor/autoload.php -c ext/ai-admin-jqadm/lib/custom/tests/phpunit.xml
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: How to test the extension classes ?
The phpunit unit command is displaying an error. I ran the following command -
It is running my test cases but the classes are not recognized and errors are being displayed.
I also tried to run the following phpunit command -
and this time only TestHelper class not found is shown in the errors.
Why are the classes not being found in the test cases of extension??
Code: Select all
vendor/bin/phpunit --bootstrap=./vendor/autoload.php -c ./ext/ext-pincode/lib/custom/tests/phpunit.xml
Code: Select all
vendor/bin/phpunit --bootstrap=./ext/ext-pincode/vendor/autoload.php -c ./ext/ext-pincode/lib/custom/tests/phpunit.xml
Re: How to test the extension classes ?
If your extension isn't installed via composer, you must execute
Code: Select all
composer dump-autoload
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: How to test the extension classes ?
Executed
and still not working!!
Code: Select all
composer dump-autoload
Re: How to test the extension classes ?
Maybe there's another problem with your custom extension but for the Aimeos standard extensions it works pretty well, e.g.:
Does this command also works in your installation?
Code: Select all
vendor/bin/phpunit --bootstrap=vendor/autoload.php -c ext/ai-admin-jqadm/lib/custom/tests/phpunit.xml
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: How to test the extension classes ?
Yes! this command is working.aimeos wrote: ↑18 Jan 2021, 17:43 Maybe there's another problem with your custom extension but for the Aimeos standard extensions it works pretty well, e.g.:Does this command also works in your installation?Code: Select all
vendor/bin/phpunit --bootstrap=vendor/autoload.php -c ext/ai-admin-jqadm/lib/custom/tests/phpunit.xml
Re: How to test the extension classes ?
I think, you have to add the path of your new extension to the "classmap" section of your composer.json and run "composer dump-autoload" again because it's unknown to composer if it's not installed via composer.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: How to test the extension classes ?
Thanks! Now the test cases are executed.
One last thing, for test cases requiring database access, it is not using the database configuration set in .env file. Do i have to separately configure database for testing and if yes where?
One last thing, for test cases requiring database access, it is not using the database configuration set in .env file. Do i have to separately configure database for testing and if yes where?
Re: How to test the extension classes ?
That's a bit tricky. You can add ./ext/<yourext>/config/resource.php to your extension with:
but you should remove that file after testing because it will take precedence for your DB settings also in production.
Code: Select all
<?php
return [
'db' => [
'adapter' => config('database.connections.mysql.driver', 'mysql'),
'host' => config('database.connections.mysql.host', '127.0.0.1'),
'port' => config('database.connections.mysql.port', '3306'),
'socket' => config('database.connections.mysql.unix_socket', ''),
'database' => config('database.connections.mysql.database', 'forge'),
'username' => config('database.connections.mysql.username', 'forge'),
'password' => config('database.connections.mysql.password', ''),
'stmt' => ["SET SESSION sort_buffer_size=2097144; SET NAMES 'utf8mb4'; SET SESSION sql_mode='ANSI'; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED"],
'limit' => 3, // maximum number of concurrent database connections
]
];
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
