Impossible to enable modules in SimpleTest I am building SimpleTests for my modules:

It seems like the standard procedure for enabling modules it doesn't work for me:

function setUp() {
    parent::setUp('mymodule');
 }


I constantly get a stupid error code: Duplicate entry 'bartik-system-main' for key 'tmd': INSERT INTO {block}

As I am using profiles I used the $profile variable:

protected $profile = 'myprofilename';


I have forced this by using a Drupal function:

module_enable(array('mymodule'), $enable_dependencies = TRUE);


In this final case the error that persists is

Undefined property: stdClass::$name


Here below is a sample of my code:

class mymoduleWebTestCase extends DrupalWebTestCase {

  protected $privileged_user;

  protected $profile = 'myprofile';

  public static function getInfo() {
    return array(
        'name' =&gt; 'mymodule',
        'description' =&gt; 'mydescription.',
        'group' =&gt; 'mygroup',
    );
  }

  function setUp() {
    $this-&gt;privileged_user = new stdClass();
    parent::setUp();
   // Login a user that has access to the content sync server admin settings
    $this-&gt;privileged_user = $this-&gt;drupalCreate();
    $this-&gt;drupalLogin($this-&gt;privileged_user);
  }

  function testMyModule() {


    //Create content of community type
    $settings = array(
      'type' =&gt; 'mycontenttype',
      'title' =&gt; 'Sample Content',
      'link' =&gt; 'http://www.google.com',
      'body' =&gt; array(LANGUAGE_NONE =&gt; array(array('body'))),
      'moderate' =&gt; 1,
      'status' =&gt; 1,
      'revisions' =&gt; NULL,
      'taxonomy' =&gt; NULL,
    );
    $node = $this-&gt;drupalCreateNode($settings);
    $this-&gt;drupalGet('mymodule/sample-content');
    $this-&gt;assertRaw('Sample Content', t('Content created.'));


    $node = $this-&gt;drupalCreateNode($settings);

   //This if we have a valid link inside
    $this-&gt;clickLink(t('http://www.google.com'));

  }
You should make triple-sure that your module declares all of its dependencies properly. Even if it does, Simpletest struggles with dependencies and you may have luck if you enable them explicitly in setUp() before your module.

Also, not sure if it's the contributing your error, but instead of $this-&gt;privileged_user = new stdClass(); I would use DrupalWebTestCase::drupalCreateUser like so: $this-&gt;privileged_user = $this-&gt;drupalCreateUser(). I might also declare it after setup() but I'm not sure that's significant.