Révision b4adf10d
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/modules/node/node.test | ||
---|---|---|
2782 | 2782 |
$edit = array(); |
2783 | 2783 |
$langcode = LANGUAGE_NONE; |
2784 | 2784 |
$edit["title"] = $this->randomName(8); |
2785 |
$edit["body[$langcode][0][value]"] = t('Data that should appear only in the body for the node.');
|
|
2786 |
$edit["body[$langcode][0][summary]"] = t('Extra data that should appear only in the teaser for the node.');
|
|
2785 |
$edit["body[$langcode][0][value]"] = 'Data that should appear only in the body for the node.';
|
|
2786 |
$edit["body[$langcode][0][summary]"] = 'Extra data that should appear only in the teaser for the node.';
|
|
2787 | 2787 |
$this->drupalPost('node/add/page', $edit, t('Save')); |
2788 | 2788 |
|
2789 | 2789 |
$node = $this->drupalGetNodeByTitle($edit["title"]); |
... | ... | |
2801 | 2801 |
$build = node_view($node); |
2802 | 2802 |
$this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.'); |
2803 | 2803 |
} |
2804 |
|
|
2805 |
/** |
|
2806 |
* Tests fields that were previously hidden when the view mode is changed. |
|
2807 |
*/ |
|
2808 |
function testNodeViewModeChangeHiddenField() { |
|
2809 |
// Hide the tags field on the default display |
|
2810 |
$instance = field_info_instance('node', 'field_tags', 'article'); |
|
2811 |
$instance['display']['default']['type'] = 'hidden'; |
|
2812 |
field_update_instance($instance); |
|
2813 |
|
|
2814 |
$web_user = $this->drupalCreateUser(array('create article content', 'edit own article content')); |
|
2815 |
$this->drupalLogin($web_user); |
|
2816 |
|
|
2817 |
// Create a node. |
|
2818 |
$edit = array(); |
|
2819 |
$langcode = LANGUAGE_NONE; |
|
2820 |
$edit["title"] = $this->randomName(8); |
|
2821 |
$edit["body[$langcode][0][value]"] = 'Data that should appear only in the body for the node.'; |
|
2822 |
$edit["body[$langcode][0][summary]"] = 'Extra data that should appear only in the teaser for the node.'; |
|
2823 |
$edit["field_tags[$langcode]"] = 'Extra tag'; |
|
2824 |
$this->drupalPost('node/add/article', $edit, t('Save')); |
|
2825 |
|
|
2826 |
$node = $this->drupalGetNodeByTitle($edit["title"]); |
|
2827 |
|
|
2828 |
// Set the flag to alter the view mode and view the node. |
|
2829 |
variable_set('node_test_change_view_mode', 'teaser'); |
|
2830 |
$this->drupalGet('node/' . $node->nid); |
|
2831 |
|
|
2832 |
// Check that teaser mode is viewed. |
|
2833 |
$this->assertText('Extra data that should appear only in the teaser for the node.', 'Teaser text present'); |
|
2834 |
// Make sure body text is not present. |
|
2835 |
$this->assertNoText('Data that should appear only in the body for the node.', 'Body text not present'); |
|
2836 |
// Make sure tags are present. |
|
2837 |
$this->assertText('Extra tag', 'Taxonomy term present'); |
|
2838 |
|
|
2839 |
// Test that the correct build mode has been set. |
|
2840 |
$build = node_view($node); |
|
2841 |
$this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.'); |
|
2842 |
} |
|
2804 | 2843 |
} |
2805 | 2844 |
|
2806 | 2845 |
/** |
Formats disponibles : Unified diff
Udpate to 7.33