function ClassifiedBasicTest::test1432606 in Classified Ads 6.3
Bug 1432606: Ads can be viewed when not published.
File
- tests/
classified_basic.test, line 449 - Basic test for known bugs in previous versions.
Class
Code
function test1432606() {
$this->group = __FUNCTION__;
$accounts = array(
'admin',
'basic',
'creator',
);
$this
->createUsers($accounts);
// 1. Get the Classified vocabulary id.
$vid = _classified_get('vid');
// 2a. Create a term in it, do not assign a specific lifetime.
$term = array(
'name' => $this
->randomName(8),
'description' => $this
->randomString(20),
'vid' => $vid,
);
$status = taxonomy_save_term($term);
$tid = $term['tid'];
$this
->assertEqual($status, SAVED_NEW, t('Term @tid created in default vocabulary.', array(
'@tid' => $tid,
)), 'setup');
// 2b. Create a published node bearing that term, belonging to "creator".
$this->group = t('new, default');
$node = $this
->createNode(array(
'taxonomy' => array(
$vid => $tid,
),
'uid' => $this->creatorUser->uid,
'status' => 1,
));
$path = 'node/' . $node->nid;
// 3. All four profiles should see published node.
$this
->drupalLogout();
$this
->drupalGet($path);
$this
->assertResponse(200, t('Anonymous user sees published ad.'));
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($path);
$this
->assertResponse(200, t('Ads administrator sees published ad.'));
$this
->drupalLogin($this->basicUser);
$this
->drupalGet($path);
$this
->assertResponse(200, t('Non-author user sees published ad.'));
$this
->drupalLogin($this->creatorUser);
$this
->drupalGet($path);
$this
->assertResponse(200, t('Author sees his published ad.'));
// 4a. Unpublish the ad.
$node->status = 0;
node_save($node);
// 4b. The ad is unpublished: only admin and creator should be able to see it.
$this
->drupalLogout();
$this
->drupalGet($path);
$this
->assertResponse(403, t('Anonymous user does not see unpublished ad.'));
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($path);
$this
->assertResponse(200, t('Ads administrator sees unpublished ad.'));
$this
->drupalLogin($this->basicUser);
$this
->drupalGet($path);
$this
->assertResponse(403, t('Non-author user does not see unpublished ad.'));
$this
->drupalLogin($this->creatorUser);
$this
->drupalGet($path);
$this
->assertResponse(200, t('Author sees his unpublished ad.'));
}