[vhffs-dev] [520] Removed old stuff from tests. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 520
Author: beuss
Date: 2007-03-21 08:44:31 +0000 (Wed, 21 Mar 2007)
Log Message:
-----------
Removed old stuff from tests.
Modified Paths:
--------------
branches/vhffs_4.1/Makefile
branches/vhffs_4.1/vhffs-tests/src/Group.pl
branches/vhffs_4.1/vhffs-tests/src/Object.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl
branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl
branches/vhffs_4.1/vhffs-tests/src/Stats.pl
branches/vhffs_4.1/vhffs-tests/src/User.pl
Modified: branches/vhffs_4.1/Makefile
===================================================================
--- branches/vhffs_4.1/Makefile 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/Makefile 2007-03-21 08:44:31 UTC (rev 520)
@@ -290,13 +290,11 @@
install -m 644 vhffs-panel/themes/vhffs-ng/js/*.js $(PANELDIR)/themes/vhffs-ng/js/
-test: test-object test-group test-user test-stats test-cvs test-web test-mail test-mysql test-functions
+test: test-object test-group test-user test-stats test-svn test-cvs test-web test-dns test-mail test-ml test-mysql test-pgsql test-functions test-repos
test-object:
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Object.pl");'
test-group:
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Group.pl");'
-test-dns:
- @perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/DNS.pl");'
test-user:
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/User.pl");'
test-stats:
@@ -307,10 +305,12 @@
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Cvs.pl");'
test-web:
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Httpd.pl");'
+test-dns:
+ @perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/DNS.pl");'
test-mail:
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Mail.pl");'
test-ml:
- @perl -I vhffs-tests/src/ -I vhffs-api/src/ vhffs-tests/src/Services/Mailing.pl
+ @perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Mailing.pl");'
test-mysql:
@perl -I vhffs-tests/src/ -I vhffs-api/src/ -e 'use Test::Harness; Test::Harness::runtests("vhffs-tests/src/Services/Mysql.pl");'
test-pgsql:
Modified: branches/vhffs_4.1/vhffs-tests/src/Group.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Group.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Group.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -12,40 +12,27 @@
Vhffs::Tests::Utils::init_db($main->get_db_object);
# We need an user as group moderator
-my $user1 = new Vhffs::User($main, 'testuser1', -1);
-my $uid = $user1->create;
+my $user1 = Vhffs::User::create($main, 'testuser1', 'abcdef');
+isa_ok($user1, 'Vhffs::User', '$user1');
# Some other users to add to group
-my $user2 = new Vhffs::User($main, 'testuser2', -1);
-$user2->create;
+my $user2 = Vhffs::User::create($main, 'testuser2', 'ghijk');
+isa_ok($user2, 'Vhffs::User', '$user2');
-my $group1 = new Vhffs::Group($main, 'testgroup1', $uid);
+my $group1 = Vhffs::Group::create($main, 'testgroup1', $user1->get_uid, undef, 'Test group 1');
isa_ok($group1, 'Vhffs::Group', $group1);
+cmp_ok($group1->get_groupname, 'eq', 'testgroup1', 'Groupname matches');
-my $gid1 = $group1->create;
-cmp_ok($gid1, '>', 0, 'group successfully created');
-
# Check for groupname uniqueness constraint
-my $group2 = new Vhffs::Group($main, 'testgroup1', 1);
-isa_ok($group2, 'Vhffs::Group', '$group2');
-
$main->get_db_object->{PrintError} = 0;
-my $gid2 = $group2->create;
+my $group2 = Vhffs::Group::create($main, 'testgroup1', $user1->get_uid, undef, 'Duplicate groupname');
$main->get_db_object->{PrintError} = 1;
-cmp_ok($gid2, '<=', 0, 'second group creation failed');
+ok(!defined $group2, 'Unable to create a second group with the same name');
-$group2->fetch;
-is_deeply($group2, $group1, 'Fetched group matches created group');
+my $group1a = Vhffs::Group::get_by_gid($main, $group1->get_gid);
+is_deeply($group1a, $group1, 'Fetched group matches created one');
-my $group2a = Vhffs::Group::get_by_gid($main, $group2->get_gid);
-is_deeply($group2a, $group2, 'New fashion of fetching group is OK');
-
ok($group1->is_user_in_group($user1), 'Moderator is in group');
-ok($group2->add_user( $user2 ), 'Other user can be added');
+ok($group1a->add_user( $user2 ), 'Other user can be added');
ok($group1->is_user_in_group($user2), 'Second user addition visible in group1');
ok($group1->remove_user($user2), 'Second user removed from group1');
-my $group3 = Vhffs::Group::create($main, 'fashion1', $user1->get_uid);
-isa_ok($group3, 'Vhffs::Group', '$group3');
-cmp_ok($group3->get_gid, '>', 0, 'New way of creating groups produces correct GID');
-cmp_ok($group3->get_groupname, 'eq', 'fashion1', 'New way of creating group keep groupname');
-
Modified: branches/vhffs_4.1/vhffs-tests/src/Object.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Object.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Object.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -10,29 +10,15 @@
my $owner1 = Vhffs::User::create($main, 'test1', '123');
isa_ok($owner1, 'Vhffs::User', 'user1');
-my $uid1 = $owner1->get_uid;
-cmp_ok($uid1, '>', 0, 'First user creation');
-ok($owner1->exists, 'First user exists');
-
-my $obj1 = new Vhffs::Object($main, 1, $owner1->get_uid);
+my $obj1 = Vhffs::Object::create($main, $owner1->get_uid, 'Test object 1');
isa_ok($obj1, 'Vhffs::Object', '$obj1');
+cmp_ok($obj1->get_description, 'eq', 'Test object 1');
-my $oid1 = $obj1->create;
-cmp_ok($oid1, '>', 0, 'Object created');
-
-my $obj2 = new Vhffs::Object($main, $oid1, -1);
+my $obj2 = Vhffs::Object::get_by_oid($main, $obj1->get_oid);
isa_ok($obj2, 'Vhffs::Object', '$obj2');
-cmp_ok($obj2->fetch, '>', 0, 'Object fetched');
-
is_deeply($obj1, $obj2, 'Fetched object matches created object');
-my $obj2b = Vhffs::Object::get_by_oid($main, $oid1);
-is_deeply($obj2b, $obj2);
my $history = $obj1->get_history;
is(scalar(keys %{$history}), 1, 'One history entry');
-
-my $obj3 = Vhffs::Object::create($main, undef, 'A new fashion object');
-isa_ok($obj3, 'Vhffs::Object', '$obj3');
-cmp_ok($obj3->get_description, 'eq', 'A new fashion object', 'Description matches');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Cvs.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -29,11 +29,10 @@
cmp_ok(scalar(@cvses), '==', 1);
is_deeply($cvses[0], $cvs1);
-ok(!defined(Vhffs::Services::Cvs::getall($main, Vhffs::Constants::ACTIVATED)), 'No ACTIVATED CVS repo');
+cmp_ok(@{Vhffs::Services::Cvs::getall($main, Vhffs::Constants::ACTIVATED)}, '==', 0, 'No ACTIVATED CVS repo');
@cvses = @{Vhffs::Services::Cvs::getall_per_group($main, $group1)};
-cmp_ok(scalar(@cvses), '==', 1);
+cmp_ok(@cvses, '==', 1);
is_deeply($cvses[0], $cvs1);
-# FIXME THIS ISN'T COHERENT, FOR get_all WE GOT AN UNDEFINED VALUE AND HERE A ZERO LENGTH ARRAY
-cmp_ok(scalar(@{Vhffs::Services::Cvs::getall_per_group($main, $group2)}), '==', 0, 'No CVS repo for group2');
+cmp_ok(@{Vhffs::Services::Cvs::getall_per_group($main, $group2)}, '==', 0, 'No CVS repo for group2');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Httpd.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -29,13 +29,13 @@
cmp_ok(scalar(@webs), '==', 1);
is_deeply($webs[0], $web1);
-ok(!defined(Vhffs::Services::Httpd::getall($main, Vhffs::Constants::ACTIVATED)), 'No ACTIVATED webarea repo');
+cmp_ok(@{Vhffs::Services::Httpd::getall($main, Vhffs::Constants::ACTIVATED)}, '==', 0, 'No ACTIVATED webarea repo');
@webs = @{Vhffs::Services::Httpd::getall_by_group($main, $group1)};
cmp_ok(scalar(@webs), '==', 1);
is_deeply($webs[0], $web1);
-ok(!defined(Vhffs::Services::Httpd::getall_by_group($main, $group2)), 'No webarea repo for group2');
+cmp_ok(@{Vhffs::Services::Httpd::getall_by_group($main, $group2)}, '==', 0, 'No webarea repo for group2');
@webs = @{Vhffs::Services::Httpd::getall_by_letter($main, 't')};
cmp_ok(scalar(@webs), '==', 1);
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Mail.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -10,7 +10,6 @@
isa_ok($main, 'Vhffs::Tests::Main', '$main');
Vhffs::Tests::Utils::init_db($main->get_db_object);
-
my $user1 = Vhffs::User::create($main, 'test1', 'abcdef', 0, 'test1@xxxxxxxx');
isa_ok($user1, 'Vhffs::User', '$user1');
@@ -24,7 +23,7 @@
$mail1->addforward('forward1', 'test@xxxxxxxx');
my $forwards = $mail1->get_forwards;
-cmp_ok(scalar(%$forwards), '==', '1', 'Forward added');
+cmp_ok(keys(%$forwards), '==', '1', 'Forward added');
ok(defined $forwards->{forward1}, 'Forward name ok');
cmp_ok($forwards->{forward1}{local_part}, 'eq', 'forward1', 'Forward local part OK');
cmp_ok($forwards->{forward1}{domain}, 'eq', 'test.com', 'Domain name propagated');
@@ -32,7 +31,7 @@
$mail1->addbox('box1', 'dummy');
my $boxes = $mail1->get_boxes;
-cmp_ok(scalar(%$boxes), '==', '1', 'Box added');
+cmp_ok(keys(%$boxes), '==', '1', 'Box added');
cmp_ok($boxes->{box1}{local_part}, 'eq', 'box1', 'Local part OK');
cmp_ok($boxes->{box1}{domain}, 'eq', 'test.com', 'Domain name propagated');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Mysql.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -30,5 +30,5 @@
cmp_ok(scalar(@mysqles), '==', 1, 'Total : 1 MySQL Service');
is_deeply($mysqles[0], $mysql1, 'getall return correct MySQL objects');
-ok(!defined(Vhffs::Services::Mysql::getall($main, Vhffs::Constants::ACTIVATED)), 'No ACTIVATED mysql DB');
+cmp_ok(@{Vhffs::Services::Mysql::getall($main, Vhffs::Constants::ACTIVATED)}, '==', 0, 'No ACTIVATED mysql DB');
Modified: branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Services/Postgres.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -30,5 +30,5 @@
cmp_ok(scalar(@postgreses), '==', 1, 'Total : 1 Postgres Service');
is_deeply($postgreses[0], $postgres1, 'getall return correct Postgres objects');
-ok(!defined(Vhffs::Services::Postgres::getall($main, Vhffs::Constants::ACTIVATED)), 'No ACTIVATED Postgres DB');
+cmp_ok(@{Vhffs::Services::Postgres::getall($main, Vhffs::Constants::ACTIVATED)}, '==', 0, 'No ACTIVATED Postgres DB');
Modified: branches/vhffs_4.1/vhffs-tests/src/Stats.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/Stats.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/Stats.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -63,7 +63,7 @@
$group = Vhffs::Group::get_by_groupname($main, "testgroup0$i");
$group->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$group->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh;
is($stats->get_groups_in_moderation, 9 - $i, (9 - $i).' groups are still waiting for moderation');
is($stats->get_groups_activated, 0, 'Groups are waiting for creation, not yet activated');
}
@@ -72,7 +72,7 @@
$group = Vhffs::Group::get_by_groupname($main, "testgroup0$i");
$group->set_status(Vhffs::Constants::ACTIVATED);
$group->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_groups_activated, $i, $i > 1 ? "$i groups are activated" : '1 group is activated');
}
@@ -84,13 +84,13 @@
$svc = Vhffs::Services::Httpd::create($main, "httpd0$i.test.com", '', $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_web_in_moderation, 9, 'All httpd services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::Httpd::get_by_servername($main, "httpd0$i.test.com");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_web_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' httpd service waiting for moderation' : ' httpd services waiting for moderation'));
is($stats->get_web_activated, 0, 'No httpd service activated');
}
@@ -99,7 +99,7 @@
$svc = Vhffs::Services::Httpd::get_by_servername($main, "httpd0$i.test.com");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_web_activated, $i, $i > 1 ? "$i httpd services activated" : "$i httpd service activated");
}
@@ -111,14 +111,14 @@
Vhffs::Services::Cvs::create($main, "testcvs0$i", '', $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_cvs_in_moderation, 9, 'All cvs services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::Cvs::get_by_cvsroot($main, "testcvs0$i");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_cvs_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' cvs service waiting for moderation' : ' cvs services waiting for moderation'));
is($stats->get_cvs_activated, 0, 'No httpd service activated');
}
@@ -127,7 +127,7 @@
$svc = Vhffs::Services::Cvs::get_by_cvsroot($main, "testcvs0$i");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_cvs_activated, $i, $i > 1 ? "$i cvs services activated" : "$i cvs service activated");
}
@@ -139,13 +139,13 @@
$svc = Vhffs::Services::DNS::create($main, "dns0$i.test.com", "Stats domain #$i", $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_dns_in_moderation, 9, 'All DNS services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::DNS::get_by_domainname($main, "dns0$i.test.com");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_dns_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' DNS service waiting for moderation' : ' DNS services waiting for moderation'));
is($stats->get_dns_activated, 0, 'No DNS service activated');
}
@@ -154,7 +154,7 @@
$svc = Vhffs::Services::DNS::get_by_domainname($main, "dns0$i.test.com");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_dns_activated, $i, $i > 1 ? "$i DNS services activated" : "$i DNS service activated");
}
@@ -166,13 +166,13 @@
$svc = Vhffs::Services::Mysql::create($main, "mysqltest0$i", "mysqltest0$i", 'abcdef', "Mysql test DB #0$i", $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_mysql_in_moderation, 9, 'All MySQL services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::Mysql::get_by_dbname($main, "mysqltest0$i");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_mysql_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' MySQL service waiting for moderation' : ' MySQL services waiting for moderation'));
is($stats->get_mysql_activated, 0, 'No MySQL service activated');
}
@@ -181,7 +181,7 @@
$svc = Vhffs::Services::Mysql::get_by_dbname($main, "mysqltest0$i");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_mysql_activated, $i, $i > 1 ? "$i MySQL services activated" : "$i MySQL service activated");
}
@@ -193,13 +193,13 @@
$svc = Vhffs::Services::Postgres::create($main, "pgsqltest0$i", "pgsqlu0$i", 'abcdef', "MySQL test DB #0$i", $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_pgsql_in_moderation, 9, 'All PostgreSQL services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::Postgres::get_by_dbname($main, "pgsqltest0$i");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_pgsql_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' PostgreSQL service waiting for moderation' : ' PostgreSQL services waiting for moderation'));
is($stats->get_pgsql_activated, 0, 'No PostgreSQL service activated');
}
@@ -208,7 +208,7 @@
$svc = Vhffs::Services::Postgres::get_by_dbname($main, "pgsqltest0$i");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_pgsql_activated, $i, $i > 1 ? "$i PostgreSQL services activated" : "$i PostgreSQL service activated");
}
@@ -220,14 +220,14 @@
$svc = Vhffs::Services::Svn::create($main, "svntest0$i", "SVN #$i for stats tests", $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_svn_in_moderation, 9, 'All SVN services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$group = Vhffs::Group::get_by_groupname($main, "testgroup0$i");
$svc = Vhffs::Services::Svn::get_by_reponame($main, "svntest0$i");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_svn_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' SVN service waiting for moderation' : ' SVN services waiting for moderation'));
is($stats->get_svn_activated, 0, 'No SVN service activated');
}
@@ -237,7 +237,7 @@
$svc = Vhffs::Services::Svn::get_by_reponame($main, "svntest0$i");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_svn_activated, $i, $i > 1 ? "$i SVN services activated" : "$i SVN service activated");
}
@@ -249,13 +249,13 @@
$svc = Vhffs::Services::Mail::create($main, "mail0$i.test.com", "Mail domain #$i for stats' tests", $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_mail_in_moderation, 9, 'All Mail services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::Mail::get_by_mxdomain($main, "mail0$i.test.com");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_mail_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' Mail service waiting for moderation' : ' Mail services waiting for moderation'));
is($stats->get_mail_activated, 0, 'No Mail service activated');
}
@@ -264,7 +264,7 @@
$svc = Vhffs::Services::Mail::get_by_mxdomain($main, "mail0$i.test.com");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_mail_activated, $i, $i > 1 ? "$i Mail services activated" : "$i Mail service activated");
}
@@ -278,7 +278,7 @@
$svc->commit;
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_mail_total_boxes, 90, 'All mboxes created');
@@ -292,7 +292,7 @@
$svc->commit;
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_mail_total_forwards, 90, 'All forwards created');
@@ -304,14 +304,14 @@
$svc = Vhffs::Services::Mailing::create($main, "ml", "mail0$i.test.com", undef, "Test list #$i", $user, $group);
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_lists_in_moderation, 9, 'All Mailing Lists services waiting for moderation');
for(my $i = 1 ; $i < 10 ; ++$i) {
$svc = Vhffs::Services::Mailing::get_by_mladdress($main, "ml", "mail0$i.test.com");
$svc->set_status(Vhffs::Constants::WAITING_FOR_CREATION);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_lists_in_moderation, 9 - $i, (9 - $i).($i >= 8 ? ' Mailing List service waiting for moderation' : ' Mailing List services waiting for moderation'));
is($stats->get_lists_activated, 0, 'No Mailing List service activated');
}
@@ -320,7 +320,7 @@
$svc = Vhffs::Services::Mailing::get_by_mladdress($main, "ml", "mail0$i.test.com");
$svc->set_status(Vhffs::Constants::ACTIVATED);
$svc->commit;
- $stats = new Vhffs::Stats($main);
+ $stats->refresh();
is($stats->get_lists_activated, $i, $i > 1 ? "$i Mailing List services activated" : "$i Mailing List service activated");
}
@@ -334,6 +334,6 @@
$svc->commit;
}
-$stats = new Vhffs::Stats($main);
+$stats->refresh();
is($stats->get_lists_totalsubs, 90, 'All subscribers registered');
Modified: branches/vhffs_4.1/vhffs-tests/src/User.pl
===================================================================
--- branches/vhffs_4.1/vhffs-tests/src/User.pl 2007-03-20 22:57:50 UTC (rev 519)
+++ branches/vhffs_4.1/vhffs-tests/src/User.pl 2007-03-21 08:44:31 UTC (rev 520)
@@ -11,6 +11,8 @@
my $user1 = Vhffs::User::create($main, 'test1', 'abcdef', 0, 'test1@xxxxxxxx');
isa_ok($user1, 'Vhffs::User', '$user1');
+cmp_ok($user1->get_username, 'eq', 'test1', 'Username matches');
+cmp_ok($user1->get_mail, 'eq', 'test1@xxxxxxxx', 'Email matches');
my $uid1 = $user1->get_uid;
ok($user1->exists, 'First user exists');
@@ -19,23 +21,16 @@
my $user2 = Vhffs::User::create($main, 'test2', 'abcdef', 0, 'test2@xxxxxxxx');
isa_ok($user2, 'Vhffs::User', '$user2');
-$user2 = new Vhffs::User($main, 'test1', 401);
-cmp_ok($user2->exists, '>', 0, 'User test1 exists');
$main->get_db_object->{PrintError} = 0;
-my $uid2 = $user2->create;
+ok(!defined Vhffs::User::create($main, 'test2', 'dummy', 1, 'another@xxxxxxxxx'), 'Unable to create duplicate user');
$main->get_db_object->{PrintError} = 1;
-cmp_ok($uid2, '<=', 0, 'User test1 can\'t be created twice');
-my $user3 = Vhffs::User::get_by_uid($main, $uid1);
-cmp_ok($user3->get_uid, '==', $uid1, 'Fetched UID matches');
-
+my $user3 = Vhffs::User::get_by_uid($main, $user1->get_uid);
is_deeply($user3, $user1, 'Fetched user is a copy of original');
-my $user3a = Vhffs::User::get_by_uid($main, $uid1);
-is_deeply($user3a, $user3, 'New fashion of fetching users');
$user3->set_admin(1);
cmp_ok($user3->commit, '>', 0, 'Third user\'s modifications committed');
-$user1->fetch;
+$user1 = Vhffs::User::get_by_uid($main, $user1->get_uid);
ok($user1->is_admin, 'Admin propertie propagated');
# Group stuff
@@ -57,7 +52,9 @@
# An user can't have the name if a group, AND it should
# be a 'all or nothing' process, that is no user is half
# created
+$main->get_db_object->{PrintError} = 0;
my $user4 = Vhffs::User::create($main, 'test1group1', 'abcdef');
+$main->get_db_object->{PrintError} = 1;
ok(!defined $user4, 'Unable to create an user with an existing groupname as username');
-$user4 = new Vhffs::User($main, 'test1group1', 401);
-cmp_ok($user4->fetch, '<', 0, 'User doesn\'t exists');
+$user4 = Vhffs::User::get_by_username($main, 'test1group1');
+ok(!defined $user4, 'User doesn\'t exists');