[Cpan-forum-commit] rev 168 - in trunk: . t t/db t/lib/CPAN/Forum
svn at pti.co.il
svn at pti.co.il
Fri Aug 25 18:15:21 IDT 2006
Author: gabor
Date: 2006-08-25 18:15:20 +0300 (Fri, 25 Aug 2006)
New Revision: 168
Added:
trunk/t/db/
trunk/t/db/users.t
Modified:
trunk/
trunk/MANIFEST
trunk/t/lib/CPAN/Forum/Test.pm
Log:
add test of the users table and the appropriat class
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:10995
+ 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:10996
Modified: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST 2006-08-25 15:15:15 UTC (rev 167)
+++ trunk/MANIFEST 2006-08-25 15:15:20 UTC (rev 168)
@@ -25,6 +25,7 @@
t/02packages.details.txt
t/lib/CPAN/Forum/Test.pm
+t/db/users.t
t/mech/000-load.t
t/mech/001-users.t
t/mech/011-register.t
@@ -62,9 +63,9 @@
templates/message_in_thread.tmpl
templates/admin.tmpl
templates/admin_edit_user.tmpl
+templates/site_is_closed.tmpl
www/cgi/index.pl
www/robots.txt
www/style.css
-templates/site_is_closed.tmpl
Added: trunk/t/db/users.t
===================================================================
--- trunk/t/db/users.t 2006-08-25 15:15:15 UTC (rev 167)
+++ trunk/t/db/users.t 2006-08-25 15:15:20 UTC (rev 168)
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More;
+my $tests;
+plan tests => $tests;
+
+use lib qw(t/lib);
+use CPAN::Forum::Test;
+
+{
+ require_ok('CPAN::Forum::Users');
+ BEGIN { $tests += 1; }
+}
+
+CPAN::Forum::Test::setup_database();
+my @users = @CPAN::Forum::Test::users;
+
+CPAN::Forum::Test::init_db();
+{
+ my @db_users = CPAN::Forum::Users->retrieve_all;
+ is(@db_users, 1, 'one user');
+ is($db_users[0]->username, 'testadmin');
+
+ is(CPAN::Forum::Users->count_all(), 1);
+ BEGIN { $tests += 3; }
+}
+
+{
+ # add user
+ my $user = CPAN::Forum::Users->create({
+ username => $users[0]{username},
+ email => $users[0]{email},
+ });
+ isa_ok($user, 'CPAN::Forum::Users');
+
+ my @db_users = CPAN::Forum::Users->retrieve_all;
+ is(@db_users, 2);
+ is(CPAN::Forum::Users->count_all(), 2);
+ BEGIN { $tests += 3; }
+}
+
Modified: trunk/t/lib/CPAN/Forum/Test.pm
===================================================================
--- trunk/t/lib/CPAN/Forum/Test.pm 2006-08-25 15:15:15 UTC (rev 167)
+++ trunk/t/lib/CPAN/Forum/Test.pm 2006-08-25 15:15:20 UTC (rev 168)
@@ -23,6 +23,15 @@
chdir "..";
}
+sub init_db {
+ require CPAN::Forum::DBI;
+ CPAN::Forum::DBI->myinit(db_connect());
+}
+
+sub db_connect {
+ return "dbi:SQLite:$ROOT/db/forum.db";
+}
+
sub get_mech {
use Test::WWW::Mechanize::CGI;
my $w = Test::WWW::Mechanize::CGI->new;
@@ -33,7 +42,7 @@
TMPL_PATH => "templates",
PARAMS => {
ROOT => $ROOT,
- DB_CONNECT => "dbi:SQLite:$ROOT/db/forum.db"
+ DB_CONNECT => db_connect(),
},
);
$webapp->run();
@@ -45,6 +54,11 @@
return "http://cpanforum.local";
}
+sub register_user {
+ my ($id) = @_;
+
+}
+
1;
More information about the Cpan-forum-commit
mailing list