aboutsummaryrefslogtreecommitdiffstats
path: root/tests/user
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-12-08 13:41:44 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2012-12-08 13:41:44 -0600
commit6b7443adacfa8e79304e4c91ca02000d25259633 (patch)
tree19c51b8b96a43f99b01e7c953c628066e33d1e80 /tests/user
parentb91ba8d5f1c05bc285e3f3b24fc5ffd50f6ee3ed (diff)
downloadforums-6b7443adacfa8e79304e4c91ca02000d25259633.tar
forums-6b7443adacfa8e79304e4c91ca02000d25259633.tar.gz
forums-6b7443adacfa8e79304e4c91ca02000d25259633.tar.bz2
forums-6b7443adacfa8e79304e4c91ca02000d25259633.tar.xz
forums-6b7443adacfa8e79304e4c91ca02000d25259633.zip
[ticket/11103] User loader test.bat
PHPBB3-11103
Diffstat (limited to 'tests/user')
-rw-r--r--tests/user/fixtures/user_loader.xml23
-rw-r--r--tests/user/user_loader.php48
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/user/fixtures/user_loader.xml b/tests/user/fixtures/user_loader.xml
new file mode 100644
index 0000000000..737376f326
--- /dev/null
+++ b/tests/user/fixtures/user_loader.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username</column>
+ <column>username_clean</column>
+ <row>
+ <value>1</value>
+ <value>Guest</value>
+ <value>guest</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>Admin</value>
+ <value>admin</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>Test</value>
+ <value>test</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/user/user_loader.php b/tests/user/user_loader.php
new file mode 100644
index 0000000000..145bfc9549
--- /dev/null
+++ b/tests/user/user_loader.php
@@ -0,0 +1,48 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_user_lang_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/user_loader.xml');
+ }
+
+ public function test_user_loader()
+ {
+ $db = $this->new_dbal();
+
+ $user_loader = new phpbb_user_loader($db, __DIR__ . '../../phpBB', 'php', 'phpbb_users');
+
+ $user_loader->load_users(array(2));
+
+ $user = $user_loader->get_user(1);
+ $this->assertEquals(1, $user['user_id']);
+ $this->assertEquals('Guest', $user['username']);
+
+ $user = $user_loader->get_user(2);
+ $this->assertEquals(2, $user['user_id']);
+ $this->assertEquals('Admin', $user['username']);
+
+ // Not loaded
+ $user = $user_loader->get_user(3);
+ $this->assertEquals(1, $user['user_id']);
+ $this->assertEquals('Guest', $user['username']);
+
+ $user_loader->load_users(array(3));
+
+ $user = $user_loader->get_user(2);
+ $this->assertEquals(2, $user['user_id']);
+ $this->assertEquals('Admin', $user['username']);
+
+ $user = $user_loader->get_user(3);
+ $this->assertEquals(3, $user['user_id']);
+ $this->assertEquals('Test', $user['username']);
+ }
+}