Here's my function:

  function testWeblinksCreate() {
    // Prepare a user to do the stuff.
    $user = $this->drupalCreateUser(array('access content', 'access web links', 'create weblinks', 'edit own weblinks'));
    $this->drupalLogin($user);

    $settings = array(
      'type' => 'weblinks',
      'title' => 'A sample link',
      'url' => 'http://www.example.com',
      'weight' => 0,
      );
    $link1 = $this->drupalCreateNode($settings);

    // Now do a list.
    $this->drupalGet('weblinks');
    $this->assertEqual($link1->is_new, 1, t('Link node created.'), 'Basic');
    $this->assertText($link1->title, t('Node title appears on the list.'), 'Basic');
    $this->assertNoText(t('There are no weblinks to display yet.'), t('No empty list message.'), 'Basic');

    $check = db_result(db_query("SELECT url FROM {weblinks} WHERE nid=%d", $link1->nid));
    $this->assertEqual($link1->url, $check, t('URL successfully stored.'), 'Basic');
  }

The node appears to be created, but the "drupalGet" is not finding any nodes to display. What am I doing wrong?

Comments

nancydru’s picture

I have now added a second node to my test and it is unpublished, but a db_query fails to find it.

nancydru’s picture

Title: Does drupalCreateNode cause teh node to be written to the database? » Does drupalCreateNode cause the node to be written to the database?

Actually, I'm wondering, since Taxonomy is on by default in 6.x, is it turned on when I do parent::setUp('weblinks', 'help');?

nancydru’s picture

Status: Active » Closed (works as designed)

Congratulations, SimpleTest found a bug in my module.