Test::DatabaseRow::Object(3pm) | User Contributed Perl Documentation | Test::DatabaseRow::Object(3pm) |
Test::DatabaseRow::Object - examine database rows
use Test::More tests => 1; use Test::DatabaseRow::Object; # setup the test my $tdr = Test::DatabaseRow::Object->new( sql_and_bind => "SELECT * FROM contacts WHERE cid = '123'", tests => [ name => "trelane" ], ); # do the test and get a result back my $result_object = $tdr->tests_ok(); # have those results render to Test::Builder $result_object->pass_to_test_builder("my database test");
This module provides the underlying functionality of "Test::DatabaseRow".
These are the read only accessors of the object. They may be (optionally) set at object creation time by passing their name and value to the constructor.
Each accessor may be queried by prefixing its name with the "has_" to determine if it has been set or not.
If this accessor is not passed then it will be populated on first use by executing the contents of "sql_and_bind" against the passed "dbh".
If this accessor is not passed then it will be populated on first use by using Test::Builder's explain function on "db_results"
This accessor will automatically coerce a simple scalar passed in into a single
If this accessor is not passed then it will be populated on first use by building SQL from the "where" and "table" accessors.
This accessor value should be a hashref of hashrefs, with the outer keys being the SQL comparison operator, the inner keys being the field names and the inner values being the values to match against. For example:
{ '=' => { first => "Fred", last => "Flintstone", }, 'like' => { address => "%Bedrock%" }, }
Values of "undef" will automatically converted into checks for NULLs.
This accessor automatically coerces array refs that are passed into a pure equals hashref. For example:
[ foo => "bar", bazz => "buzz" ]
Will be coerced into:
{ "=" => { foo => "bar", bazz => "buzz" } }
See "where" in Test::DatabaseRow for a more detailed explanation.
This flag only effects data that this module places into "db_resutls". If you manually populate this accessor this flag will have no effect.
This accessor value should be a hashref of hashrefs, with the outer keys being the Perl comparison operator, the inner keys being the field names and the inner values being the values to test against. For example:
{ 'eq' => { first => "Fred", last => "Flintstone", }, '=~' => { address => "%Bedrock%" }, }
This accessor automatically coerces array refs that are passed into a hashref structure, converting things that look like strings into "eq" tests, things that look like numbers into "==" tests and things that are references to regular expressions into "=~" tests. Foe example:
[ num => 123, letters => "abc", kinda => qr/substring/ ]
Will be coerced into
{ '==' => { num => 123, }, 'eq' => { letters => "abc", }, '=~' => { kinda => qr/substring/ }, }
See "tests" in Test::DatabaseRow for a more detailed explanation.
Bugs (and requests for new features) can be reported though the CPAN RT system: <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-DatabaseRow>
Alternatively, you can simply fork this project on github and send me pull requests. Please see <http://github.com/2shortplanks/Test-DatabaseRow>
Written by Mark Fowler mark@twoshortplanks.com
Copyright Profero 2003, 2004. Copyright Mark Fowler 2011.
Some code taken from Test::Builder, written by Michael Schwern. Some code taken from Regexp::Common, written by Damian Conway. Neither objected to its inclusion in this module.
Some code taken from Lingua::EN::Numbers::Ordinate, written by Sean M. Burke.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Test::DatabaseRow::Object, Test::DatabaseRow::Result, Test::More, DBI
2022-06-17 | perl v5.34.0 |