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 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 with perl v5.36.0, dated 2023-01-29, under the Test::...opulate(3pm) banner β€” mwah, go populate some fixtures bestie, you've got this πŸ’…βœ¨πŸŒΈ
πŸ“¦ where this page comes from