In #666956: Provide DrupalCloneTestCase for testing pre-configured drupal sites a patch was committed to simpletest 7.x-2.x to allow testing of pre-configured drupal sites. DrupalCloneTestCase is not functional and throws this error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd7pow.simpletest737772system' doesn't exist: SELECT * FROM {system} WHERE type = 'theme' OR (type = 'module' AND status = 1) ORDER BY weight ASC, name ASC; Array ( ) in system_list() (line 151 of includes/module.inc).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scor’s picture

I'm attaching a patch to reproduce this bug. You should get the error above if you attempt to run the "SimpleTest DrupalCloneTestCase" test. Note that testContact() should fail unless you have enable the contact module, but the PDOException is thrown way before SimpleTest gets to run the tests properly anyways.

daniel.nitsche’s picture

I can confirm this is still an issue -- is there a planned fix in the works?

Having a quick look at the code, does the setUp function need to be overwritten from the parent DrupalWebTestCase? (because DrupalWebTestCase is design to rebuild the DB from scratch)

In Drupal 6 I was using this technique to run tests on the live DB
http://www.trellon.com/content/blog/forcing-simpletest-use-live-database

but it doesn't seem to work for Drupal 7 (which is why I was looking at DrupalCloneTestCase).

ygerasimov’s picture

Status: Active » Needs review
FileSize
2.15 KB

Here is patch to fix the issue.

daniel.nitsche’s picture

Thanks for the patch -- I can confirm this fixes the issue.

al.ex’s picture

confirming issue & fix

ygerasimov’s picture

Status: Needs review » Reviewed & tested by the community
neochief’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.83 KB

Reroll agains current 2.x.

daniel.nitsche’s picture

This patch doesn't work for me against 2.x. I get 3 errors (I assume the last error listed is the main problem). I'll see if I can work out what's going on.

PS. anyone know if this module is still alive? There hasn't been a commit in over a year.

Additional uncaught exception thrown while handling exception.OriginalPDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1: INSERT INTO simpletest110720node SELECT * FROM node; Array ( ) in DrupalCloneTestCase->cloneTable() (line 3488 of /var/www/test/sites/all/modules/simpletest/drupal_web_test_case.php).

AdditionalPDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.simpletest110720node_type' doesn't exist: SELECT nt.* FROM {node_type} nt WHERE (disabled = :db_condition_placeholder_0) ORDER BY nt.type ASC; Array ( [:db_condition_placeholder_0] => 0 ) in _node_types_build() (line 704 of /var/www/test/modules/node/node.module).

Uncaught exception thrown in session handler.PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.simpletest110720sessions' doesn't exist: SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ) FOR UPDATE; Array ( [:db_condition_placeholder_0] => rzQqzYV7zduqr2bBqabKt8q46RGhhbMw7mKEf92eDnI [:db_condition_placeholder_1] => ) in _drupal_session_write() (line 209 of /var/www/test/includes/session.inc).

GaëlG’s picture

Issue summary: View changes

Sometimes when database updates have been done, the order of columns in the database is not the same as the one in the schema.
To have it work, I had to change:

db_query('INSERT INTO ' . $target . ' SELECT * FROM ' . $source);

into:

db_query('INSERT INTO ' . $target . ' SELECT ' . implode(',', array_keys($schema['fields'])) . ' FROM ' . $source);
minorOffense’s picture

Here's an updated patch that applies to the sept 2016 dev release. I can confirm this actually does let the module clone the db properly.

Status: Needs review » Needs work

The last submitted patch, 10: 983266-10-simletest-clone.patch, failed testing.

minorOffense’s picture

Status: Needs work » Needs review

I'm gonna put it back to needs review. Looks like the CI runner failed to load some composer stuff. Not related to the patch itself.