|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 3; |
| 21 |
|
21 |
|
| 22 |
use Template::Context; |
22 |
use Template::Context; |
| 23 |
use Template::Stash; |
23 |
use Template::Stash; |
|
Lines 25-32
use Template::Stash;
Link Here
|
| 25 |
use C4::Auth; |
25 |
use C4::Auth; |
| 26 |
use Koha::Cache::Memory::Lite; |
26 |
use Koha::Cache::Memory::Lite; |
| 27 |
use Koha::Database; |
27 |
use Koha::Database; |
|
|
28 |
use Koha::Patrons; |
| 28 |
use Koha::Template::Plugin::Koha; |
29 |
use Koha::Template::Plugin::Koha; |
| 29 |
|
30 |
|
|
|
31 |
use t::lib::TestBuilder; |
| 32 |
|
| 30 |
my $schema = Koha::Database->new->schema; |
33 |
my $schema = Koha::Database->new->schema; |
| 31 |
|
34 |
|
| 32 |
subtest 'GenerateCSRF() tests' => sub { |
35 |
subtest 'GenerateCSRF() tests' => sub { |
|
Lines 75-77
subtest 'GenerateCSRF - New CSRF token generated everytime we need one' => sub {
Link Here
|
| 75 |
$schema->storage->txn_rollback; |
78 |
$schema->storage->txn_rollback; |
| 76 |
|
79 |
|
| 77 |
}; |
80 |
}; |
| 78 |
- |
81 |
|
|
|
82 |
subtest 'GetObjectById tests' => sub { |
| 83 |
plan tests => 3; |
| 84 |
|
| 85 |
$schema->storage->txn_begin; |
| 86 |
|
| 87 |
my $session = C4::Auth::get_session(''); |
| 88 |
|
| 89 |
my $stash = Template::Stash->new( { sessionID => $session->id } ); |
| 90 |
my $context = Template::Context->new( { STASH => $stash } ); |
| 91 |
|
| 92 |
my $builder = t::lib::TestBuilder->new; |
| 93 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 94 |
|
| 95 |
my $plugin = Koha::Template::Plugin::Koha->new($context); |
| 96 |
|
| 97 |
my $patron2 = $plugin->GetObjectById('Koha::Patrons', $patron->id ); |
| 98 |
is( $patron->id, $patron2->id, "Got correct object via GetObjectById" ); |
| 99 |
|
| 100 |
my $invalid = $plugin->GetObjectById('Koha::Patrons', 'INVALID_ID' ); |
| 101 |
is( $invalid, undef, "Invalid ID returns undef" ); |
| 102 |
|
| 103 |
$invalid = $plugin->GetObjectById('Koha::Nothing', 1 ); |
| 104 |
is( $invalid, undef, "Invalid objects name returns undef" ); |
| 105 |
|
| 106 |
$schema->storage->txn_rollback; |
| 107 |
}; |