aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/visibility_softdelete_test.php
diff options
context:
space:
mode:
authorOliver Schramm <oliver.schramm97@gmail.com>2015-03-22 17:59:27 +0100
committerOliver Schramm <oliver.schramm97@gmail.com>2015-03-22 21:30:05 +0100
commiteca0128d0a4affb717294c905c866ef96be6a96f (patch)
tree846bf9adfe21b7b75430be79417e8e90b97d82c8 /tests/functional/visibility_softdelete_test.php
parent53169b1303d3b9be66c6b67ab031060c41a1280f (diff)
downloadforums-eca0128d0a4affb717294c905c866ef96be6a96f.tar
forums-eca0128d0a4affb717294c905c866ef96be6a96f.tar.gz
forums-eca0128d0a4affb717294c905c866ef96be6a96f.tar.bz2
forums-eca0128d0a4affb717294c905c866ef96be6a96f.tar.xz
forums-eca0128d0a4affb717294c905c866ef96be6a96f.zip
[ticket/13469] Add tests
PHPBB3-13469
Diffstat (limited to 'tests/functional/visibility_softdelete_test.php')
-rw-r--r--tests/functional/visibility_softdelete_test.php107
1 files changed, 86 insertions, 21 deletions
diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php
index 794f0cde68..4aaf240bdd 100644
--- a/tests/functional/visibility_softdelete_test.php
+++ b/tests/functional/visibility_softdelete_test.php
@@ -42,6 +42,19 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_perm_from' => 2,
));
$crawler = self::submit($form);
+
+ // Create second user which does not have m_delete permission
+ $this->add_lang('acp/permissions');
+
+ $second_user = $this->create_user('no m_delete moderator');
+ $this->add_user_group("GLOBAL_MODERATORS", 'no m_delete moderator', true);
+
+ // Set m_delete to never
+ $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&user_id[0]=$second_user&type=m_&sid={$this->sid}");
+ $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
+ $data = array("setting[$second_user][0][m_delete]" => ACL_NEVER);
+ $form->setValues($data);
+ $crawler = self::submit($form);
}
public function test_create_post()
@@ -98,6 +111,23 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'],
), 'after replying');
+
+ // Test creating another reply
+ $post3 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#3', 'This is another test post posted by the testing framework.');
+ $crawler = self::request('GET', "viewtopic.php?t={$post3['topic_id']}&sid={$this->sid}");
+
+ $this->assertContains('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text());
+ $this->data['posts']['Re: Soft Delete Topic #1-#3'] = (int) $post3['post_id'];
+
+ $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
+ 'forum_posts_approved' => 3,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#3'],
+ ), 'after replying a second time');
}
public function test_softdelete_post()
@@ -114,21 +144,22 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3',
),
));
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
- 'forum_posts_approved' => 2,
+ 'forum_posts_approved' => 3,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 0,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
- 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'],
+ 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#3'],
), 'before softdelete');
$this->add_lang('posting');
- $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Soft Delete #1']}&p={$this->data['posts']['Re: Soft Delete Topic #1-#2']}&sid={$this->sid}");
+ $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Soft Delete #1']}&p={$this->data['posts']['Re: Soft Delete Topic #1-#3']}&sid={$this->sid}");
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$form = $crawler->selectButton('Yes')->form();
@@ -136,17 +167,43 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('POST_DELETED', $crawler->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
- 'forum_posts_approved' => 1,
+ 'forum_posts_approved' => 2,
'forum_posts_unapproved' => 0,
'forum_posts_softdeleted' => 1,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'],
+ ), 'after softdelete');
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
+ $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+
+ $this->logout();
+ // Delete second post as moderator without m_delete permission
+ $this->login('no m_delete moderator');
+
+ $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Soft Delete #1']}&p={$this->data['posts']['Re: Soft Delete Topic #1-#2']}&sid={$this->sid}");
+ $this->assertNotContainsLang('DELETE_PERMANENTLY', $crawler->text());
+
+ $form = $crawler->selectButton('Yes')->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('POST_DELETED', $crawler->text());
+
+ $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 2,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
), 'after softdelete');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
$this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+
+ $this->logout();
}
public function test_move_softdeleted_post()
@@ -163,13 +220,14 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3',
),
));
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -212,7 +270,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -234,6 +292,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
@@ -250,7 +309,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -283,7 +342,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 2,
+ 'forum_posts_softdeleted' => 3,
'forum_topics_approved' => 0,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 1,
@@ -305,6 +364,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
@@ -321,7 +381,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 2,
+ 'forum_posts_softdeleted' => 3,
'forum_topics_approved' => 0,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 1,
@@ -344,7 +404,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 2,
+ 'forum_posts_softdeleted' => 3,
'forum_topics_approved' => 0,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 1,
@@ -376,13 +436,14 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 0,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 2,
+ 'forum_posts_softdeleted' => 3,
'forum_topics_approved' => 0,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 1,
@@ -417,7 +478,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -449,13 +510,14 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -495,7 +557,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 0,
+ 'forum_posts_softdeleted' => 1,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -528,6 +590,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
@@ -539,7 +602,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 1,
@@ -562,13 +625,14 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 1,
@@ -603,7 +667,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -625,13 +689,14 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'posts' => array(
'Soft Delete Topic #1',
'Re: Soft Delete Topic #1-#2',
+ 'Re: Soft Delete Topic #1-#3'
),
));
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -660,7 +725,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
@@ -670,11 +735,11 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
'forum_posts_approved' => 1,
'forum_posts_unapproved' => 0,
- 'forum_posts_softdeleted' => 1,
+ 'forum_posts_softdeleted' => 2,
'forum_topics_approved' => 1,
'forum_topics_unapproved' => 0,
'forum_topics_softdeleted' => 0,
- 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'] + 2,
+ 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'] + 3,
), 'after forking #2');
}