DBD::Mock::Session::GenerateFixtures - When a real DBI database handle ($dbh) is provided, the module generates DBD::Mock::Session data. Otherwise, it returns a DBD::Mock::Session object populated with generated data. This not a part form DBD::Mock::Session distribution just a wrapper around it.
# Case 1: Providing a pre-existing DBI database handle for genereting a mocked data files with the test name
my $mock_dumper = DBD::Mock::Session::GenerateFixtures->new({ dbh => $dbh });
my $real_dbh = $mock_dumper->get_dbh();
# Case 2: Read data from the same file as current test
my $mock_dumper = DBD::Mock::Session::GenerateFixtures->new();
my $dbh = $mock_dumper->get_dbh();
# Your code using the mock DBD
# Case 3: Read data from a coustom file
my $mock_dumper = DBD::Mock::Session::GenerateFixtures->new({ file => 'path/to/fixture.json' });
my $dbh = $mock_dumper->get_dbh();
# Your code using the mock DBD
# Case 4: Providing an array reference containing mock data
my $mock_dumper = DBD::Mock::Session::GenerateFixtures->new({ data => \@mock_data });
my $dbh = $mock_dumper->get_dbh();
# Your code using the mock DBD
cpanm DBD::Mock::Session::GenerateFixtures
Or direct form the repo:
git clone git@github.com:DragosTrif/DBD-Fixtures.git
perl Makefile.PL
make test
make install