[Jifty-commit] r542 - in jifty/trunk: . t/TestApp/lib/TestApp/Model t/TestApp/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Feb 3 02:45:01 EST 2006


Author: kevinr
Date: Fri Feb  3 02:45:00 2006
New Revision: 542

Added:
   jifty/trunk/t/TestApp/lib/TestApp/Model/User.pm
   jifty/trunk/t/TestApp/t/00-load.t
   jifty/trunk/t/TestApp/t/00-model-User.t
   jifty/trunk/t/TestApp/t/00-prototype.t
   jifty/trunk/t/TestApp/t/01-config.t
   jifty/trunk/t/TestApp/t/01-trivial.t
   jifty/trunk/t/TestApp/testapp   (contents, props changed)
Modified:
   jifty/trunk/   (props changed)

Log:
 r10757 at RANDOM-THREE-NINETY-TWO:  kevinr | 2006-02-03 02:43:01 -0500
 * Added the remaining (very basic) TestApp tests.  I've now got a handle on how
 to do this, so some *real* tests should be forthcoming Real Soon Now.


Added: jifty/trunk/t/TestApp/lib/TestApp/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/lib/TestApp/Model/User.pm	Fri Feb  3 02:45:00 2006
@@ -0,0 +1,20 @@
+package TestApp::Model::User::Schema;
+use Jifty::DBI::Schema;
+
+# Your column definitions go here.  See L<Jifty::DBI::Schema> for
+# documentation about how to write column definitions.
+
+column 'name' =>
+  type is 'text',
+  is mandatory;
+column 'email' =>
+  type is 'text',
+  is mandatory;
+
+package TestApp::Model::User;
+use base qw/TestApp::Record/;
+
+# Your model-specific methods go here.
+
+1;
+

Added: jifty/trunk/t/TestApp/t/00-load.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/00-load.t	Fri Feb  3 02:45:00 2006
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 2;
+
+use_ok('Jifty::Everything');
+use_ok('Jifty::Test');

Added: jifty/trunk/t/TestApp/t/00-model-User.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/00-model-User.t	Fri Feb  3 02:45:00 2006
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the User model.
+
+=cut
+
+BEGIN {chdir "t/TestApp"}
+use lib '../../lib';
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('TestApp::Model::User');
+
+# Grab a system use
+my $system_user = TestApp::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = TestApp::Model::User->new(current_user => $system_user);
+my ($id) = $o->create( name => $$, email => $$ );
+ok($id, "User create returned success");
+ok($o->id, "New User has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create( name => $$, email => $$ );
+ok($o->id, "User create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection =  TestApp::Model::UserCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+

Added: jifty/trunk/t/TestApp/t/00-prototype.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/00-prototype.t	Fri Feb  3 02:45:00 2006
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+This is a template for your own tests. Copy it and modify it.
+
+=cut
+
+BEGIN {chdir "t/TestApp"}
+use lib '../../lib';
+use Jifty::Test tests => 1;
+
+ok(1, "Loaded the test script");
+1;
+

Added: jifty/trunk/t/TestApp/t/01-config.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/01-config.t	Fri Feb  3 02:45:00 2006
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+#use Jifty::Test tests => 3;
+use Jifty::Test tests => 2;
+
+is(Jifty->config->framework('ApplicationClass'), 'jifty');
+# is(Jifty->config->framework('LogConfig'), 't/btdttest.log4perl.conf');
+# Port is overridden by testconfig
+ok(Jifty->config->framework('Web')->{'Port'} >= 10000, "test nested config");
+
+
+1;
+
+

Added: jifty/trunk/t/TestApp/t/01-trivial.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/01-trivial.t	Fri Feb  3 02:45:00 2006
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+
+BEGIN {chdir "t/TestApp"}
+use lib '../../lib';
+use Jifty::Test tests => 6;
+use Jifty::Test::WWW::Mechanize;
+
+my $server  = Jifty::Test->make_server;
+
+isa_ok($server, 'Jifty::Server');
+
+my $URL     = $server->started_ok;
+my $mech    = Jifty::Test::WWW::Mechanize->new();
+
+use_ok('TestApp::Model::User');
+
+my $user = TestApp::Model::User->new();
+
+my ($id, $msg) = $user->create( name => $$, email => $$.'@example.com');
+
+ok($id, "Created a new user: ".$msg);
+is ($id, $user->id);
+is($user->name, $$);
+
+1;

Added: jifty/trunk/t/TestApp/testapp
==============================================================================
Binary file. No diff available.


More information about the Jifty-commit mailing list