@RobMcA opened this Issue on January 12th 2021

After following the development setup and testing instruction, when running ./console tests:run --testsuite unit I get an error. I have created the database matomo_tests as mentioned in the docs, but don't see anything in the documentation on how to get the required tables created.

./console tests:run --testsuite unit                                                                                          
Executing command: cd /Users/rmcarthu/Development/repos/rmcarthu/matomo/tests/PHPUnit &&  /Users/rmcarthu/Development/repos/rmcarthu/matomo/vendor/bin/phpunit   --testsuite UnitTests

Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'matomo_tests.option' doesn't exist in /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Statement/Pdo.php:233
Stack trace:
<a href='/0'>#0</a> /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Statement/Pdo.php(233): PDOStatement->execute()
<a href='/1'>#1</a> /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
<a href='/2'>#2</a> /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
<a href='/3'>#3</a> /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT option_v...', Array)
<a href='/4'>#4</a> /Users/rmcarthu/Development/repos/rmcarthu/matomo/core/Db/Adapter/Pdo/Mysql.php(309): Zend_Db_Adapter_Pdo_Abstract->query('SELECT option_v...', Array)
<a href='/5'>#5</a> /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Adapter/Abstract.php(736): Piwik\Db\Adapter\Pdo\Mysql->query(' in /Users/rmcarthu/Development/repos/rmcarthu/matomo/libs/Zend/Db/Statement/Pdo.php on line 236
@tsteur commented on January 13th 2021 Member

Hi @RobMcA thanks for creating this issue. I suppose you're using the latest 4.X version of Matomo from github?

In https://github.com/matomo-org/developer-documentation/issues/385 it was mentioned that the MySQL user needs to have CREATE/DROP database & tables etc permission. Do you know if the MySQL user is maybe missing some permissions? Although I would assume in this case maybe the error message would be different.

The issue also mentions that somehow ./console tests:setup-fixture OmniFixture needs to be called once. Does it maybe work after executing that command?

@RobMcA commented on January 14th 2021

Thanks for the input. After setting request_uri = "" I ran ./console tests:setup-fixture OmniFixture and it loaded a number of fixtures before having a failure:
```./console tests:setup-fixture OmniFixture  ✔  10040  INSERT
Dropping database 'matomo_tests'...
Setting up Piwik\Tests\Fixtures\ManySitesImportedLogsWithXssAttempts...
Setting up Piwik\Plugins\Contents\tests\Fixtures\TwoVisitsWithContents...
Setting up Piwik\Tests\Fixtures\FewVisitsWithSetVisitorId...
Setting up Piwik\Tests\Fixtures\InvalidVisits...
Setting up Piwik\Tests\Fixtures\ManySitesImportedLogs...
Setting up Piwik\Tests\Fixtures\ManyVisitsWithGeoIP...
Setting up Piwik\Tests\Fixtures\ManyVisitsWithGeoIPAndEcommerce...
Setting up Piwik\Tests\Fixtures\ManyVisitsWithMockLocationProvider...
Setting up Piwik\Tests\Fixtures\ManyVisitsWithSubDirReferrersAndCustomVars...
Setting up Piwik\Tests\Fixtures\OneVisitSeveralPageViews...
Setting up Piwik\Tests\Fixtures\OneVisitWithAbnormalPageviewUrls...

Expected GIF beacon, got:

'GIF89a' . "\0" . '' . "\0" . '?' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0"
. '' . "\0" . '!?' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . ',' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" .
'' . "\0" . '' . "\0" . '' . "\0" . 'D' . "\0" . ';This resource is part of Matomo. Keep full control of your
data with the leading free and open source <a href=\'https://matomo.org\' target=\'_blank\' rel=\'noopener noreferr
er nofollow\'>web analytics & conversion optimisation platform.

This file is the endpoint for the Matomo tracking API. If you want to access the Matomo UI or use the Reporting API
, please use <a href=\'index.php\'>index.php instead.'
If you are stuck, you can enable [Tracker] debug=1; in config.ini.php to get more debug info.
Also, please try to restart your webserver, and run the test again, this may help!R0lGODlhAQABAIAAAAAAAAAAACH5BAEA

URL was: http://localhost:8000/tests/PHPUnit/proxy/matomo.php?idsite=1&rec=1&apiv=1&r=878744&cip=
Failed asserting that two strings are equal.

Looking in the web log I see the following error:

[Thu Jan 14 09:13:23 2021] Error in Matomo (tracker): Error query: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xEA_\xBD\xEF\xA4\xBB...' for column 'name' at row 1 In query: INSERT INTO log_action (name, hash, type, urlprefix) VALUES (?,CRC32(?),?,?) Parameters: array ( 0 => 'my.url/��碌������_κ�_�ό�शμε�', 1 => 'my.url/��碌������_κ�_�ό�शμε��_', 2 =>, 3 => 1, )

My mysql database is running utf8mbf3. Any suggestions?

I tried `/.console tests:run` and it complained

Executing command: cd /Users/rmcarthu/Development/repos/rmcarthu/matomo/tests/PHPUnit && /Users/rmcarthu/Development/repos/rmcarthu/matomo/vendor/bin/phpunit --testsuite UnitTests
WARNING: for tests to pass, you must first:
1) Install webserver on localhost, eg. apache
2) Make these Piwik files available on the webserver, at eg. http://localhost/dev/piwik/
3) Install Piwik by going through the installation process
4) Configure tests section if needed in config/config.ini.php:
http_host = "localhost"
request_uri = "@REQUEST_URI@"
remote_addr = ""

Try again.

Changing `request_uri = "<a class='mention' href='https://github.com/REQUEST_URI'>@REQUEST_URI</a>@" then allowed tests to run. So it seems there is inconsistency as to what the `request_uri` value should be.
@RobMcA commented on January 14th 2021

Strangely, resetting everything from scratch and running it all again resulted in the unit tests running fine with no change needed to request_uri.

@tsteur commented on January 14th 2021 Member

Thanks @RobMcA I'll close this issue for now as a duplicate of https://github.com/matomo-org/developer-documentation/issues/385 where we need to adjust the docs as I understand it works now for you. Thanks for trying all this and sorry for running into that trouble. Did you initially set the request_uri in the config?

This Issue was closed on January 14th 2021
Powered by GitHub Issue Mirror