NAME

SQL::Bibliosoph::Sims - A SQL::Bibliosoph Tester library

SYNOPSIS

my $bs = SQL::Bibliosoph::Sims();

my $array_of_hashes = $bs->h_ANYQUERY();
my $hash            = $bs->rowh_ANYQUERY();
my $array_of_arrays = $bs->ANYQUERY();

This is a simple class to replace SQL::Bibliosoph in unit test. This generate random data and does not need a catalog file. (Methods are handled on request with AUTOLOAD). The returned value is in concordance with the requested resulset( e.g.: If you ask for that hash (with the prefix rowh_) you will get a hashref).
    

DESCRIPTION

Will generate random date when you call any subrotine on it. This module is inspired on Test::Sims.

Constructor parameters

rows

This controls how many rows will be returned in the resultset. Defaults to 10.

presets

You can costumize the return of some particular query by using preset, like this:

my $bs = SQL::Bibliosoph::Sims(
                presets => {
                    rowh_user       => '{ name => "juan", age => "42" }',
                    rowh_costumer   => '{ 
                                name => "rand_words( size=>10 )", 
                                age =>  "rand_chars( size=>2 )",
                    }',
                }
);

Values in the array will be evaluated. You can use rand_ functions from Data::Random to generate your values.. presets queries have preference over presets_catalog quieres.

presets_catalog

You can also define catalog for tests. In this case, the queries not defined in the catalog will be random generated. The defined, will be evaluated:

my $bs = SQL::Bibliosoph::Sims->new(
                presets_catalog => 'tests.bb',
);

tests.bb:
--[ TITo ]
{ a=>1, b=>2 }
--[ rowh_RANDy ]    
{name => join "", rand_chars( set=> "alpha", min=>5, max=>7) } 
--[ rowh_RAND2y ]
 {name => join "", rand_chars( set=> "numeric", min=>5, max=>7) }
--[ h_RAND3 ]
[ { id => (join '',rand_chars(set=>"numeric")), name => join ('', rand_chars(set=>"alpha")), role_code => 1 }, ],
--[ h_RAND4 ]
[ { id =>1 }, { id => 2 }, { id => 3 } , ],

BUGS

If you use presets_catalog, arrays references [] rows MUST BE ended with a ',' (comma), like in:

--[ h_RAND4 ] [ { id =>1 }, { id => 2 }, { id => 3 } , ],