@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...

[PHPUnit\Framework\ExpectationFailedException]
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
AAAALAAAAAABAAEAAAICRAEAO1RoaXMgcmVzb3VyY2UgaXMgcGFydCBvZiBNYXRvbW8uIEtlZXAgZnVsbCBjb250cm9sIG9mIHlvdXIgZGF0YSB3aXR
oIHRoZSBsZWFkaW5nIGZyZWUgYW5kIG9wZW4gc291cmNlIDxhIGhyZWY9J2h0dHBzOi8vbWF0b21vLm9yZycgdGFyZ2V0PSdfYmxhbmsnIHJlbD0nbm
9vcGVuZXIgbm9yZWZlcnJlciBub2ZvbGxvdyc+d2ViIGFuYWx5dGljcyAmIGNvbnZlcnNpb24gb3B0aW1pc2F0aW9uIHBsYXRmb3JtPC9hPi48YnI+C
lRoaXMgZmlsZSBpcyB0aGUgZW5kcG9pbnQgZm9yIHRoZSBNYXRvbW8gdHJhY2tpbmcgQVBJLiBJZiB5b3Ugd2FudCB0byBhY2Nlc3MgdGhlIE1hdG9t
byBVSSBvciB1c2UgdGhlIFJlcG9ydGluZyBBUEksIHBsZWFzZSB1c2UgPGEgaHJlZj0naW5kZXgucGhwJz5pbmRleC5waHA8L2E+IGluc3RlYWQu

URL was: http://localhost:8000/tests/PHPUnit/proxy/matomo.php?idsite=1&rec=1&apiv=1&r=878744&cip=156.5.3.2&cdt=201
2-01-11+12%3A04%3A33&_idts=1610633601&fla=1&java=1&qt=0&realp=0&pdf=0&wma=0&ag=0&h=12&m=34&s=6&res=1024x768&cookie=
1&_id=a898c00b8e1d9f0c&url=http%3A%2F%2Fwww.my.url%2F%EA%9F%BD%EF%A4%BB%E3%92%A7%E4%8A%B6%E4%BA%84%EF%B6%86%E2%85%8
5%E0%B8%82%CE%BA%E3%82%82%E1%8A%B8%E1%BD%B9%CF%83%E0%A4%B6%CE%BC%CE%B5%DE%96%E0%A5%83&urlref=http%3A%2F%2Fwww.googl
e.com%2Fsearch%3Fq%3Dpiwik&pv_id=60e3f6&action_name=Valid+URL%2C+although+strange+looking
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:
[tests]
http_host = "localhost"
request_uri = "@REQUEST_URI@"
remote_addr = "127.0.0.1"

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