IvanChepurnyi/EcomDev_PHPUnit — Issue #18: websites, store groups, stores break after first use
Author: veilig2000
Created: 2012-01-31 18:51:57+00:00
State: open

My test database, which was copied over from development, was setup with multiple stores and websites - this worked fine on all my tests, none of which had a multiple store configuration in their fixture file, until I tried to write a new test that included a new configuration because I was specifically testing it. Now when I run my tests I'm getting a SQL error on this specific test.

Zend_Db_Statement_Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'base' for key 'UNQ_MAG_CORE_WEBSITE_CODE'

This is what my initial DB looked like for websites

mysql> select * from mag_core_website;
+------------+-------+--------------+------------+------------------+------------+
| website_id | code | name | sort_order | default_group_id | is_default |
+------------+-------+--------------+------------+------------------+------------+
| 0 | admin | Admin | 0 | 0 | 0 |
| 1 | base | Main Website | 0 | 1 | 1 |
+------------+-------+--------------+------------+------------------+------------+

and this was the part of the fixture file that is throwing the error:

scope:
website: # Initializes websites
- website_id: 1
code: "base"
name: "Main Website"
default_group_id: 1

It appears I can make this work if I remove website_id: 1 from my test database and have the tests create/remove the entry, but then all my other tests start to break. The only way I see to fix that then will be to add the same multi store markup to all my fixture config files....which I have a lot and ideally don't want to do.

Is there a better way to handle this? I could always use different ID's but if we ever need to adjust these in the DB for some reason and it creates a conflict again - then we'll have the same issue.

I'm concerned I'm going to have the same results when I add groups and/or stores to the fixture as well...although I haven't gotten that far yet.