diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-25 17:52:43 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-25 17:52:43 +0000 |
commit | fb5d44bc2c1c2d3ea79c4c9d19ea0d8c7d1f6950 (patch) | |
tree | 9d4c006c79db10896660c0cbf98ce43faee0f654 /modules/node/node.test | |
parent | 9a59cf76742669f4e7a26d1ef2737179db8cf7b5 (diff) | |
download | brdo-fb5d44bc2c1c2d3ea79c4c9d19ea0d8c7d1f6950.tar.gz brdo-fb5d44bc2c1c2d3ea79c4c9d19ea0d8c7d1f6950.tar.bz2 |
#303965 by moshe weitzman and snufkin: Allow data import scripts to set /->is_new programmatically.
Diffstat (limited to 'modules/node/node.test')
-rw-r--r-- | modules/node/node.test | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/modules/node/node.test b/modules/node/node.test index 30e3e6971..022b0cf78 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -664,3 +664,55 @@ class NodeRSSContentTestCase extends DrupalWebTestCase { $this->assertText($test_text, t('Extra node content appears in RSS feed.')); } } + +/** + * Test case to check node save related functionality, including import-save + */ +class NodeSaveTestCase extends DrupalWebTestCase { + + function getInfo() { + return array( + 'name' => t('Node save'), + 'description' => t('Test node_save() for saving content.'), + 'group' => t('Node'), + ); + } + + function setUp() { + parent::setUp(); + // Create a user that is allowed to post; we'll use this to test the submission. + $web_user = $this->drupalCreateUser(array('create article content')); + $this->drupalLogin($web_user); + $this->web_user = $web_user; + } + + /** + * Import test, to check if custom node ids are saved properly. + * Workflow: + * - first create a piece of content + * - save the content + * - check if node exists + */ + function testImport() { + // Node ID must be a number that is not in the database. + $max_nid = db_result(db_query('SELECT MAX(nid) FROM {node}')); + $test_nid = $max_nid + mt_rand(1000, 1000000); + $title = $this->randomName(8); + $node = array( + 'title' => $title, + 'body' => $this->randomName(32), + 'uid' => $this->web_user->uid, + 'type' => 'article', + 'nid' => $test_nid, + 'is_new' => TRUE, + ); + $node = (object)$node; + node_save($node); + // Test the import. + $node_by_nid = node_load($test_nid); + $this->assertTrue($node_by_nid, t('Node load by node ID.')); + + $node_by_title = $this->drupalGetNodeByTitle($title); + $this->assertTrue($node_by_title, t('Node load by node title.')); + } +} |