Skip to content

Commit

Permalink
change module name
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayu36 committed Oct 23, 2011
1 parent 6403ea4 commit 6efb14f
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Revision history for Test::Factory::DBI
Revision history for DBIx::DataFactory

0.0.1 Tue Oct 18 08:56:04 2011
- Initial release
16 changes: 8 additions & 8 deletions lib/Test/Factory/DBI.pm → lib/DBIx/DataFactory.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Test::Factory::DBI;
package DBIx::DataFactory;

use strict;
use warnings;
Expand All @@ -11,9 +11,9 @@ __PACKAGE__->mk_classdata('username');
__PACKAGE__->mk_classdata('password');
__PACKAGE__->mk_classdata('defined_types' => {});

__PACKAGE__->add_type('Test::Factory::DBI::Type::Int');
__PACKAGE__->add_type('Test::Factory::DBI::Type::Num');
__PACKAGE__->add_type('Test::Factory::DBI::Type::Str');
__PACKAGE__->add_type('DBIx::DataFactory::Type::Int');
__PACKAGE__->add_type('DBIx::DataFactory::Type::Num');
__PACKAGE__->add_type('DBIx::DataFactory::Type::Str');

use Smart::Args;
use DBIx::Inspector;
Expand All @@ -22,7 +22,7 @@ use SQL::Maker;
use Sub::Install;
use Class::Load qw/load_class/;

use Test::Factory::DBI::Type;
use DBIx::DataFactory::Type;

sub create_factory_method {
args my $class => 'ClassName',
Expand Down Expand Up @@ -109,7 +109,7 @@ sub _factory_method {
next;
}
elsif (ref $default eq 'HASH') {
my $value = Test::Factory::DBI->make_value_from_type_info($default);
my $value = DBIx::DataFactory->make_value_from_type_info($default);
$values->{$column} = $value;
next;
}
Expand All @@ -134,12 +134,12 @@ __END__
=head1 NAME
Test::Factory::DBI - [One line description of module's purpose here]
DBIx::DataFactory - [One line description of module's purpose here]
=head1 SYNOPSIS
use Test::Factory::DBI;
use DBIx::DataFactory;
=for author to fill in:
Brief code example(s) here showing commonest usage(s).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Test::Factory::DBI::Type;
package DBIx::DataFactory::Type;

use strict;
use warnings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package Test::Factory::DBI::Type::Int;
package DBIx::DataFactory::Type::Int;

use strict;
use warnings;
use Carp;

use base qw(Test::Factory::DBI::Type);
use base qw(DBIx::DataFactory::Type);

use Smart::Args;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package Test::Factory::DBI::Type::Num;
package DBIx::DataFactory::Type::Num;

use strict;
use warnings;
use Carp;

use base qw(Test::Factory::DBI::Type);
use base qw(DBIx::DataFactory::Type);

use Smart::Args;

Expand Down
19 changes: 19 additions & 0 deletions lib/DBIx/DataFactory/Type/Set.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package DBIx::DataFactory::Type::Set;

use strict;
use warnings;
use Carp;

use base qw(DBIx::DataFactory::Type);

use Smart::Args;

sub type_name { 'Set' }

sub make_value {
args my $class => 'ClassName',
my $set => 'ArrayRef';
return $set->[int rand(scalar @$set)];
}

1;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package Test::Factory::DBI::Type::Str;
package DBIx::DataFactory::Type::Str;

use strict;
use warnings;
use Carp;

use base qw(Test::Factory::DBI::Type);
use base qw(DBIx::DataFactory::Type);

use Smart::Args;
use String::Random;
Expand Down
4 changes: 2 additions & 2 deletions t/00-load.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use Test::More tests => 1;

BEGIN {
use_ok( 'Test::Factory::DBI' );
use_ok( 'DBIx::DataFactory' );
}

diag( "Testing Test::Factory::DBI $Test::Factory::DBI::VERSION" );
diag( "Testing DBIx::DataFactory $DBIx::DataFactory::VERSION" );
53 changes: 38 additions & 15 deletions t/01-base.t
Original file line number Diff line number Diff line change
@@ -1,33 +1,56 @@
package test::Test::Factory::DBI;
package test::DBIx::DataFactory;
use strict;
use warnings;
use Test::More tests => 1;

use Test::Factory::DBI;
use DBIx::DataFactory;
use String::Random;

Test::Factory::DBI->username('nobody');
Test::Factory::DBI->password('nobody');
Test::Factory::DBI->create_factory_method(
method => 'create_factory',
# DBIx::DataFactory->username('nobody');
# DBIx::DataFactory->password('nobody');
# DBIx::DataFactory->create_factory_method(
# method => 'create_factory',
# dbi => 'dbi:mysql:dbname=test_factory;host=localhost',
# table => 'test_factory',
# columns => {
# int => {
# type => 'Int',
# size => 10,
# },
# double => {
# type => 'Num',
# size => 5,
# },
# string => {
# type => 'Set',
# set => ['test', 'test2', 'test3'],
# },
# },
# );

# my $factory = create_factory(nullable => 100);
# use Data::Dumper;
# warn Dumper($factory);

use DBIx::DataFactory;
DBIx::DataFactory->username('nobody');
DBIx::DataFactory->password('nobody');
DBIx::DataFactory->create_factory_method(
method => 'create_factory_data',
dbi => 'dbi:mysql:dbname=test_factory;host=localhost',
table => 'test_factory',
columns => {
int => {
type => 'Int',
size => 10,
},
double => {
type => 'Num',
size => 5,
},
string => {
type => 'Str',
size => 50,
}
size => 10,
},
},
);

my $factory = create_factory(nullable => 100);
use Data::Dumper;
warn Dumper($factory);
my $values = create_factory_data(
text => 'test text',
);
2 changes: 1 addition & 1 deletion t/02-random.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ use strict;
use warnings;
use Test::More tests => 1;

use Test::Factory::DBI::Random;
use DBIx::DataFactory::Random;

warn rand_int(5);
4 changes: 2 additions & 2 deletions t/03-type.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ use strict;
use warnings;
use Test::More tests => 1;

use Test::Factory::DBI::Type;
use DBIx::DataFactory::Type;

warn Test::Factory::DBI::Type->type_to_random_sub('num')->(3);
warn DBIx::DataFactory::Type->type_to_random_sub('num')->(3);

0 comments on commit 6efb14f

Please sign in to comment.