Test::...Handle(3pm)

πŸ“¦
version 1.113 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Test::...Handle(3pm) πŸ’–

okay bestie, welcome to Test::Database::Handle β€” this one lives in the User Contributed Perl Documentation section of the manual, and it's genuinely one of the chillest little classes you'll ever meet. no cap.


✨ NAME ✨

Test::Database::Handle β€” a class for Test::Database handles πŸŽ€


🌸 SYNOPSIS 🌸

use Test::Database;

my $handle = Test::Database->handle(@requests);
my $dbh    = $handle->dbh();

like… that's it. that's the whole vibe. you ask for a handle, you get a handle, you get a dbh. slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Test::Database::Handle is a very simple class whose whole job is encapsulating the information about a test database handle. she's not doing too much. she's just holding your stuff. queen behavior honestly.

so here's the deal: inside a test script, Test::Database::Handle objects are the way you get the info you need about a test database handle. and where do the handles come from, you ask? you grab them through the Test::Database->handles() method or the Test::Database->handle() method. those are the plug. πŸ”Œβœ¨


πŸ”₯ METHODS πŸ”₯

Test::Database::Handle provides the following methods, bestie, and there aren't many, so no stress:

🧚 new 🧚

Return a new Test::Database::Handle with the given parameters: dsn, username, password.

the only mandatory argument is dsn. everything else can just… not exist. she's low maintenance like that. πŸ’œ


πŸ‘‘ ACCESSORS πŸ‘‘

the following accessors are available. come get y'all info:

πŸ“ dsn

Return the Data Source Name. that's the whole thing. that's the tea. πŸ«–

πŸ“ username

Return the connection username. defaults to undef.

πŸ“ password

Return the connection password. defaults to undef.

🌈 connection_info

Return the connection information triplet β€” that's dsn, username, password, all together, as a little squad:

my ( $dsn, $username, $password ) = $handle->connection_info;

look at them. iconic trio. ✨

πŸ’€ dbh

my $dbh = $handle->dbh;
my $dbh = $handle->dbh( $attr );

Return the DBI database handle you get when connecting with the connection triplet returned by connection_info(). yes, that triplet. the iconic one.

the optional parameter $attr is a reference to a hash of connection attributes, and it gets passed directly to DBI's connect() method. no middleman, no filter. straight through. periodt. πŸ’…

🌸 name

Return the database name attached to the handle.

⭐ dbd

Return the DBI driver name, as computed from the dsn.

πŸŽ€ driver

Return the Test::Database::Driver object attached to the handle. she comes with a plus-one. πŸ’–


πŸ’œ AUTHOR πŸ’œ

Philippe Bruhat (BooK), "<book@cpan.org>"


Copyright 2008-2010 Philippe Bruhat (BooK), all rights reserved.


🌈 LICENSE 🌈

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


ok and that's the whole page, bestie!! no notes, she ate, fr fr πŸ”₯

and for the cute sign-off: this little slice of documentation came from perl v5.32.1, dated 2021-11-12, and the page itself is Test::...Handle(3pm) 🫢 mwah, go write some tests πŸ’–βœ¨

πŸ“¦ where this page comes from