Test::...opulate(3pm)
π NAME π
Test::DBIx::Class::FixtureCommand::Populate β bestie, this is the little helper that installs your fixtures using Populate β¨
(This is the manual page for Test::DBIx::Class::FixtureCommand::Populate, in the 3pm Perl-modules section, just so you know exactly which page you're reading π«Ά)
π SYNOPSIS π
okay so the whole vibe is literally two lines:
my $command = Test::DBIx::Class::FixtureComand::Populate->new(schema=>$schema);
$command->install_fixtures($fixtures);
(yes, FixtureComand β that's how it's spelled in the synopsis, don't come for me, I copy exactly π)
πΈ DESCRIPTION πΈ
So here's the tea, bestie π: this thing leans on the "populate" in DBIx::Class::Schema method to actually install your fixture data. It expects a hash shaped like "Source => [\@fields, \@rows]". If you want the deep lore, go read the 'populate' method itself. But here's the look β¨:
->install_fixtures(
Person => [
['name', 'age'],
['john', 40],
['vincent', 15],
],
Job => [
[title => 'description'],
[programmer => 'Who wrote the code'],
[marketer => 'Who sold the code'],
],
);
And you can throw in as many Sources as your heart desires β literally as many as you like β and you can even include the same one more than once. No cap. π₯
Now, because different config formats are all valid and we're not here to yuck anybody's yum, it accepts three variations of the incoming arguments:
Variation one: Array of HashRefs π
## Array of HashRefs
->install_fixtures(
{Person => [
['name', 'age'],
['john', 40],
['vincent', 15],
]},
{Job => [
[title => 'description'],
[programmer => 'Who wrote the code'],
[marketer => 'Who sold the code'],
]},
);
Variation two: ArrayRef π¦
## ArrayRef
->install_fixtures([
Person => [
['name', 'age'],
['john', 40],
['vincent', 15],
],
Job => [
[title => 'description'],
[programmer => 'Who wrote the code'],
[marketer => 'Who sold the code'],
],
]);
Variation three: ArrayRef of HashRefs π
## ArrayRef of HashRefs
->install_fixtures([
{Person => [
['name', 'age'],
['john', 40],
['vincent', 15],
]},
{Job => [
[title => 'description'],
[programmer => 'Who wrote the code'],
[marketer => 'Who sold the code'],
]},
]);
The whole point, bestie: you get to model your fixtures in your configuration format of choice, without a whole lot of trouble. It's giving flexible. It's giving considerate. Periodt. π
β¨ METHODS β¨
This class defines the following methods, and yes we're going to walk through them like a tour guide π
π« install_fixtures
Takes an Array or an ArrayRef of arguments and installs them straight into your target database. Then it hands you back an array of hashrefs, where every single hashref is a {$source => @rows} pair. That's the whole deal π«Ά
π AUTHOR π
John Napiorkowski "<jjnapiork@cpan.org>" β absolute icon, we love them π
π COPYRIGHT & LICENSE π
Copyright 2009, John Napiorkowski "<jjnapiork@cpan.org>"
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Slay, honestly. π§
and that's the page!! generated withperl v5.36.0, dated2023-01-29, under theTest::...opulate(3pm)banner β mwah, go populate some fixtures bestie, you've got this π β¨πΈ
π¦ where this page comes from
- debian bookworm: libtest-dbix-class-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-dbix-class-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-dbix-class-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-dbix-class-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-dbix-class-perl 0.52-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms