diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-04-13 18:03:02 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-04-13 18:03:02 +0200 |
commit | cbfe866eba5b2a7bb9f141e5145292dbef135e78 (patch) | |
tree | 27c40663f279016eda6095be769a4b7197c83a40 | |
parent | 5c24474c2a85d159d2b76d4483c62ab1e9861222 (diff) | |
download | forums-cbfe866eba5b2a7bb9f141e5145292dbef135e78.tar forums-cbfe866eba5b2a7bb9f141e5145292dbef135e78.tar.gz forums-cbfe866eba5b2a7bb9f141e5145292dbef135e78.tar.bz2 forums-cbfe866eba5b2a7bb9f141e5145292dbef135e78.tar.xz forums-cbfe866eba5b2a7bb9f141e5145292dbef135e78.zip |
[ticket/11494] Use functions instead of repeating
PHPBB3-11494
-rw-r--r-- | tests/functional/memberlist_test.php | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/tests/functional/memberlist_test.php b/tests/functional/memberlist_test.php index 2e3d7907bf..0065147d11 100644 --- a/tests/functional/memberlist_test.php +++ b/tests/functional/memberlist_test.php @@ -41,25 +41,37 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case $this->assertContains('admin', $crawler->filter('h2')->text()); } + protected function get_memberlist_leaders_crawler() + { + $crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid); + $this->assert_response_success(); + + return $crawler; + } + + protected function get_crawler_table_text($crawler, $table) + { + return $crawler->filter('.forumbg-table')->eq($table)->text(); + } + public function test_leaders() { $this->login(); $this->create_user('memberlist-test-moderator'); - $crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid); - $this->assert_response_success(); + $crawler = $this->get_memberlist_leaders_crawler(); // Admin in admin group, but not in moderators - $this->assertContains('admin', $crawler->filter('.forumbg-table')->eq(0)->text()); - $this->assertNotContains('admin', $crawler->filter('.forumbg-table')->eq(1)->text()); + $this->assertContains('admin', $this->get_crawler_table_text($crawler, 0)); + $this->assertNotContains('admin', $this->get_crawler_table_text($crawler, 1)); // memberlist-test-user in neither group - $this->assertNotContains('memberlist-test-user', $crawler->filter('.forumbg-table')->eq(0)->text()); - $this->assertNotContains('memberlist-test-user', $crawler->filter('.forumbg-table')->eq(1)->text()); + $this->assertNotContains('memberlist-test-user', $this->get_crawler_table_text($crawler, 0)); + $this->assertNotContains('memberlist-test-user', $this->get_crawler_table_text($crawler, 1)); // memberlist-test-moderator in neither group - $this->assertNotContains('memberlist-test-moderator', $crawler->filter('.forumbg-table')->eq(0)->text()); - $this->assertNotContains('memberlist-test-moderator', $crawler->filter('.forumbg-table')->eq(1)->text()); + $this->assertNotContains('memberlist-test-moderator', $this->get_crawler_table_text($crawler, 0)); + $this->assertNotContains('memberlist-test-moderator', $this->get_crawler_table_text($crawler, 1)); } public function test_leaders_remove_users() @@ -68,16 +80,15 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case // Remove admin from admins, but is now in moderators $this->remove_user_group('ADMINISTRATORS', array('admin')); - $crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid); - $this->assert_response_success(); - $this->assertNotContains('admin', $crawler->filter('.forumbg-table')->eq(0)->text()); - $this->assertContains('admin', $crawler->filter('.forumbg-table')->eq(1)->text()); + $crawler = $this->get_memberlist_leaders_crawler(); + $this->assertNotContains('admin', $this->get_crawler_table_text($crawler, 0)); + $this->assertContains('admin', $this->get_crawler_table_text($crawler, 1)); // Remove admin from moderators, should not be visible anymore $this->remove_user_group('GLOBAL_MODERATORS', array('admin')); - $crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid); - $this->assertNotContains('admin', $crawler->filter('.forumbg-table')->eq(0)->text()); - $this->assertNotContains('admin', $crawler->filter('.forumbg-table')->eq(1)->text()); + $crawler = $this->get_memberlist_leaders_crawler(); + $this->assertNotContains('admin', $this->get_crawler_table_text($crawler, 0)); + $this->assertNotContains('admin', $this->get_crawler_table_text($crawler, 1)); } public function test_leaders_add_users() @@ -86,9 +97,8 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case // Add memberlist-test-moderator to moderators $this->add_user_group('GLOBAL_MODERATORS', array('memberlist-test-moderator')); - $crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid); - $this->assert_response_success(); - $this->assertNotContains('memberlist-test-moderator', $crawler->filter('.forumbg-table')->eq(0)->text()); - $this->assertContains('memberlist-test-moderator', $crawler->filter('.forumbg-table')->eq(1)->text()); + $crawler = $this->get_memberlist_leaders_crawler(); + $this->assertNotContains('memberlist-test-moderator', $this->get_crawler_table_text($crawler, 0)); + $this->assertContains('memberlist-test-moderator', $this->get_crawler_table_text($crawler, 1)); } } |