File: after_update.t

package info (click to toggle)
libdbix-class-perl 0.082843-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (28 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (7)
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
use strict;
use warnings;

use Test::More;
use lib qw(t/lib);
use DBICTest;

my $schema = DBICTest->init_schema();

plan tests => 2;

my $bookmark = $schema->resultset("Bookmark")->find(1);
my $link = $bookmark->link;
my $link_id = $link->id;

my $new_link = $schema->resultset("Link")->new({
    id      => 42,
    url     => "http://monstersarereal.com",
    title   => "monstersarereal.com"
});

# Changing a relationship by id rather than by object would cause
# old related_resultsets to be used.
$bookmark->link($new_link->id);
is $bookmark->link->id, $new_link->id;

$bookmark->update;
is $bookmark->link->id, $new_link->id;