File: StorageValues.t

package info (click to toggle)
libdbix-class-helpers-perl 2.036000-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,008 kB
  • sloc: perl: 5,041; sql: 537; makefile: 7
file content (36 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!perl

use strict;
use warnings;

use lib 't/lib';
use Test::More;
use Test::Deep;

use TestSchema;
my $schema = TestSchema->deploy_or_connect();
$schema->prepopulate;

my $first = $schema->resultset('Bar')->search(undef, { order_by => 'id' })->first;

is($first->foo_id, 1, 'foo_id starts as 1');
is($first->get_storage_value('foo_id'), 1, 'foo_id storage value starts as 1');
$first->foo_id(2);
is($first->foo_id, 2, 'foo_id changes to 2');
is($first->get_storage_value('foo_id'), 1, 'foo_id storage value is still 1');
$first->update;
is($first->get_storage_value('foo_id'), 2, 'foo_id storage value is updated to 2');

my $new = $schema->resultset('Bar')->new({
   id => 999,
   foo_id => 1,
});
is($new->foo_id, 1, 'new row of course has set values');
is($new->get_storage_value('foo_id'), undef, 'and storage values are unset');
$new->foo_id(2);
is($new->foo_id, 2, 'updated row has new value');
is($new->get_storage_value('foo_id'), undef, 'but storage values are unchanged');
$new->insert;
is($new->get_storage_value('foo_id'), 2, 'storage value updated after insert');

done_testing;