Questions around the TYPO3 integration and plugins as well as Flow and NeosCMS
Forum rules: Always add your TYPO3/Flow, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5220 by aleks
12 Dec 2017, 09:05
I want to write integration & functional tests of my TYPO3/Aimeos extension against Aimeos components. That's especially important since we're using dev-master versions of Aimeos :-)

My components need to also instantiate the Aimeos Context, including locales. The code looks like this:

Code: Select all        $aimeosSettings = Aimeos\Base::getConfig($settings ?? []);
        $this->_context = Aimeos\Base::getContext($aimeosSettings);

        $locale = Aimeos\Base::getLocaleBackend($this->_context, $site ?? 'default');
        $this->_context->setLocale($locale);


This fails:

Code: Select allAimeos\MW\DB\Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testdb_ftfadd314.mshop_locale_site' doesn't exist


That's understandable, since Typo3 knows nothing of Aimeos' tables (see this longstanding issue) and the testing framework doesn't instantiate them. I will also need the product, attribute, etc. tables later on, so this is just the first error.

So, my question is: how do I test my components in this scenario? I can think of two ways:
  • a) run the aimeos extension update script in `setUp()` — but I don't yet know how.
  • b) prepare the tables using a fixture, or, if that is not possible, directly using doctrine DBAL to create the tables.
  • c) Mock the Aimeos context in some way that doesn't ruin the integration/functional nature of my tests. That would be my least preferred option.

Which one do you think is the better way? Which one are you using in your own tests? I wasn't able to find an answer in the aimeos-typo3 code, but maybe just didn't look in the right places.

Thanks!

PHP Version: 7.1, Aimeos: recent dev-master, Typo3 8.7.8, and TYPO3/testing-framework 2.0.1, Linux, (dockerised Debian)
#5228 by aleks
13 Dec 2017, 11:37
Thanks for your answer :-) So it's basically running the Aimeos Update script, I can live with that (even though it makes the test very slow.)

It seems it can't find the static_countries table during the call to Setup::execute(), and hence some SQL fails. I'll see if I can find that table somewhere and just add it as a fixture or directly over Doctrine.

We're using dev-master because we were initially relying on the (bug-free implementation) of some newer additions to Aimeos, such as JQAdm and the JSON API. Our project is in active development, and we're going to cut to a stable release as soon as the project nears completion. In the meantime, we can test bleeding edge Aimeos and send you bug reports ;-)
#5230 by aimeos
13 Dec 2017, 23:12
aleks wrote:Thanks for your answer :-) So it's basically running the Aimeos Update script, I can live with that (even though it makes the test very slow.)


Put the method call into the setUpBeforeClass() of your test classes. Then, the tables will be checked only once for each
test class.

aleks wrote:It seems it can't find the static_countries table during the call to Setup::execute(), and hence some SQL fails. I'll see if I can find that table somewhere and just add it as a fixture or directly over Doctrine.


Yes, the static_countries tables are not part of Aimeos but of the static_info_tables extension.

aleks wrote:We're using dev-master because we were initially relying on the (bug-free implementation) of some newer additions to Aimeos, such as JQAdm and the JSON API. Our project is in active development, and we're going to cut to a stable release as soon as the project nears completion. In the meantime, we can test bleeding edge Aimeos and send you bug reports ;-)


Always very welcome! :-)
According to our todo list, the PHP changes are almost done besides renaming all templates for consistency (default -> standard). The most active development is currently in the JQAdm interface (using Vue.js in templates) so please expect a few problems there from time to time ...