Mercurial > hg > rr-repo
comparison sites/all/modules/entityreference_prepopulate/entityreference_prepopulate.test @ 4:ce11bbd8f642
added modules
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 19 Sep 2013 10:38:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:b28be78d8160 | 4:ce11bbd8f642 |
---|---|
1 <?php | |
2 | |
3 class EntityReferenceOgContextTestCase extends DrupalWebTestCase { | |
4 | |
5 public static function getInfo() { | |
6 return array( | |
7 'name' => 'OG-context integration', | |
8 'description' => 'Test the OG-context integration, which allows prepopulating by the group context.', | |
9 'group' => 'Entity reference prepopulate', | |
10 'dependencies' => array('og'), | |
11 ); | |
12 } | |
13 | |
14 function setUp() { | |
15 parent::setUp('og_context', 'entityreference_prepopulate_test'); | |
16 | |
17 $this->user1 = $this->drupalCreateUser(); | |
18 $this->user2 = $this->drupalCreateUser(array('bypass node access', 'administer group')); | |
19 | |
20 $type = $this->drupalCreateContentType(); | |
21 $this->group_type = $type->type; | |
22 og_create_field(OG_GROUP_FIELD, 'node', $this->group_type); | |
23 | |
24 $type = $this->drupalCreateContentType(); | |
25 $this->group_content_type = $type->type; | |
26 | |
27 $og_field = og_fields_info(OG_AUDIENCE_FIELD); | |
28 // Enable the prepopulate behavior. | |
29 $og_field['instance']['settings']['behaviors']['prepopulate'] = array( | |
30 'status' => TRUE, | |
31 'action' => 'none', | |
32 'fallback' => 'none', | |
33 'skip_perm' => FALSE, | |
34 'og_context' => TRUE, | |
35 ); | |
36 og_create_field(OG_AUDIENCE_FIELD, 'node', $this->group_content_type, $og_field); | |
37 } | |
38 | |
39 /** | |
40 * Test the OG-context integration. | |
41 */ | |
42 function testPrepopulate() { | |
43 $settings = array( | |
44 'type' => $this->group_type, | |
45 'uid' => $this->user1->uid, | |
46 ); | |
47 $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; | |
48 $group1 = $this->drupalCreateNode($settings); | |
49 | |
50 og_group('node', $group1, array('entity_type' => 'user', 'entity' => $this->user2)); | |
51 | |
52 $this->drupalLogin($this->user2); | |
53 $this->drupalGet('node/add/' . str_replace('_', '-', $this->group_content_type)); | |
54 $this->assertNoOptionSelected('edit-og-group-ref-und-0-default', 1, 'Group-audience fields is not selected.'); | |
55 | |
56 // Set the OG-context(); | |
57 // See entityreference_prepopulate_init(). | |
58 $options = array( | |
59 'query' => array( | |
60 'gid' => $group1->nid, | |
61 ), | |
62 ); | |
63 | |
64 $this->drupalGet('node/add/' . str_replace('_', '-', $this->group_content_type), $options); | |
65 $this->assertOptionSelected('edit-og-group-ref-und-0-default', 1, 'Group-audience fields is selected.'); | |
66 } | |
67 } |