t::lib::TestBuilder.pm - Koha module to simplify the writing of tests
use t::lib::TestBuilder;
Koha module to insert the foreign keys automatically for the tests
This module allows to insert automatically an entry in the database. All the database changes are wrapped in a transaction. The foreign keys are created according to the DBIx::Class schema. The taken values are the values by default if it is possible or randomly generated.
$builder = t::lib::TestBuilder->new()
Constructor - Begins a transaction and returns the object TestBuilder
$schema = $builder->schema
Getter - Returns the schema of DBIx::Class
$builder->clear({ source => $source_name })
$source_name
is the name of the source in the DBIx::Class schema (required)Clears all the data of this source (database table)
$builder->build({ source => $source_name, value => $value, only_fk => $only_fk, })
$source_name
is the name of the source in the DBIx::Class schema (required)$value
is the values for the entry (optional)$only_fk
is a boolean to indicate if only the foreign keys are created (optional)Inserts an entry in the database by instanciating all the foreign keys. The values can be specified, the values which are not given are default values if they exists or generated randomly. Returns the values of the entry as a hashref with an extra key : _fk which contains all the values of the generated foreign keys.
Yohann Dufour <yohann.dufour@biblibre.com>
Copyright 2014 - Biblibre SARL
This file is part of Koha.
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Koha; if not, see <http://www.gnu.org/licenses>.