aboutsummaryrefslogtreecommitdiffstats
path: root/tests/avatar
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-01-08 21:58:03 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-01-08 21:58:03 +0100
commitcaa3516d134360c86b00c3f8104f3ac7157b0e47 (patch)
tree1d5aaf8945652686f449210d58f895384032b93d /tests/avatar
parentcb08bf3c0cac1f15ae46238a00a56ff7bf72efda (diff)
downloadforums-caa3516d134360c86b00c3f8104f3ac7157b0e47.tar
forums-caa3516d134360c86b00c3f8104f3ac7157b0e47.tar.gz
forums-caa3516d134360c86b00c3f8104f3ac7157b0e47.tar.bz2
forums-caa3516d134360c86b00c3f8104f3ac7157b0e47.tar.xz
forums-caa3516d134360c86b00c3f8104f3ac7157b0e47.zip
[feature/avatars] Differentiate tests for get drivers functions
Tests for get_all_drivers() and get_enabled_drivers() should be different. PHPBB3-10018
Diffstat (limited to 'tests/avatar')
-rw-r--r--tests/avatar/driver/barfoo.php19
-rw-r--r--tests/avatar/manager_test.php13
2 files changed, 31 insertions, 1 deletions
diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php
new file mode 100644
index 0000000000..936b6e0559
--- /dev/null
+++ b/tests/avatar/driver/barfoo.php
@@ -0,0 +1,19 @@
+<?php
+
+class phpbb_avatar_driver_barfoo extends phpbb_avatar_driver
+{
+ public function get_data($row)
+ {
+ return array();
+ }
+
+ public function prepare_form($request, $template, $row, &$error)
+ {
+ return false;
+ }
+
+ public function process_form($request, $template, $row, &$error)
+ {
+ return false;
+ }
+}
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index fd7132ea82..f01ea47c25 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -26,12 +26,20 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
$config = new phpbb_config(array());
$request = $this->getMock('phpbb_request');
$cache = $this->getMock('phpbb_cache_driver_interface');
+
$this->avatar_foobar = $this->getMock('phpbb_avatar_driver_foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache));
$this->avatar_foobar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.foobar'));
- $avatar_drivers = array($this->avatar_foobar);
+ $this->avatar_barfoo = $this->getMock('phpbb_avatar_driver_barfoo', array('get_name'));
+ $this->avatar_barfoo->expects($this->any())
+ ->method('get_name')
+ ->will($this->returnValue('avatar.driver.barfoo'));
+
+ $avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo);
+
$config['allow_avatar_' . get_class($this->avatar_foobar)] = true;
+ $config['allow_avatar_' . get_class($this->avatar_barfoo)] = false;
// Set up avatar manager
$this->manager = new phpbb_avatar_manager($config, $avatar_drivers, $this->phpbb_container);
@@ -56,13 +64,16 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
{
$drivers = $this->manager->get_all_drivers();
$this->assertArrayHasKey('avatar.driver.foobar', $drivers);
+ $this->assertArrayHasKey('avatar.driver.barfoo', $drivers);
$this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
+ $this->assertEquals('avatar.driver.barfoo', $drivers['avatar.driver.barfoo']);
}
public function test_get_enabled_drivers()
{
$drivers = $this->manager->get_enabled_drivers();
$this->assertArrayHasKey('avatar.driver.foobar', $drivers);
+ $this->assertArrayNotHasKey('avatar.driver.barfoo', $drivers);
$this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
}