|
Lines 210-234
sub build_sample_item {
Link Here
|
| 210 |
)->store->get_from_storage; |
210 |
)->store->get_from_storage; |
| 211 |
} |
211 |
} |
| 212 |
|
212 |
|
| 213 |
=pod |
|
|
| 214 |
|
| 215 |
=head2 build_sample_ill_request |
| 216 |
|
| 217 |
Builds a sample ILL request with the supplied arguments. |
| 218 |
|
| 219 |
C<$args> is a hashref with the following optional keys: |
| 220 |
|
| 221 |
=over 4 |
| 222 |
|
| 223 |
=item * C<biblio_id> (default: a new sample biblio created with L<build_sample_biblio>) |
| 224 |
|
| 225 |
=item * C<backend> (default: Standard) |
| 226 |
|
| 227 |
=item * C<branchcode> (default: a random branch) |
| 228 |
|
| 229 |
=back |
| 230 |
|
| 231 |
=cut |
| 232 |
sub build_sample_ill_request { |
213 |
sub build_sample_ill_request { |
| 233 |
my ( $self, $args ) = @_; |
214 |
my ( $self, $args ) = @_; |
| 234 |
|
215 |
|
|
Lines 239-245
sub build_sample_ill_request {
Link Here
|
| 239 |
return $self->build_object( |
220 |
return $self->build_object( |
| 240 |
{ |
221 |
{ |
| 241 |
class => 'Koha::ILL::Requests', |
222 |
class => 'Koha::ILL::Requests', |
| 242 |
value => $args, |
223 |
value => $args, |
| 243 |
} |
224 |
} |
| 244 |
)->store->get_from_storage; |
225 |
)->store->get_from_storage; |
| 245 |
} |
226 |
} |
|
Lines 751-763
Note that you should wrap these actions in a transaction yourself.
Link Here
|
| 751 |
|
732 |
|
| 752 |
my $builder = t::lib::TestBuilder->new; |
733 |
my $builder = t::lib::TestBuilder->new; |
| 753 |
|
734 |
|
| 754 |
Constructor - Returns the object TestBuilder |
735 |
Constructor - Returns the object TestBuilder |
| 755 |
|
736 |
|
| 756 |
=head2 schema |
737 |
=head2 schema |
| 757 |
|
738 |
|
| 758 |
my $schema = $builder->schema; |
739 |
my $schema = $builder->schema; |
| 759 |
|
740 |
|
| 760 |
Getter - Returns the schema of DBIx::Class |
741 |
Getter - Returns the schema of DBIx::Class |
| 761 |
|
742 |
|
| 762 |
=head2 delete |
743 |
=head2 delete |
| 763 |
|
744 |
|
|
Lines 766-807
Note that you should wrap these actions in a transaction yourself.
Link Here
|
| 766 |
records => $patron, # OR: records => [ $patron, ... ], |
747 |
records => $patron, # OR: records => [ $patron, ... ], |
| 767 |
}); |
748 |
}); |
| 768 |
|
749 |
|
| 769 |
Delete individual records, created by builder. |
750 |
Delete individual records, created by builder. |
| 770 |
Returns the number of delete attempts, or undef. |
751 |
Returns the number of delete attempts, or undef. |
| 771 |
|
752 |
|
| 772 |
=head2 build |
753 |
=head2 build |
| 773 |
|
754 |
|
| 774 |
$builder->build({ source => $source_name, value => $value }); |
755 |
$builder->build({ source => $source_name, value => $value }); |
| 775 |
|
756 |
|
| 776 |
Create a test record in the table, represented by $source_name. |
757 |
Create a test record in the table, represented by $source_name. |
| 777 |
The name is required and must conform to the DBIx::Class schema. |
758 |
The name is required and must conform to the DBIx::Class schema. |
| 778 |
Values may be specified by the optional $value hashref. Will be |
759 |
Values may be specified by the optional $value hashref. Will be |
| 779 |
randomized otherwise. |
760 |
randomized otherwise. |
| 780 |
If needed, TestBuilder creates linked records for foreign keys. |
761 |
If needed, TestBuilder creates linked records for foreign keys. |
| 781 |
Returns the values of the new record as a hashref, or undef if |
762 |
Returns the values of the new record as a hashref, or undef if |
| 782 |
the record could not be created. |
763 |
the record could not be created. |
| 783 |
|
764 |
|
| 784 |
Note that build also supports recursive hash references inside the |
765 |
Note that build also supports recursive hash references inside the |
| 785 |
value hash for foreign key columns, like: |
766 |
value hash for foreign key columns, like: |
| 786 |
value => { |
767 |
value => { |
| 787 |
column1 => 'some_value', |
768 |
column1 => 'some_value', |
| 788 |
fk_col2 => { |
769 |
fk_col2 => { |
| 789 |
columnA => 'another_value', |
770 |
columnA => 'another_value', |
| 790 |
} |
|
|
| 791 |
} |
771 |
} |
| 792 |
The hash for fk_col2 here means: create a linked record with build |
772 |
} |
| 793 |
where columnA has this value. In case of a composite FK the hashes |
773 |
The hash for fk_col2 here means: create a linked record with build |
| 794 |
are merged. |
774 |
where columnA has this value. In case of a composite FK the hashes |
|
|
775 |
are merged. |
| 795 |
|
776 |
|
| 796 |
Realize that passing primary key values to build may result in undef |
777 |
Realize that passing primary key values to build may result in undef |
| 797 |
if a record with that primary key already exists. |
778 |
if a record with that primary key already exists. |
| 798 |
|
779 |
|
| 799 |
=head2 build_object |
780 |
=head2 build_object |
| 800 |
|
781 |
|
|
|
782 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' [, value => { ... }] }); |
| 783 |
|
| 801 |
Given a plural Koha::Object-derived class, it creates a random element, and |
784 |
Given a plural Koha::Object-derived class, it creates a random element, and |
| 802 |
returns the corresponding Koha::Object. |
785 |
returns the corresponding Koha::Object. |
| 803 |
|
786 |
|
| 804 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' [, value => { ... }] }); |
787 |
=head2 build_sample_ill_request |
|
|
788 |
|
| 789 |
my $ill_request = $builder->build_sample_ill_request({ biblio_id => $biblio_id }); |
| 790 |
|
| 791 |
Builds a sample ILL request with the supplied arguments. |
| 792 |
|
| 793 |
C<$args> is a hashref with the following optional keys: |
| 794 |
|
| 795 |
=over 4 |
| 796 |
|
| 797 |
=item * C<biblio_id> (default: a new sample biblio created with L<build_sample_biblio>) |
| 798 |
|
| 799 |
=item * C<backend> (default: Standard) |
| 800 |
|
| 801 |
=item * C<branchcode> (default: a random branch) |
| 802 |
|
| 803 |
=back |
| 805 |
|
804 |
|
| 806 |
=head1 AUTHOR |
805 |
=head1 AUTHOR |
| 807 |
|
806 |
|
| 808 |
- |
|
|