[Rt-commit] r3523 - in Jifty-DBI/trunk: . t
kevinr at bestpractical.com
kevinr at bestpractical.com
Mon Jul 25 00:06:51 EDT 2005
Author: kevinr
Date: Mon Jul 25 00:06:51 2005
New Revision: 3523
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/t/01basics.t
Jifty-DBI/trunk/t/01records.t
Jifty-DBI/trunk/t/01searches.t
Jifty-DBI/trunk/t/02records_object.t
Jifty-DBI/trunk/t/03rebless.t
Jifty-DBI/trunk/t/10schema.t
Jifty-DBI/trunk/t/11schema_records.t
Jifty-DBI/trunk/t/testmodels.pl
Jifty-DBI/trunk/t/utils.pl
Log:
r6621 at SAD-GIRL-IN-SNOW: kevinr | 2005-07-25 00:06:42 -0400
* Renamed (most of) the functions in the test suite that wanted renaming
(and probably a few that didn't).
Modified: Jifty-DBI/trunk/t/01basics.t
==============================================================================
--- Jifty-DBI/trunk/t/01basics.t (original)
+++ Jifty-DBI/trunk/t/01basics.t Mon Jul 25 00:06:51 2005
@@ -4,14 +4,14 @@
use Test::More;
BEGIN { require "t/utils.pl" }
-our (@AvailableDrivers);
+our (@available_drivers);
use constant TESTS_PER_DRIVER => 4;
-my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
use_ok('Jifty::DBI::Handle::'. $d);
my $handle = get_handle( $d );
Modified: Jifty-DBI/trunk/t/01records.t
==============================================================================
--- Jifty-DBI/trunk/t/01records.t (original)
+++ Jifty-DBI/trunk/t/01records.t Mon Jul 25 00:06:51 2005
@@ -6,14 +6,14 @@
use File::Spec;
use Test::More;
BEGIN { require "t/utils.pl" }
-our (@AvailableDrivers);
+our (@available_drivers);
use constant TESTS_PER_DRIVER => 65;
-my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
unless( has_schema( 'TestApp::Address', $d ) ) {
skip "No schema for '$d' driver", TESTS_PER_DRIVER;
@@ -30,171 +30,171 @@
isa_ok($ret,'DBI::st', "Inserted the schema. got a statement handle back");
my $rec = TestApp::Address->new($handle);
- isa_ok($rec, 'Jifty::DBI::Record');
+ isa_ok($rec, 'Jifty::DBI::record');
# _Accessible testings
- is( $rec->_Accessible('id' => 'read'), 1, 'id is accessible for read' );
- is( $rec->_Accessible('id' => 'write'), undef, 'id is not accessible for write' );
- is( $rec->_Accessible('id'), undef, "any field is not accessible in undefined mode" );
- is( $rec->_Accessible('unexpected_field' => 'read'), undef, "field doesn't exist and can't be accessible for read" );
- is_deeply( [sort($rec->ReadableAttributes)], [qw(EmployeeId Name Phone id)], 'readable attributes' );
- is_deeply( [sort($rec->WritableAttributes)], [qw(EmployeeId Name Phone)], 'writable attributes' );
+ is( $rec->_accessible('id' => 'read'), 1, 'id is accessible for read' );
+ is( $rec->_accessible('id' => 'write'), undef, 'id is not accessible for write' );
+ is( $rec->_accessible('id'), undef, "any field is not accessible in undefined mode" );
+ is( $rec->_accessible('unexpected_field' => 'read'), undef, "field doesn't exist and can't be accessible for read" );
+ is_deeply( [sort($rec->readable_attributes)], [qw(employee_id name phone id)], 'readable attributes' );
+ is_deeply( [sort($rec->writable_attributes)], [qw(employee_id name phone)], 'writable attributes' );
- can_ok($rec,'Create');
+ can_ok($rec,'create');
- my ($id) = $rec->Create( Name => 'Jesse', Phone => '617 124 567');
+ my ($id) = $rec->create( name => 'Jesse', phone => '617 124 567');
ok($id,"Created record ". $id);
- ok($rec->Load($id), "Loaded the record");
+ ok($rec->load($id), "Loaded the record");
is($rec->id, $id, "The record has its id");
- is ($rec->Name, 'Jesse', "The record's name is Jesse");
+ is ($rec->name, 'Jesse', "The record's name is Jesse");
- my ($val, $msg) = $rec->SetName('Obra');
+ my ($val, $msg) = $rec->set_name('Obra');
ok($val, $msg) ;
- is($rec->Name, 'Obra', "We did actually change the name");
+ is($rec->name, 'Obra', "We did actually change the name");
# Validate immutability of the field id
- ($val, $msg) = $rec->Setid( $rec->id + 1 );
+ ($val, $msg) = $rec->set_id( $rec->id + 1 );
ok(!$val, $msg);
is($msg, 'Immutable field', 'id is immutable field');
is($rec->id, $id, "The record still has its id");
# Check some non existant field
- ok( !eval{ $rec->SomeUnexpectedField }, "The record has no 'SomeUnexpectedField'");
+ ok( !eval{ $rec->some_unexpected_field }, "The record has no 'some_unexpected_field'");
{
# test produce DBI warning
local $SIG{__WARN__} = sub {return};
- is( $rec->_Value( 'SomeUnexpectedField' ), undef, "The record has no 'SomeUnexpectedField'");
+ is( $rec->_Value( 'some_unexpected_field' ), undef, "The record has no 'some_unexpected_field'");
}
- ($val, $msg) = $rec->SetSomeUnexpectedField( 'foo' );
+ ($val, $msg) = $rec->set_some_unexpected_field( 'foo' );
ok(!$val, $msg);
is($msg, 'Nonexistant field?', "Field doesn't exist");
- ($val, $msg) = $rec->_Set('SomeUnexpectedField', 'foo');
+ ($val, $msg) = $rec->_set('some_unexpected_field', 'foo');
ok(!$val, "$msg");
# Validate truncation on update
- ($val,$msg) = $rec->SetName('1234567890123456789012345678901234567890');
+ ($val,$msg) = $rec->set_name('1234567890123456789012345678901234567890');
ok($val, $msg);
- is($rec->Name, '12345678901234', "Truncated on update");
- $val = $rec->TruncateValue(Phone => '12345678901234567890');
+ is($rec->name, '12345678901234', "Truncated on update");
+ $val = $rec->truncate_value(phone => '12345678901234567890');
is($val, '123456789012345678', 'truncate by length attribute');
# Test unicode truncation:
my $univalue = "這是個測試";
- ($val,$msg) = $rec->SetName($univalue.$univalue);
+ ($val,$msg) = $rec->set_name($univalue.$univalue);
ok($val, $msg) ;
- is($rec->Name, '這是個測');
+ is($rec->name, '這是個測');
# make sure we do _not_ truncate things which should not be truncated
- ($val,$msg) = $rec->SetEmployeeId('1234567890');
+ ($val,$msg) = $rec->set_employee_id('1234567890');
ok($val, $msg) ;
- is($rec->EmployeeId, '1234567890', "Did not truncate id on create");
+ is($rec->employee_id, '1234567890', "Did not truncate id on create");
# make sure we do truncation on create
my $newrec = TestApp::Address->new($handle);
- my $newid = $newrec->Create( Name => '1234567890123456789012345678901234567890',
- EmployeeId => '1234567890' );
+ my $newid = $newrec->create( name => '1234567890123456789012345678901234567890',
+ employee_id => '1234567890' );
- $newrec->Load($newid);
+ $newrec->load($newid);
ok ($newid, "Created a new record");
- is($newrec->Name, '12345678901234', "Truncated on create");
- is($newrec->EmployeeId, '1234567890', "Did not truncate id on create");
+ is($newrec->name, '12345678901234', "Truncated on create");
+ is($newrec->employee_id, '1234567890', "Did not truncate id on create");
# no prefetch feature and _LoadFromSQL sub checks
$newrec = TestApp::Address->new($handle);
- ($val, $msg) = $newrec->_LoadFromSQL('SELECT id FROM Address WHERE id = ?', $newid);
+ ($val, $msg) = $newrec->_load_from_sql('SELECT id FROM address WHERE id = ?', $newid);
is($val, 1, 'found object');
- is($newrec->Name, '12345678901234', "autoloaded not prefetched field");
- is($newrec->EmployeeId, '1234567890', "autoloaded not prefetched field");
+ is($newrec->name, '12345678901234', "autoloaded not prefetched field");
+ is($newrec->employee_id, '1234567890', "autoloaded not prefetched field");
# _LoadFromSQL and missing PK
$newrec = TestApp::Address->new($handle);
- ($val, $msg) = $newrec->_LoadFromSQL('SELECT Name FROM Address WHERE Name = ?', '12345678901234');
+ ($val, $msg) = $newrec->_load_from_sql('SELECT name FROM address WHERE name = ?', '12345678901234');
is($val, 0, "didn't find object");
is($msg, "Missing a primary key?", "reason is missing PK");
# _LoadFromSQL and not existant row
$newrec = TestApp::Address->new($handle);
- ($val, $msg) = $newrec->_LoadFromSQL('SELECT id FROM Address WHERE id = ?', 0);
+ ($val, $msg) = $newrec->_load_from_sql('SELECT id FROM address WHERE id = ?', 0);
is($val, 0, "didn't find object");
is($msg, "Couldn't find row", "reason is wrong id");
-# _LoadFromSQL and wrong SQL
+# _load_from_sql and wrong SQL
$newrec = TestApp::Address->new($handle);
{
local $SIG{__WARN__} = sub{return};
- ($val, $msg) = $newrec->_LoadFromSQL('SELECT ...');
+ ($val, $msg) = $newrec->_load_from_sql('SELECT ...');
}
is($val, 0, "didn't find object");
is($msg, "Couldn't execute query", "reason is bad SQL");
# test Load* methods
$newrec = TestApp::Address->new($handle);
- $newrec->Load();
+ $newrec->load();
is( $newrec->id, undef, "can't load record with undef id");
$newrec = TestApp::Address->new($handle);
- $newrec->LoadByCol( Name => '12345678901234' );
- is( $newrec->id, $newid, "load record by 'Name' column value");
+ $newrec->load_by_col( name => '12345678901234' );
+ is( $newrec->id, $newid, "load record by 'name' column value");
# LoadByCol with operator
$newrec = TestApp::Address->new($handle);
- $newrec->LoadByCol( Name => { value => '%45678%',
+ $newrec->load_by_col( name => { value => '%45678%',
operator => 'LIKE' } );
- is( $newrec->id, $newid, "load record by 'Name' with LIKE");
+ is( $newrec->id, $newid, "load record by 'name' with LIKE");
# LoadByPrimaryKeys
$newrec = TestApp::Address->new($handle);
- ($val, $msg) = $newrec->LoadByPrimaryKeys( id => $newid );
+ ($val, $msg) = $newrec->load_by_primary_keys( id => $newid );
ok( $val, "load record by PK");
is( $newrec->id, $newid, "loaded correct record");
$newrec = TestApp::Address->new($handle);
- ($val, $msg) = $newrec->LoadByPrimaryKeys( {id => $newid} );
+ ($val, $msg) = $newrec->load_by_primary_keys( {id => $newid} );
ok( $val, "load record by PK");
is( $newrec->id, $newid, "loaded correct record" );
$newrec = TestApp::Address->new($handle);
- ($val, $msg) = $newrec->LoadByPrimaryKeys( Phone => 'some' );
+ ($val, $msg) = $newrec->load_by_primary_keys( phone => 'some' );
ok( !$val, "couldn't load, missing PK field");
is( $msg, "Missing PK field: 'id'", "right error message" );
# LoadByCols and empty or NULL values
$rec = TestApp::Address->new($handle);
- $id = $rec->Create( Name => 'Obra', Phone => undef );
+ $id = $rec->create( name => 'Obra', phone => undef );
ok( $id, "new record");
$rec = TestApp::Address->new($handle);
- $rec->LoadByCols( Name => 'Obra', Phone => undef, EmployeeId => '' );
+ $rec->load_by_cols( name => 'Obra', phone => undef, employee_id => '' );
is( $rec->id, $id, "loaded record by empty value" );
# __Set error paths
$rec = TestApp::Address->new($handle);
- $rec->Load( $id );
- $val = $rec->SetName( 'Obra' );
+ $rec->load( $id );
+ $val = $rec->set_name( 'Obra' );
isa_ok( $val, 'Class::ReturnValue', "couldn't set same value, error returned");
is( ($val->as_array)[1], "That is already the current value", "correct error message" );
- is( $rec->Name, 'Obra', "old value is still there");
- $val = $rec->SetName( 'invalid' );
+ is( $rec->name, 'Obra', "old value is still there");
+ $val = $rec->set_name( 'invalid' );
isa_ok( $val, 'Class::ReturnValue', "couldn't set invalid value, error returned");
is( ($val->as_array)[1], 'Illegal value for Name', "correct error message" );
- is( $rec->Name, 'Obra', "old value is still there");
+ is( $rec->name, 'Obra', "old value is still there");
# XXX TODO FIXME: this test cover current implementation that is broken //RUZ
- $val = $rec->SetName( );
+ $val = $rec->set_name( );
isa_ok( $val, 'Class::ReturnValue', "couldn't set empty/undef value, error returned");
- is( ($val->as_array)[1], "No value passed to _Set", "correct error message" );
- is( $rec->Name, 'Obra', "old value is still there");
+ is( ($val->as_array)[1], "No value passed to _set", "correct error message" );
+ is( $rec->name, 'Obra', "old value is still there");
# deletes
$newrec = TestApp::Address->new($handle);
- $newrec->Load( $newid );
- is( $newrec->Delete, 1, 'successfuly delete record');
+ $newrec->load( $newid );
+ is( $newrec->delete, 1, 'successfuly delete record');
$newrec = TestApp::Address->new($handle);
- $newrec->Load( $newid );
+ $newrec->load( $newid );
is( $newrec->id, undef, "record doesn't exist any more");
cleanup_schema( 'TestApp::Address', $handle );
@@ -208,31 +208,31 @@
use base qw/Jifty::DBI::Record/;
-sub _Init {
+sub _init {
my $self = shift;
my $handle = shift;
- $self->Table('Address');
- $self->_Handle($handle);
+ $welf->table('address');
+ $self->_handle($handle);
}
-sub ValidateName
+sub validate_name
{
my ($self, $value) = @_;
return 0 if $value =~ /invalid/i;
return 1;
}
-sub _ClassAccessible {
+sub _class_accessible {
{
id =>
{read => 1, type => 'int(11)', default => ''},
- Name =>
+ name =>
{read => 1, write => 1, type => 'varchar(14)', default => ''},
- Phone =>
+ phone =>
{read => 1, write => 1, type => 'varchar(18)', length => 18, default => ''},
- EmployeeId =>
+ employee_id =>
{read => 1, write => 1, type => 'int(8)', default => ''},
}
@@ -241,11 +241,11 @@
sub schema_mysql {
<<EOF;
-CREATE TEMPORARY TABLE Address (
+CREATE TEMPORARY TABLE address (
id integer AUTO_INCREMENT,
- Name varchar(36),
- Phone varchar(18),
- EmployeeId int(8),
+ name varchar(36),
+ phone varchar(18),
+ employee_id int(8),
PRIMARY KEY (id))
EOF
@@ -253,11 +253,11 @@
sub schema_pg {
<<EOF;
-CREATE TEMPORARY TABLE Address (
+CREATE TEMPORARY TABLE address (
id serial PRIMARY KEY,
- Name varchar,
- Phone varchar,
- EmployeeId integer
+ name varchar,
+ phone varchar,
+ employee_id integer
)
EOF
@@ -266,11 +266,11 @@
sub schema_sqlite {
<<EOF;
-CREATE TABLE Address (
+CREATE TABLE address (
id integer primary key,
- Name varchar(36),
- Phone varchar(18),
- EmployeeId int(8))
+ name varchar(36),
+ phone varchar(18),
+ employee_id int(8))
EOF
}
Modified: Jifty-DBI/trunk/t/01searches.t
==============================================================================
--- Jifty-DBI/trunk/t/01searches.t (original)
+++ Jifty-DBI/trunk/t/01searches.t Mon Jul 25 00:06:51 2005
@@ -6,14 +6,14 @@
use File::Spec;
use Test::More;
BEGIN { require "t/utils.pl" }
-our (@AvailableDrivers);
+our (@available_drivers);
use constant TESTS_PER_DRIVER => 59;
-my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
unless( has_schema( 'TestApp', $d ) ) {
skip "No schema for '$d' driver", TESTS_PER_DRIVER;
@@ -34,40 +34,40 @@
my $users_obj = TestApp::Users->new( $handle );
isa_ok( $users_obj, 'Jifty::DBI::Collection' );
- is( $users_obj->_Handle, $handle, "same handle as we used in constructor");
+ is( $users_obj->_handle, $handle, "same handle as we used in constructor");
# check that new object returns 0 records in any case
- is( $users_obj->_RecordCount, 0, '_RecordCount returns 0 on not limited obj' );
- is( $users_obj->Count, 0, 'Count returns 0 on not limited obj' );
- is( $users_obj->IsLast, undef, 'IsLast returns undef on not limited obj after Count' );
- is( $users_obj->First, undef, 'First returns undef on not limited obj' );
- is( $users_obj->IsLast, undef, 'IsLast returns undef on not limited obj after First' );
- is( $users_obj->Last, undef, 'Last returns undef on not limited obj' );
- is( $users_obj->IsLast, undef, 'IsLast returns undef on not limited obj after Last' );
- $users_obj->GotoFirstItem;
- is( $users_obj->Next, undef, 'Next returns undef on not limited obj' );
- is( $users_obj->IsLast, undef, 'IsLast returns undef on not limited obj after Next' );
+ is( $users_obj->_record_count, 0, '_record_count returns 0 on not limited obj' );
+ is( $users_obj->count, 0, 'count returns 0 on not limited obj' );
+ is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after count' );
+ is( $users_obj->first, undef, 'first returns undef on not limited obj' );
+ is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after First' );
+ is( $users_obj->last, undef, 'last returns undef on not limited obj' );
+ is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after Last' );
+ $users_obj->goto_first_item;
+ is( $users_obj->next, undef, 'next returns undef on not limited obj' );
+ is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after Next' );
# XXX TODO FIXME: may be this methods should be implemented
- # $users_obj->GotoLastItem;
- # is( $users_obj->Prev, undef, 'Prev returns undef on not limited obj' );
- my $items_ref = $users_obj->ItemsArrayRef;
- isa_ok( $items_ref, 'ARRAY', 'ItemsArrayRef always returns array reference' );
- is_deeply( $items_ref, [], 'ItemsArrayRef returns [] on not limited obj' );
+ # $users_obj->goto_last_item;
+ # is( $users_obj->prev, undef, 'prev returns undef on not limited obj' );
+ my $items_ref = $users_obj->items_array_ref;
+ isa_ok( $items_ref, 'ARRAY', 'items_array_ref always returns array reference' );
+ is_deeply( $items_ref, [], 'items_array_ref returns [] on not limited obj' );
# unlimit new object and check
- $users_obj->UnLimit;
- is( $users_obj->Count, $count_all, 'Count returns same number of records as was inserted' );
- isa_ok( $users_obj->First, 'Jifty::DBI::Record', 'First returns record object' );
- isa_ok( $users_obj->Last, 'Jifty::DBI::Record', 'Last returns record object' );
- $users_obj->GotoFirstItem;
- isa_ok( $users_obj->Next, 'Jifty::DBI::Record', 'Next returns record object' );
- $items_ref = $users_obj->ItemsArrayRef;
- isa_ok( $items_ref, 'ARRAY', 'ItemsArrayRef always returns array reference' );
- is( scalar @{$items_ref}, $count_all, 'ItemsArrayRef returns same number of records as was inserted' );
- $users_obj->RedoSearch;
- $items_ref = $users_obj->ItemsArrayRef;
- isa_ok( $items_ref, 'ARRAY', 'ItemsArrayRef always returns array reference' );
- is( scalar @{$items_ref}, $count_all, 'ItemsArrayRef returns same number of records as was inserted' );
+ $users_obj->un_limit;
+ is( $users_obj->count, $count_all, 'count returns same number of records as was inserted' );
+ isa_ok( $users_obj->first, 'Jifty::DBI::Record', 'first returns record object' );
+ isa_ok( $users_obj->last, 'Jifty::DBI::Record', 'last returns record object' );
+ $users_obj->goto_first_item;
+ isa_ok( $users_obj->next, 'Jifty::DBI::Record', 'next returns record object' );
+ $items_ref = $users_obj->items_array_ref;
+ isa_ok( $items_ref, 'ARRAY', 'items_array_ref always returns array reference' );
+ is( scalar @{$items_ref}, $count_all, 'items_array_ref returns same number of records as was inserted' );
+ $users_obj->redo_search;
+ $items_ref = $users_obj->items_array_ref;
+ isa_ok( $items_ref, 'ARRAY', 'items_array_ref always returns array reference' );
+ is( scalar @{$items_ref}, $count_all, 'items_array_ref returns same number of records as was inserted' );
# try to use $users_obj for all tests, after each call to CleanSlate it should look like new obj.
# and test $obj->new syntax
@@ -75,86 +75,86 @@
isa_ok( $clean_obj, 'Jifty::DBI::Collection' );
# basic limits
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->Limit( FIELD => 'Login', VALUE => 'obra' );
- is( $users_obj->Count, 1, 'found one user with login obra' );
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->limit( FIELD => 'login', VALUE => 'obra' );
+ is( $users_obj->count, 1, 'found one user with login obra' );
TODO: {
local $TODO = 'require discussion';
- is( $users_obj->IsLast, undef, 'IsLast returns undef before we fetch any record' );
+ is( $users_obj->is_last, undef, 'is_last returns undef before we fetch any record' );
}
- my $first_rec = $users_obj->First;
+ my $first_rec = $users_obj->first;
isa_ok( $first_rec, 'Jifty::DBI::Record', 'First returns record object' );
- is( $users_obj->IsLast, 1, '1 record in the collection then first rec is last');
- is( $first_rec->Login, 'obra', 'login is correct' );
- my $last_rec = $users_obj->Last;
- is( $last_rec, $first_rec, 'Last returns same object as First' );
- is( $users_obj->IsLast, 1, 'IsLast always returns 1 after Last call');
- $users_obj->GotoFirstItem;
- my $next_rec = $users_obj->Next;
- is( $next_rec, $first_rec, 'Next returns same object as First' );
- is( $users_obj->IsLast, 1, 'IsLast returns 1 after fetch first record with Next method');
- is( $users_obj->Next, undef, 'only one record in the collection' );
+ is( $users_obj->is_last, 1, '1 record in the collection then first rec is last');
+ is( $first_rec->login, 'obra', 'login is correct' );
+ my $last_rec = $users_obj->last;
+ is( $last_rec, $first_rec, 'last returns same object as first' );
+ is( $users_obj->is_last, 1, 'is_last always returns 1 after last call');
+ $users_obj->goto_first_item;
+ my $next_rec = $users_obj->next;
+ is( $next_rec, $first_rec, 'next returns same object as first' );
+ is( $users_obj->is_last, 1, 'is_last returns 1 after fetch first record with next method');
+ is( $users_obj->next, undef, 'only one record in the collection' );
TODO: {
local $TODO = 'require discussion';
- is( $users_obj->IsLast, undef, 'Next returns undef, IsLast returns undef too');
+ is( $users_obj->is_last, undef, 'next returns undef, is_last returns undef too');
}
- $items_ref = $users_obj->ItemsArrayRef;
- isa_ok( $items_ref, 'ARRAY', 'ItemsArrayRef always returns array reference' );
- is( scalar @{$items_ref}, 1, 'ItemsArrayRef has only 1 record' );
+ $items_ref = $users_obj->items_array_ref;
+ isa_ok( $items_ref, 'ARRAY', 'items_array_ref always returns array reference' );
+ is( scalar @{$items_ref}, 1, 'items_array_ref has only 1 record' );
-# similar basic limit, but with different OPERATORS and less Firs/Next/Last tests
+# similar basic limit, but with different OPERATORS and less first/next/last tests
# LIKE
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->Limit( FIELD => 'Name', OPERATOR => 'LIKE', VALUE => 'Glass' );
- is( $users_obj->Count, 1, "found one user with 'Glass' in the name" );
- $first_rec = $users_obj->First;
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->limit( FIELD => 'name', OPERATOR => 'LIKE', VALUE => 'Glass' );
+ is( $users_obj->count, 1, "found one user with 'Glass' in the name" );
+ $first_rec = $users_obj->first;
isa_ok( $first_rec, 'Jifty::DBI::Record', 'First returns record object' );
- is( $first_rec->Login, 'glasser', 'login is correct' );
+ is( $first_rec->login, 'glasser', 'login is correct' );
# STARTSWITH
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->Limit( FIELD => 'Name', OPERATOR => 'STARTSWITH', VALUE => 'Ruslan' );
- is( $users_obj->Count, 1, "found one user who name starts with 'Ruslan'" );
- $first_rec = $users_obj->First;
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->limit( FIELD => 'name', OPERATOR => 'STARTSWITH', VALUE => 'Ruslan' );
+ is( $users_obj->count, 1, "found one user who name starts with 'Ruslan'" );
+ $first_rec = $users_obj->first;
isa_ok( $first_rec, 'Jifty::DBI::Record', 'First returns record object' );
- is( $first_rec->Login, 'cubic', 'login is correct' );
+ is( $first_rec->login, 'cubic', 'login is correct' );
# ENDSWITH
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->Limit( FIELD => 'Name', OPERATOR => 'ENDSWITH', VALUE => 'Tang' );
- is( $users_obj->Count, 1, "found one user who name ends with 'Tang'" );
- $first_rec = $users_obj->First;
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->limit( FIELD => 'name', OPERATOR => 'ENDSWITH', VALUE => 'Tang' );
+ is( $users_obj->count, 1, "found one user who name ends with 'Tang'" );
+ $first_rec = $users_obj->first;
isa_ok( $first_rec, 'Jifty::DBI::Record', 'First returns record object' );
- is( $first_rec->Login, 'autrijus', 'login is correct' );
+ is( $first_rec->login, 'autrijus', 'login is correct' );
# IS NULL
# XXX TODO FIXME: FIELD => undef should be handled as NULL
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->Limit( FIELD => 'Phone', OPERATOR => 'IS', VALUE => 'NULL' );
- is( $users_obj->Count, 2, "found 2 users who has unknown phone number" );
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->limit( FIELD => 'phone', OPERATOR => 'IS', VALUE => 'NULL' );
+ is( $users_obj->count, 2, "found 2 users who has unknown phone number" );
# IS NOT NULL
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->Limit( FIELD => 'Phone', OPERATOR => 'IS NOT', VALUE => 'NULL', QOUTEVALUE => 0 );
- is( $users_obj->Count, $count_all - 2, "found users who has phone number filled" );
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->limit( FIELD => 'phone', OPERATOR => 'IS NOT', VALUE => 'NULL', QOUTEVALUE => 0 );
+ is( $users_obj->count, $count_all - 2, "found users who has phone number filled" );
# ORDER BY / GROUP BY
- $users_obj->CleanSlate;
- is_deeply( $users_obj, $clean_obj, 'after CleanSlate looks like new object');
- $users_obj->UnLimit;
- $users_obj->GroupByCols({FIELD => 'Login'});
- $users_obj->OrderBy(FIELD => 'Login', ORDER => 'desc');
- $users_obj->Column(FIELD => 'Login');
- is( $users_obj->Count, $count_all, "group by / order by finds right amount");
- $first_rec = $users_obj->First;
+ $users_obj->clean_slate;
+ is_deeply( $users_obj, $clean_obj, 'after clean_slate looks like new object');
+ $users_obj->un_limit;
+ $users_obj->group_by_cols({FIELD => 'login'});
+ $users_obj->order_by(FIELD => 'login', ORDER => 'desc');
+ $users_obj->column(FIELD => 'login');
+ is( $users_obj->count, $count_all, "group by / order by finds right amount");
+ $first_rec = $users_obj->first;
isa_ok( $first_rec, 'Jifty::DBI::Record', 'First returns record object' );
- is( $first_rec->Login, 'obra', 'login is correct' );
+ is( $first_rec->login, 'obra', 'login is correct' );
cleanup_schema( 'TestApp', $handle );
}} # SKIP, foreach blocks
@@ -165,11 +165,11 @@
sub schema_mysql {
<<EOF;
-CREATE TEMPORARY TABLE Users (
+CREATE TEMPORARY TABLE users (
id integer AUTO_INCREMENT,
- Login varchar(18) NOT NULL,
- Name varchar(36),
- Phone varchar(18),
+ login varchar(18) NOT NULL,
+ name varchar(36),
+ phone varchar(18),
PRIMARY KEY (id))
EOF
@@ -177,11 +177,11 @@
sub schema_pg {
<<EOF;
-CREATE TEMPORARY TABLE Users (
+CREATE TEMPORARY TABLE users (
id serial PRIMARY KEY,
- Login varchar(18) NOT NULL,
- Name varchar(36),
- Phone varchar(18)
+ login varchar(18) NOT NULL,
+ name varchar(36),
+ phone varchar(18)
)
EOF
@@ -190,11 +190,11 @@
sub schema_sqlite {
<<EOF;
-CREATE TABLE Users (
+CREATE TABLE users (
id integer primary key,
- Login varchar(18) NOT NULL,
- Name varchar(36),
- Phone varchar(18))
+ login varchar(18) NOT NULL,
+ name varchar(36),
+ phone varchar(18))
EOF
}
@@ -206,29 +206,29 @@
use base qw/Jifty::DBI::Record/;
-sub _Init {
+sub _init {
my $self = shift;
my $handle = shift;
- $self->Table('Users');
- $self->_Handle($handle);
+ $self->table('users');
+ $self->_handle($handle);
}
-sub _ClassAccessible {
+sub _class_accessible {
{
id =>
{read => 1, type => 'int(11)' },
- Login =>
+ login =>
{read => 1, write => 1, type => 'varchar(18)' },
- Name =>
+ name =>
{read => 1, write => 1, type => 'varchar(36)' },
- Phone =>
+ phone =>
{read => 1, write => 1, type => 'varchar(18)', default => ''},
}
}
sub init_data {
return (
- [ 'Login', 'Name', 'Phone' ],
+ [ 'login', 'name', 'phone' ],
[ 'cubic', 'Ruslan U. Zakirov', '+7-903-264-XX-XX' ],
[ 'obra', 'Jesse Vincent', undef ],
[ 'glasser', 'David Glasser', undef ],
@@ -243,16 +243,16 @@
# use TestApp::User;
use base qw/Jifty::DBI::Collection/;
-sub _Init {
+sub _init {
my $self = shift;
- $self->SUPER::_Init( Handle => shift );
- $self->Table('Users');
+ $self->SUPER::_init( handle => shift );
+ $self->table('users');
}
-sub NewItem
+sub new_item
{
my $self = shift;
- return TestApp::User->new( $self->_Handle );
+ return TestApp::User->new( $self->_handle );
}
1;
Modified: Jifty-DBI/trunk/t/02records_object.t
==============================================================================
--- Jifty-DBI/trunk/t/02records_object.t (original)
+++ Jifty-DBI/trunk/t/02records_object.t Mon Jul 25 00:06:51 2005
@@ -7,14 +7,14 @@
use Test::More;
BEGIN { require "t/utils.pl" }
-our (@AvailableDrivers);
+our (@available_drivers);
use constant TESTS_PER_DRIVER => 11;
-my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
unless( has_schema( 'TestApp', $d ) ) {
skip "No schema for '$d' driver", TESTS_PER_DRIVER;
@@ -31,23 +31,23 @@
isa_ok($ret,'DBI::st', "Inserted the schema. got a statement handle back");
my $emp = TestApp::Employee->new($handle);
- my $e_id = $emp->Create( Name => 'RUZ' );
+ my $e_id = $emp->create( Name => 'RUZ' );
ok($e_id, "Got an ide for the new emplyee");
my $phone = TestApp::Phone->new($handle);
- isa_ok( $phone, 'TestApp::Phone', "it's atestapp::phone");
- my $p_id = $phone->Create( Employee => $e_id, Phone => '+7(903)264-03-51');
+ isa_ok( $phone, 'TestApp::Phone', "it's a TestApp::Phone");
+ my $p_id = $phone->create( employee => $e_id, phone => '+7(903)264-03-51');
# XXX: test fails if next string is commented
is($p_id, 1, "Loaded record $p_id");
- $phone->Load( $p_id );
+ $phone->load( $p_id );
- my $obj = $phone->EmployeeObj($handle);
+ my $obj = $phone->employee_obj($handle);
ok($obj, "Employee #$e_id has phone #$p_id");
isa_ok( $obj, 'TestApp::Employee');
is($obj->id, $e_id);
- is($obj->Name, 'RUZ');
+ is($obj->name, 'RUZ');
# tests for no object mapping
- my ($state, $msg) = $phone->ValueObj($handle);
+ my ($state, $msg) = $phone->value_obj($handle);
ok(!$state, "State is false");
is( $msg, 'No object mapping for field', 'Error message is correct');
@@ -61,45 +61,45 @@
sub schema_sqlite {
[
q{
-CREATE TABLE Employees (
+CREATE TABLE employees (
id integer primary key,
- Name varchar(36)
+ name varchar(36)
)
}, q{
-CREATE TABLE Phones (
+CREATE TABLE phones (
id integer primary key,
- Employee integer NOT NULL,
- Phone varchar(18)
+ employee integer NOT NULL,
+ phone varchar(18)
) }
]
}
sub schema_mysql {
[ q{
-CREATE TEMPORARY TABLE Employees (
+CREATE TEMPORARY TABLE employees (
id integer AUTO_INCREMENT primary key,
- Name varchar(36)
+ name varchar(36)
)
}, q{
-CREATE TEMPORARY TABLE Phones (
+CREATE TEMPORARY TABLE phones (
id integer AUTO_INCREMENT primary key,
- Employee integer NOT NULL,
- Phone varchar(18)
+ employee integer NOT NULL,
+ phone varchar(18)
)
} ]
}
sub schema_pg {
[ q{
-CREATE TEMPORARY TABLE Employees (
+CREATE TEMPORARY TABLE employees (
id serial PRIMARY KEY,
- Name varchar
+ name varchar
)
}, q{
-CREATE TEMPORARY TABLE Phones (
+CREATE TEMPORARY TABLE phones (
id serial PRIMARY KEY,
- Employee integer references Employees(id),
- Phone varchar
+ employee integer references employees(id),
+ phone varchar
)
} ]
}
@@ -110,19 +110,19 @@
use vars qw/$VERSION/;
$VERSION=0.01;
-sub _Init {
+sub _init {
my $self = shift;
my $handle = shift;
- $self->Table('Employees');
- $self->_Handle($handle);
+ $self->Table('employees');
+ $self->_handle($handle);
}
-sub _ClassAccessible {
+sub _class_accessible {
{
id =>
{read => 1, type => 'int(11)'},
- Name =>
+ name =>
{read => 1, write => 1, type => 'varchar(18)'},
}
@@ -137,21 +137,21 @@
use base qw/Jifty::DBI::Record/;
-sub _Init {
+sub _init {
my $self = shift;
my $handle = shift;
- $self->Table('Phones');
- $self->_Handle($handle);
+ $self->table('phones');
+ $self->_handle($handle);
}
-sub _ClassAccessible {
+sub _class_accessible {
{
id =>
{read => 1, type => 'int(11)'},
- Employee =>
+ employee =>
{read => 1, write => 1, type => 'int(11)', object => 'TestApp::Employee' },
- Value =>
+ value =>
{read => 1, write => 1, type => 'varchar(18)'},
}
Modified: Jifty-DBI/trunk/t/03rebless.t
==============================================================================
--- Jifty-DBI/trunk/t/03rebless.t (original)
+++ Jifty-DBI/trunk/t/03rebless.t Mon Jul 25 00:06:51 2005
@@ -8,14 +8,14 @@
use Jifty::DBI::Handle;
BEGIN { require "t/utils.pl" }
-our (@AvailableDrivers);
+our (@available_drivers);
use constant TESTS_PER_DRIVER => 4;
-my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
unless( should_test( $d ) ) {
skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
Modified: Jifty-DBI/trunk/t/10schema.t
==============================================================================
--- Jifty-DBI/trunk/t/10schema.t (original)
+++ Jifty-DBI/trunk/t/10schema.t Mon Jul 25 00:06:51 2005
@@ -5,11 +5,11 @@
use Test::More;
use constant TESTS_PER_DRIVER => 14;
-our @AvailableDrivers;
+our @available_drivers;
BEGIN {
require("t/utils.pl");
- my $total = 3 + scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+ my $total = 3 + scalar(@available_drivers) * TESTS_PER_DRIVER;
if( not eval { require DBIx::DBSchema } ) {
plan skip_all => "DBIx::DBSchema not installed";
} else {
@@ -24,7 +24,7 @@
require_ok("t/testmodels.pl");
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
unless ($d eq 'Pg') {
skip "first goal is to work on Pg", TESTS_PER_DRIVER;
@@ -45,27 +45,27 @@
isa_ok($SG->_db_schema, 'DBIx::DBSchema');
- is($SG->CreateTableSQLText, '', "no tables means no sql");
+ is($SG->create_table_sql_text, '', "no tables means no sql");
- my $ret = $SG->AddModel('Sample::This::Does::Not::Exist');
+ my $ret = $SG->add_model('Sample::This::Does::Not::Exist');
ok($ret == 0, "couldn't add model from nonexistent class");
like($ret->error_message, qr/Error making new object from Sample::This::Does::Not::Exist/,
"couldn't add model from nonexistent class");
- is($SG->CreateTableSQLText, '', "no tables means no sql");
+ is($SG->create_table_sql_text, '', "no tables means no sql");
- $ret = $SG->AddModel('Sample::Address');
+ $ret = $SG->add_model('Sample::Address');
ok($ret != 0, "added model from real class");
- is_ignoring_space($SG->CreateTableSQLText, <<END_SCHEMA, "got the right schema");
- CREATE TABLE Addresses (
+ is_ignoring_space($SG->create_table_sql_text, <<END_SCHEMA, "got the right schema");
+ CREATE TABLE addresses (
id serial NOT NULL ,
- EmployeeId integer ,
- Name varchar DEFAULT 'Frank' ,
- Phone varchar ,
+ employee_id integer ,
+ name varchar DEFAULT 'Frank' ,
+ phone varchar ,
PRIMARY KEY (id)
) ;
END_SCHEMA
@@ -74,28 +74,28 @@
isa_ok($employee, 'Sample::Employee');
- $ret = $SG->AddModel($employee);
+ $ret = $SG->add_model($employee);
ok($ret != 0, "added model from an instantiated object");
- is_ignoring_space($SG->CreateTableSQLText, <<END_SCHEMA, "got the right schema");
- CREATE TABLE Addresses (
+ is_ignoring_space($SG->create_table_sql_text, <<END_SCHEMA, "got the right schema");
+ CREATE TABLE addresses (
id serial NOT NULL ,
- EmployeeId integer ,
- Name varchar DEFAULT 'Frank' ,
- Phone varchar ,
+ employee_id integer ,
+ name varchar DEFAULT 'Frank' ,
+ phone varchar ,
PRIMARY KEY (id)
) ;
- CREATE TABLE Employees (
+ CREATE TABLE employees (
id serial NOT NULL ,
- Dexterity integer ,
- Name varchar ,
+ dexterity integer ,
+ name varchar ,
PRIMARY KEY (id)
) ;
END_SCHEMA
- my $manually_make_text = join ' ', map { "$_;" } $SG->CreateTableSQLStatements;
- is_ignoring_space($SG->CreateTableSQLText, $manually_make_text, 'CreateTableSQLText is the statements in CreateTableSQLStatements')
+ my $manually_make_text = join ' ', map { "$_;" } $SG->create_table_sql_statements;
+ is_ignoring_space($SG->create_table_sql_text, $manually_make_text, 'create_table_sql_text is the statements in create_table_sql_statements')
}}
sub is_ignoring_space {
Modified: Jifty-DBI/trunk/t/11schema_records.t
==============================================================================
--- Jifty-DBI/trunk/t/11schema_records.t (original)
+++ Jifty-DBI/trunk/t/11schema_records.t Mon Jul 25 00:06:51 2005
@@ -7,14 +7,14 @@
use Test::More;
BEGIN { require "t/utils.pl" }
-our (@AvailableDrivers);
+our (@available_drivers);
use constant TESTS_PER_DRIVER => 63;
-my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
-foreach my $d ( @AvailableDrivers ) {
+foreach my $d ( @available_drivers ) {
SKIP: {
unless( has_schema( 'TestApp', $d ) ) {
skip "No schema for '$d' driver", TESTS_PER_DRIVER;
@@ -31,12 +31,12 @@
isa_ok($ret,'DBI::st', "Inserted the schema. got a statement handle back");
my $emp = TestApp::Employee->new($handle);
- my $e_id = $emp->Create( Name => 'RUZ' );
+ my $e_id = $emp->create( Name => 'RUZ' );
ok($e_id, "Got an id for the new employee: $e_id");
- $emp->Load($e_id);
+ $emp->load($e_id);
is($emp->id, $e_id);
- my $phone_collection = $emp->Phones;
+ my $phone_collection = $emp->phones;
isa_ok($phone_collection, 'TestApp::PhoneCollection');
{
@@ -46,139 +46,139 @@
my $phone = TestApp::Phone->new($handle);
isa_ok( $phone, 'TestApp::Phone');
- my $p_id = $phone->Create( Employee => $e_id, Phone => '+7(903)264-03-51');
+ my $p_id = $phone->create( employee => $e_id, phone => '+7(903)264-03-51');
is($p_id, 1, "Loaded phone $p_id");
- $phone->Load( $p_id );
+ $phone->load( $p_id );
- my $obj = $phone->Employee;
+ my $obj = $phone->employee;
ok($obj, "Employee #$e_id has phone #$p_id");
isa_ok( $obj, 'TestApp::Employee');
is($obj->id, $e_id);
- is($obj->Name, 'RUZ');
+ is($obj->name, 'RUZ');
{
- $phone_collection->RedoSearch;
- my $ph = $phone_collection->Next;
+ $phone_collection->redo_search;
+ my $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p_id, 'found first phone');
- is($ph->Phone, '+7(903)264-03-51');
- is($phone_collection->Next, undef);
+ is($ph->phone, '+7(903)264-03-51');
+ is($phone_collection->next, undef);
}
# tests for no object mapping
- my $val = $phone->Phone;
+ my $val = $phone->phone;
is( $val, '+7(903)264-03-51', 'Non-object things still work');
my $emp2 = TestApp::Employee->new($handle);
isa_ok($emp2, 'TestApp::Employee');
- my $e2_id = $emp2->Create( Name => 'Dave' );
+ my $e2_id = $emp2->create( name => 'Dave' );
ok($e2_id, "Got an id for the new employee: $e2_id");
- $emp2->Load($e2_id);
+ $emp2->load($e2_id);
is($emp2->id, $e2_id);
- my $phone2_collection = $emp2->Phones;
+ my $phone2_collection = $emp2->phones;
isa_ok($phone2_collection, 'TestApp::PhoneCollection');
{
- my $ph = $phone2_collection->Next;
+ my $ph = $phone2_collection->next;
is($ph, undef, "new emp has no phones");
}
{
- $phone_collection->RedoSearch;
- my $ph = $phone_collection->Next;
+ $phone_collection->redo_search;
+ my $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p_id, 'first emp still has phone');
- is($ph->Phone, '+7(903)264-03-51');
- is($phone_collection->Next, undef);
+ is($ph->phone, '+7(903)264-03-51');
+ is($phone_collection->next, undef);
}
- $phone->SetEmployee($e2_id);
+ $phone->set_employee($e2_id);
- my $emp3 = $phone->Employee;
+ my $emp3 = $phone->employee;
isa_ok($emp3, 'TestApp::Employee');
- is($emp3->Name, 'Dave', 'changed employees by ID');
+ is($emp3->name, 'Dave', 'changed employees by ID');
is($emp3->id, $emp2->id);
{
- $phone_collection->RedoSearch;
- is($phone_collection->Next, undef, "first emp lost phone");
+ $phone_collection->redo_search;
+ is($phone_collection->next, undef, "first emp lost phone");
}
{
- $phone2_collection->RedoSearch;
- my $ph = $phone2_collection->Next;
+ $phone2_collection->redo_search;
+ my $ph = $phone2_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p_id, 'new emp stole the phone');
- is($ph->Phone, '+7(903)264-03-51');
- is($phone2_collection->Next, undef);
+ is($ph->phone, '+7(903)264-03-51');
+ is($phone2_collection->next, undef);
}
- $phone->SetEmployee($emp);
+ $phone->set_employee($emp);
- my $emp4 = $phone->Employee;
+ my $emp4 = $phone->employee;
isa_ok($emp4, 'TestApp::Employee');
- is($emp4->Name, 'RUZ', 'changed employees by obj');
+ is($emp4->name, 'RUZ', 'changed employees by obj');
is($emp4->id, $emp->id);
{
- $phone2_collection->RedoSearch;
- is($phone2_collection->Next, undef, "second emp lost phone");
+ $phone2_collection->redo_search;
+ is($phone2_collection->next, undef, "second emp lost phone");
}
{
- $phone_collection->RedoSearch;
- my $ph = $phone_collection->Next;
+ $phone_collection->redo_search;
+ my $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p_id, 'first emp stole the phone');
- is($ph->Phone, '+7(903)264-03-51');
- is($phone_collection->Next, undef);
+ is($ph->phone, '+7(903)264-03-51');
+ is($phone_collection->next, undef);
}
my $phone2 = TestApp::Phone->new($handle);
isa_ok( $phone2, 'TestApp::Phone');
- my $p2_id = $phone2->Create( Employee => $e_id, Phone => '123456');
+ my $p2_id = $phone2->create( employee => $e_id, phone => '123456');
ok($p2_id, "Loaded phone $p2_id");
- $phone2->Load( $p2_id );
+ $phone2->load( $p2_id );
{
- $phone_collection->RedoSearch;
- my $ph = $phone_collection->Next;
+ $phone_collection->redo_search;
+ my $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p_id, 'still has this phone');
- is($ph->Phone, '+7(903)264-03-51');
- $ph = $phone_collection->Next;
+ is($ph->phone, '+7(903)264-03-51');
+ $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p2_id, 'now has that phone');
- is($ph->Phone, '123456');
- is($phone_collection->Next, undef);
+ is($ph->phone, '123456');
+ is($phone_collection->next, undef);
}
# Test Create with obj as argument
my $phone3 = TestApp::Phone->new($handle);
isa_ok( $phone3, 'TestApp::Phone');
- my $p3_id = $phone3->Create( Employee => $emp, Phone => '7890');
+ my $p3_id = $phone3->create( employee => $emp, phone => '7890');
ok($p3_id, "Loaded phone $p3_id");
- $phone3->Load( $p3_id );
+ $phone3->load( $p3_id );
{
- $phone_collection->RedoSearch;
- my $ph = $phone_collection->Next;
+ $phone_collection->redo_search;
+ my $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p_id, 'still has this phone');
- is($ph->Phone, '+7(903)264-03-51');
- $ph = $phone_collection->Next;
+ is($ph->phone, '+7(903)264-03-51');
+ $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p2_id, 'still has that phone');
- is($ph->Phone, '123456');
- $ph = $phone_collection->Next;
+ is($ph->phone, '123456');
+ $ph = $phone_collection->next;
isa_ok($ph, 'TestApp::Phone');
is($ph->id, $p3_id, 'even has this other phone');
- is($ph->Phone, '7890');
- is($phone_collection->Next, undef);
+ is($ph->phone, '7890');
+ is($phone_collection->next, undef);
}
@@ -193,45 +193,45 @@
sub schema_sqlite {
[
q{
-CREATE TABLE Employees (
+CREATE TABLE employees (
id integer primary key,
- Name varchar(36)
+ name varchar(36)
)
}, q{
-CREATE TABLE Phones (
+CREATE TABLE phones (
id integer primary key,
- Employee integer NOT NULL,
- Phone varchar(18)
+ employee integer NOT NULL,
+ phone varchar(18)
) }
]
}
sub schema_mysql {
[ q{
-CREATE TEMPORARY TABLE Employees (
+CREATE TEMPORARY TABLE employees (
id integer AUTO_INCREMENT primary key,
- Name varchar(36)
+ name varchar(36)
)
}, q{
-CREATE TEMPORARY TABLE Phones (
+CREATE TEMPORARY TABLE phones (
id integer AUTO_INCREMENT primary key,
- Employee integer NOT NULL,
- Phone varchar(18)
+ employee integer NOT NULL,
+ phone varchar(18)
)
} ]
}
sub schema_pg {
[ q{
-CREATE TEMPORARY TABLE Employees (
+CREATE TEMPORARY TABLE employees (
id serial PRIMARY KEY,
- Name varchar
+ name varchar
)
}, q{
-CREATE TEMPORARY TABLE Phones (
+CREATE TEMPORARY TABLE phones (
id serial PRIMARY KEY,
- Employee integer references Employees(id),
- Phone varchar
+ employee integer references employees(id),
+ phone varchar
)
} ]
}
@@ -240,18 +240,18 @@
use base qw/Jifty::DBI::Record/;
-sub Table { 'Employees' }
+sub Table { 'employees' }
-sub Schema {
+sub schema {
return {
- Name => { TYPE => 'varchar' },
- Phones => { REFERENCES => 'TestApp::PhoneCollection', KEY => 'Employee' }
+ name => { TYPE => 'varchar' },
+ phones => { REFERENCES => 'TestApp::PhoneCollection', KEY => 'employee' }
};
}
-sub _Value {
+sub _value {
my $self = shift;
- my $x = ($self->__Value(@_));
+ my $x = ($self->__value(@_));
return $x;
}
@@ -262,12 +262,12 @@
use base qw/Jifty::DBI::Record/;
-sub Table { 'Phones' }
+sub Table { 'phones' }
-sub Schema {
+sub schema {
return {
- Employee => { REFERENCES => 'TestApp::Employee' },
- Phone => { TYPE => 'varchar' },
+ employee => { REFERENCES => 'TestApp::Employee' },
+ phone => { TYPE => 'varchar' },
}
}
@@ -275,16 +275,16 @@
use base qw/Jifty::DBI::Collection/;
-sub Table {
+sub table {
my $self = shift;
- my $tab = $self->NewItem->Table();
+ my $tab = $self->new_item->table();
return $tab;
}
-sub NewItem {
+sub new_item {
my $self = shift;
my $class = 'TestApp::Phone';
- return $class->new( $self->_Handle );
+ return $class->new( $self->_handle );
}
Modified: Jifty-DBI/trunk/t/testmodels.pl
==============================================================================
--- Jifty-DBI/trunk/t/testmodels.pl (original)
+++ Jifty-DBI/trunk/t/testmodels.pl Mon Jul 25 00:06:51 2005
@@ -4,15 +4,15 @@
# Class and instance method
-sub Table { "Addresses" }
+sub Table { "addresses" }
# Class and instance method
-sub Schema {
+sub schema {
return {
- Name => { TYPE => 'varchar', DEFAULT => 'Frank', },
- Phone => { TYPE => 'varchar', },
- EmployeeId => { REFERENCES => 'Sample::Employee', },
+ name => { TYPE => 'varchar', DEFAULT => 'Frank', },
+ phone => { TYPE => 'varchar', },
+ employee_id => { REFERENCES => 'Sample::Employee', },
}
}
@@ -20,13 +20,13 @@
use base qw/Jifty::DBI::Record/;
-sub Table { "Employees" }
+sub table { "employees" }
-sub Schema {
+sub schema {
return {
- Name => { TYPE => 'varchar', },
- Dexterity => { TYPE => 'integer', },
+ name => { TYPE => 'varchar', },
+ dexterity => { TYPE => 'integer', },
}
}
-1;
\ No newline at end of file
+1;
Modified: Jifty-DBI/trunk/t/utils.pl
==============================================================================
--- Jifty-DBI/trunk/t/utils.pl (original)
+++ Jifty-DBI/trunk/t/utils.pl Mon Jul 25 00:06:51 2005
@@ -4,13 +4,13 @@
=head1 VARIABLES
-=head2 @SupportedDrivers
+=head2 @supported_drivers
Array of all supported DBD drivers.
=cut
-our @SupportedDrivers = qw(
+our @supported_drivers = qw(
Informix
mysql
mysqlPP
@@ -21,14 +21,14 @@
Sybase
);
-=head2 @AvailableDrivers
+=head2 @available_drivers
Array that lists only drivers from supported list
that user has installed.
=cut
-our @AvailableDrivers = grep { eval "require DBD::". $_ } @SupportedDrivers;
+our @available_drivers = grep { eval "require DBD::". $_ } @supported_drivers;
=head1 FUNCTIONS
@@ -95,31 +95,31 @@
sub connect_sqlite
{
my $handle = shift;
- return $handle->Connect(
- Driver => 'SQLite',
- Database => File::Spec->catfile(File::Spec->tmpdir(), "sb-test.$$")
+ return $handle->connect(
+ driver => 'SQLite',
+ database => File::Spec->catfile(File::Spec->tmpdir(), "sb-test.$$")
);
}
sub connect_mysql
{
my $handle = shift;
- return $handle->Connect(
- Driver => 'mysql',
- Database => $ENV{'SB_TEST_MYSQL'},
- User => $ENV{'SB_TEST_MYSQL_USER'} || 'root',
- Password => $ENV{'SB_TEST_MYSQL_PASS'} || '',
+ return $handle->connect(
+ driver => 'mysql',
+ database => $ENV{'SB_TEST_MYSQL'},
+ user => $ENV{'SB_TEST_MYSQL_USER'} || 'root',
+ password => $ENV{'SB_TEST_MYSQL_PASS'} || '',
);
}
sub connect_pg
{
my $handle = shift;
- return $handle->Connect(
- Driver => 'Pg',
- Database => $ENV{'SB_TEST_PG'},
- User => $ENV{'SB_TEST_PG_USER'} || 'postgres',
- Password => $ENV{'SB_TEST_PG_PASS'} || '',
+ return $handle->connect(
+ driver => 'Pg',
+ database => $ENV{'SB_TEST_PG'},
+ user => $ENV{'SB_TEST_PG_USER'} || 'postgres',
+ password => $ENV{'SB_TEST_PG_PASS'} || '',
);
}
@@ -169,7 +169,7 @@
$schema = ref( $schema )? $schema : [$schema];
my $ret;
foreach my $query( @$schema ) {
- $ret = $handle->SimpleQuery( $query );
+ $ret = $handle->simple_query( $query );
return $ret unless UNIVERSAL::isa( $ret, 'DBI::st' );
}
return $ret;
@@ -191,7 +191,7 @@
my $schema = $class->$call();
$schema = ref( $schema )? $schema : [$schema];
foreach my $query( @$schema ) {
- eval { $handle->SimpleQuery( $query ) };
+ eval { $handle->simple_query( $query ) };
}
}
@@ -211,7 +211,7 @@
$args{ $columns[$i] } = $values->[$i];
}
my $rec = $class->new( $handle );
- my $id = $rec->Create( %args );
+ my $id = $rec->create( %args );
die "Couldn't create record" unless $id;
$count++;
}
More information about the Rt-commit
mailing list