8 use SGN::Test::Fixture;
10 use_ok('CXGN::Stock');
12 my $f = SGN::Test::Fixture->new();
13 my $schema = $f->bcs_schema();
15 print STDERR "Create new stock... ";
16 my $new_s = CXGN::Stock->new(schema => $schema);
17 $new_s->uniquename("aniceuniquename");
18 $new_s->name("anicename");
19 $new_s->type("accession");
20 $new_s->description("blablabla");
21 my $new_s_id = $new_s->store();
23 my $copy_s = CXGN::Stock->new(schema => $schema, stock_id => $new_s_id);
24 is($copy_s->name(), $new_s->name(), "name save check");
25 is($copy_s->uniquename(), $new_s->uniquename(), "uniquename save check");
26 is($copy_s->type(), $new_s->type(), "type save check");
27 is($copy_s->type_id(), $new_s->type_id(), "type_id save check");
28 is($copy_s->description(), $new_s->description(), "description save check");
29 is($copy_s->is_obsolete(), $new_s->is_obsolete(), "obsolete save check");
30 is($copy_s->organism_id(), $new_s->organism_id(), "organism_id save check");
31 is($copy_s->stock_id(), $new_s->stock_id(), "stock_id save check");
33 $new_s->name("new_name");
34 $new_s->uniquename("new_uniquename");
36 $new_s->description("blablabla 2");
37 $new_s->is_obsolete(1);
40 my $update_s = CXGN::Stock->new(schema => $schema, stock_id => $new_s_id);
41 is($update_s->name(), "new_name", "update name check");
42 is($update_s->uniquename(), "new_uniquename", "update uniquename check");
43 is($update_s->description(), "blablabla 2", "update description check");
44 is($update_s->is_obsolete(), 1, "update obsolete check");
46 my $s = CXGN::Stock->new( schema => $schema, stock_id => 38846 );
48 print STDERR "OBJECTS: ".Dumper($s->objects());
49 print STDERR "SUJECTS: ".Dumper($s->subjects());
51 is($s->name(), "new_test_crossP001", "name check");
52 is($s->uniquename(), "new_test_crossP001", "uniquename check");
53 is($s->type_id(), 76392, 'type_id check');
54 is($s->description(), "", "description check");
55 is($s->is_obsolete(), 0, "obsolete check");
56 is($s->get_species(), "Solanum lycopersicum", "species check");
57 my @image_ids = $s->get_image_ids();
58 is_deeply(\@image_ids, [], "image ids check");
59 print STDERR Dumper(\@image_ids);
60 my @trait_list = $s->get_trait_list();
61 is_deeply(\@trait_list, [], "trait list check");
62 print STDERR Dumper(\@trait_list);
63 my @trial_list = $s->get_trials();
64 is_deeply(\@trial_list, [], "trials check");
65 print STDERR Dumper(\@trial_list);
66 my $pedigree = $s->get_parents(1);
68 # test a stock with trial data
69 my $t_s = CXGN::Stock->new(schema => $schema, stock_id => 38880);
70 @trial_list = $t_s->get_trials();
71 print STDERR Dumper(\@trial_list);
72 is_deeply(\@trial_list,
92 ], "trial list check");