Using ext unit test

Help for integrating the Laravel package
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!
User avatar
IvanIgniter
Posts: 58
Joined: 01 Dec 2021, 07:41

Using ext unit test

Post by IvanIgniter » 07 Jul 2022, 10:46

I am using laravel 6.x, PHP 7.4, Docker desktop/Ubuntu and the Aimeos 2021 (aimeos-laravel: 2021.10.4 / aimeos-core: 2021.10.13)

I would like to ask how to use the unit test in the ext. We have successfully used the ext modified code and now with our modifications we would like to use the unit test built-in to it. I have found some of the convo using it like the code below but seems like it is not properly working. Kindly help how to use it?

vendor/bin/phpunit --bootstrap=vendor/autoload.php -c ext/ai-client-jsonapi/client/jsonapi/tests/phpunit.xml --filter=JsonApiTest
22b.jpg
22b.jpg (113.78 KiB) Viewed 7771 times

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: Using ext unit test

Post by aimeos » 08 Jul 2022, 08:48

Running tests for extensions in a Laravel environment is a bit tricky.
Even if you run it that way, there's no access to the database so the tests fail:

Code: Select all

vendor/bin/phpunit --prepend vendor/autoload.php --include-path vendor/aimeos/aimeos-core/ -c vendor/aimeos/ai-client-html/tests/phpunit.xml
What's always working is to check out aimeos/aimeos-core separately and place your extension (or link to it) in its ./ext/ folder. This is described here:
https://aimeos.org/docs/latest/develope ... sion-tests
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
IvanIgniter
Posts: 58
Joined: 01 Dec 2021, 07:41

Re: Using ext unit test

Post by IvanIgniter » 11 Jul 2022, 10:43

I have clone the aimeos core in a separate project for testing and I have successfully executed vendor/bin/phing setup from the instruction in the documentation but I am having trouble to test the ext folder unit test files. I can even test the buit-in unit test of the core with this command.
vendor/bin/phpunit --bootstrap=vendor/autoload.php -c tests/phpunit.xml

But for ext folder unit test with these command are having some issues. I don't how to make it work, kindly help?
vendor/bin/phing -Ddir=ext/ai-client-jsonapi/client/jsonapi/tests/phpunit.xml
vendor/bin/phing -Ddir=ext/ai-client-jsonapi/lib/custom/tests/phpunit.xml
a1.jpg
a1.jpg (107.03 KiB) Viewed 7737 times

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: Using ext unit test

Post by aimeos » 12 Jul 2022, 06:16

IvanIgniter wrote: 11 Jul 2022, 10:43 vendor/bin/phing -Ddir=ext/ai-client-jsonapi/client/jsonapi/tests/phpunit.xml
vendor/bin/phing -Ddir=ext/ai-client-jsonapi/lib/custom/tests/phpunit.xml
The correct command is:

Code: Select all

vendor/bin/phing -Ddir=ext/ai-client-jsonapi testext
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
IvanIgniter
Posts: 58
Joined: 01 Dec 2021, 07:41

Re: Using ext unit test

Post by IvanIgniter » 12 Jul 2022, 10:07

It did able to execute but still has an issue with it's default standard test. Any idea it cannot find the following class?
222a.jpg
222a.jpg (147.85 KiB) Viewed 7720 times

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: Using ext unit test

Post by aimeos » 13 Jul 2022, 11:42

Did you run "composer up" to install all dependencies?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
IvanIgniter
Posts: 58
Joined: 01 Dec 2021, 07:41

Re: Using ext unit test

Post by IvanIgniter » 15 Jul 2022, 01:37

Yes I did. I clone the aimeos-core: 2021.10 and copied our modified ext folder into the new project.
Phing seems to be working but it was not able to find 'Aimeos\MW\View\Standard' class upon initializing?
a3.jpg
a3.jpg (245.48 KiB) Viewed 7682 times

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: Using ext unit test

Post by aimeos » 17 Jul 2022, 06:43

You must not modify the Aimeos extension code directly because you won't be able to update and get bugfixes and security patches any more! Instead, only overwrite those files/classes you really need to change to get the behavior you want!

Can you please post the output of "composer show" for your Aimeos Core checkout?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
IvanIgniter
Posts: 58
Joined: 01 Dec 2021, 07:41

Re: Using ext unit test

Post by IvanIgniter » 18 Jul 2022, 07:03

