Skip to content

Commit

Permalink
[ticket/10411] Test for thrown exceptions when group does not exist
Browse files Browse the repository at this point in the history
PHPBB3-10411
  • Loading branch information
nickvergessen committed Feb 26, 2013
1 parent 9e70f7a commit 1261583
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions tests/groupposition/legend_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ public function getDataSet()
public function get_group_value_data()
{
return array(
array(1, 0),
array(3, 2),
array(1, 0, ''),
array(3, 2, ''),
array(4, 0, 'phpbb_groupposition_exception'),
);
}

/**
* @dataProvider get_group_value_data
*/
public function test_get_group_value($group_id, $expected)
public function test_get_group_value($group_id, $expected, $throws_exception)
{
global $cache;

Expand All @@ -35,6 +36,11 @@ public function test_get_group_value($group_id, $expected)
$user = new phpbb_user;
$user->lang = array();

if ($throws_exception)
{
$this->setExpectedException($throws_exception);
}

$test_class = new phpbb_groupposition_legend($db, $user);
$this->assertEquals($expected, $test_class->get_group_value($group_id));
}
Expand Down
12 changes: 9 additions & 3 deletions tests/groupposition/teampage_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ public function getDataSet()
public function get_group_value_data()
{
return array(
array(2, 3),
array(6, 8),
array(2, 3, ''),
array(6, 8, ''),
array(10, 0, 'phpbb_groupposition_exception'),
);
}

/**
* @dataProvider get_group_value_data
*/
public function test_get_group_value($group_id, $expected)
public function test_get_group_value($group_id, $expected, $throws_exception)
{
global $cache;

Expand All @@ -37,6 +38,11 @@ public function test_get_group_value($group_id, $expected)
$user = new phpbb_user;
$user->lang = array();

if ($throws_exception)
{
$this->setExpectedException($throws_exception);
}

$test_class = new phpbb_groupposition_teampage($db, $user, $cache);
$this->assertEquals($expected, $test_class->get_group_value($group_id));
}
Expand Down

0 comments on commit 1261583

Please sign in to comment.