Integration testing my implementation against Aimeos
Posted: 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:
This fails:
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:
Thanks!
PHP Version: 7.1, Aimeos: recent dev-master, Typo3 8.7.8, and TYPO3/testing-framework 2.0.1, Linux, (dockerised Debian)
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);
Code: Select all
Aimeos\MW\DB\Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testdb_ftfadd314.mshop_locale_site' doesn't exist
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.
Thanks!
PHP Version: 7.1, Aimeos: recent dev-master, Typo3 8.7.8, and TYPO3/testing-framework 2.0.1, Linux, (dockerised Debian)