We only modify parts of the code that are necessary for display of records and how it looks.

I clone the aimeos core https://github.com/aimeos/aimeos-core/tree/2021.10
This is the result of composer show:

aimeos/aimeos-base dev-master 2daf1a3 Aimeos base layer for abstracting from host environments
aimeos/macro 1.0.0 Dynamically extend objects by custom methods
aimeos/map 3.1.0 Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections
aimeos/upscheme 0.8.2 Database schema upgrades made easy
doctrine/cache 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, mem...
doctrine/dbal 3.3.7 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations v1.0.0 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations o...
doctrine/event-manager 1.1.1 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/instantiator 1.4.1 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
enshrined/svg-sanitize 0.15.4 An SVG sanitizer for PHP
guzzlehttp/guzzle 7.4.5 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.5.1 Guzzle promises library
guzzlehttp/psr7 2.4.0 PSR-7 message implementation that also provides common utility methods
myclabs/deep-copy 1.11.0 Create deep copies (clones) of your objects
nikic/php-parser v4.14.0 A PHP parser written in PHP
nyholm/psr7 1.5.1 A fast PHP7 implementation of PSR-7
phar-io/manifest 2.0.3 Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version 3.2.1 Library for handling version information and constraints
phing/phing 2.17.4 PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.
php-coveralls/php-coveralls v2.5.2 PHP client library for Coveralls API
php-http/message-factory v1.0.2 Factory interfaces for PSR-7 HTTP Message
phpdocumentor/reflection-common 2.2.0 Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock 5.3.0 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information t...
phpdocumentor/type-resolver 1.6.1 A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy v1.15.0 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage 9.2.15 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator 3.0.6 FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker 3.1.1 Invoke callables with a timeout
phpunit/php-text-template 2.0.4 Simple template engine.
phpunit/php-timer 5.0.3 Utility class for timing
phpunit/phpunit 9.5.21 The PHP Unit Testing framework.
psr/cache 1.0.1 Common interface for caching libraries
psr/container 1.1.2 Common Container Interface (PHP FIG PSR-11)
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 1.1.4 Common interface for logging libraries
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
sebastian/cli-parser 1.0.1 Library for parsing CLI options
sebastian/code-unit 1.0.8 Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3 Looks up which function or method a line of code belongs to
sebastian/comparator 4.0.6 Provides the functionality to compare PHP values for equality
sebastian/complexity 2.0.2 Library for calculating the complexity of PHP code units
sebastian/diff 4.0.4 Diff implementation
sebastian/environment 5.1.4 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 4.0.4 Provides the functionality to export PHP variables for visualization
sebastian/global-state 5.0.5 Snapshotting of global state
sebastian/lines-of-code 1.0.3 Library for counting the lines of code in PHP source code
sebastian/object-enumerator 4.0.4 Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector 2.0.4 Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context 4.0.4 Provides functionality to recursively process PHP variables
sebastian/resource-operations 3.0.3 Provides a list of PHP built-in functions that operate on resources
sebastian/type 3.0.0 Collection of value objects that represent the types of the PHP type system
sebastian/version 3.0.2 Library that helps with managing the version number of Git-hosted PHP projects
squizlabs/php_codesniffer 3.7.1 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
symfony/config v5.4.9 Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/console v5.4.10 Eases the creation of beautiful and testable command line interfaces
symfony/deprecation-contracts v2.5.2 A generic function and convention to trigger deprecation notices
symfony/filesystem v5.4.9 Provides basic utilities for the filesystem
symfony/polyfill-ctype v1.26.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme v1.26.0 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer v1.26.0 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring v1.26.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php73 v1.26.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80 v1.26.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81 v1.26.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/service-contracts v2.5.2 Generic abstractions related to writing services
symfony/stopwatch v5.4.5 Provides a way to profile code
symfony/string v5.4.10 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unifie...
symfony/yaml v5.4.10 Loads and dumps YAML files
theseer/tokenizer 1.2.1 A small library for converting tokenized PHP source code into XML and potentially other formats
voku/portable-ascii 2.0.1 Portable ASCII library - performance optimized (ascii) string functions for php.
webmozart/assert 1.11.0 Assertions to validate method input/output with nice error messages.

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: Using ext unit test

Post by aimeos » 19 Jul 2022, 08:06

You've checked out the master branch of aimeos/aimeos-core but you need the branch that matches your extension version (2021.10).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply