veda-consulting-company / uk.co.vedaconsulting.mailchimp

Other
22 stars 43 forks source link

Odd issue running tests: testRemoveInSync fails, but can't repro via SQL #226

Open xurizaemon opened 8 years ago

xurizaemon commented 8 years ago

I ran into a strange issue running the tests, and rather than try to debug it further figured I'd post here.

Prep: I added @depends testGetMCInterestGroupings and @group sync to this test, so I could easily run just that test and its dependency. This is reproducible if you run a wider set of tests, though.

Problem: testRemoveInSync() reports a failure, but looks like it should succeed.

testRemoveInSync runs these three SQL:

INSERT INTO tmp_mailchimp_push_c (email, hash, contact_id) VALUES
  ('found@example.com', 'aaaaaaaaaaaaaaaa', 1),
  ('red-herring@example.com', 'aaaaaaaaaaaaaaaa', 2);

INSERT INTO tmp_mailchimp_push_m (email, hash, cid_guess) VALUES
  ('found@example.com', 'aaaaaaaaaaaaaaaa', 1),
  ('notfound@example.com', 'aaaaaaaaaaaaaaaa', 2);

SELECT COUNT(c.email) AS co FROM tmp_mailchimp_push_m m
  INNER JOIN tmp_mailchimp_push_c c ON m.cid_guess = c.contact_id AND m.hash = c.hash;

From MySQL CLI, these work fine; the expected result of 2 is returned from the final query.

Run via phpunit sites/default/civicrm/extensions/uk.co.vedaconsulting.mailchimp/tests --group sync, the result of the second query via $dao->co is 0 instead of 2.

As a result, the test fails. I'm flummoxed - activating query logging didn't show any additional queries being fired between the three queries above ... what am I missing?

Tests being run on Linux, MySQL 5.5.50-0+deb8u1-log, via PHPUnit 5.5.4.