Lines 16-21
Link Here
|
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
|
|
19 |
|
20 |
use Koha::Acquisition::Orders; |
19 |
use Koha::Cities; |
21 |
use Koha::Cities; |
20 |
|
22 |
|
21 |
# Dummy app for testing the plugin |
23 |
# Dummy app for testing the plugin |
Lines 34-57
get '/cities' => sub {
Link Here
|
34 |
$c->render( status => 200, json => $cities ); |
36 |
$c->render( status => 200, json => $cities ); |
35 |
}; |
37 |
}; |
36 |
|
38 |
|
|
|
39 |
get '/orders' => sub { |
40 |
my $c = shift; |
41 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
42 |
$c->validation->output($c->req->params->to_hash); |
43 |
my $orders = $c->objects->search(Koha::Acquisition::Orders->new); |
44 |
$c->render( status => 200, json => $orders ); |
45 |
}; |
46 |
|
37 |
# The tests |
47 |
# The tests |
38 |
use Test::More tests => 2; |
48 |
use Test::More tests => 3; |
39 |
use Test::Mojo; |
49 |
use Test::Mojo; |
40 |
|
50 |
|
41 |
use t::lib::TestBuilder; |
51 |
use t::lib::TestBuilder; |
42 |
use Koha::Database; |
52 |
use Koha::Database; |
43 |
|
53 |
|
44 |
my $schema = Koha::Database->new()->schema(); |
54 |
my $t = Test::Mojo->new; |
45 |
|
|
|
46 |
|
55 |
|
|
|
56 |
my $schema = Koha::Database->new()->schema(); |
47 |
my $builder = t::lib::TestBuilder->new; |
57 |
my $builder = t::lib::TestBuilder->new; |
48 |
|
58 |
|
49 |
subtest 'objects.search helper' => sub { |
59 |
subtest 'objects.search helper' => sub { |
50 |
|
60 |
|
51 |
plan tests => 34; |
61 |
plan tests => 34; |
52 |
|
62 |
|
53 |
my $t = Test::Mojo->new; |
|
|
54 |
|
55 |
$schema->storage->txn_begin; |
63 |
$schema->storage->txn_begin; |
56 |
|
64 |
|
57 |
# Remove existing cities to have more control on the search restuls |
65 |
# Remove existing cities to have more control on the search restuls |
Lines 128-135
subtest 'objects.search helper, sorting on mapped column' => sub {
Link Here
|
128 |
|
136 |
|
129 |
plan tests => 14; |
137 |
plan tests => 14; |
130 |
|
138 |
|
131 |
my $t = Test::Mojo->new; |
|
|
132 |
|
133 |
$schema->storage->txn_begin; |
139 |
$schema->storage->txn_begin; |
134 |
|
140 |
|
135 |
# Have complete control over the existing cities to ease testing |
141 |
# Have complete control over the existing cities to ease testing |
Lines 155-158
subtest 'objects.search helper, sorting on mapped column' => sub {
Link Here
|
155 |
->json_is('/1/name' => 'A'); |
161 |
->json_is('/1/name' => 'A'); |
156 |
|
162 |
|
157 |
$schema->storage->txn_rollback; |
163 |
$schema->storage->txn_rollback; |
158 |
} |
164 |
}; |
|
|
165 |
|
166 |
subtest 'objects.search helper, embed' => sub { |
167 |
|
168 |
plan tests => 2; |
169 |
|
170 |
$schema->storage->txn_begin; |
171 |
|
172 |
my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); |
173 |
|
174 |
$t->get_ok('/orders?order_id=' . $order->ordernumber) |
175 |
->json_is('/0',$order->to_api({ embed => ( { fund => {} } ) })); |
176 |
|
177 |
$schema->storage->txn_rollback; |
178 |
}; |
159 |
- |
|
|