Skip to content
This repository
Browse code

Added basic list item tests

  • Loading branch information...
commit b12260e9f374dc43b749721fe1213acc1d227bc9 1 parent f9429d5
Dave Cross authored January 30, 2014
48  t/Test/Lystyng/Schema/Result/ListItem.pm
... ...
@@ -0,0 +1,48 @@
  1
+package Test::Lystyng::Schema::Result::List::Util;
  2
+
  3
+use base qw(Test::Class);
  4
+use Test::More;
  5
+use Moose;
  6
+
  7
+with 'Test::Role::WithSchema';
  8
+
  9
+sub basic : Tests {
  10
+  my $self = shift;
  11
+
  12
+  my $user_rs = $self->schema->resultset('User');
  13
+  my $list_rs = $self->schema->resultset('List');
  14
+  my $item_rs = $self->schema->resultset('ListItem');
  15
+  my $user = $user_rs->create({
  16
+    username => 'user',
  17
+    password => 'pass',
  18
+    email    => 'user@example.com',
  19
+  });
  20
+  $user->add_to_lists({
  21
+      title => 'test list',
  22
+      slug  => 'test',
  23
+  });
  24
+
  25
+  my $list = $user->lists->first;
  26
+  my $item = $list->add_to_list_items({
  27
+    title => 'test item',
  28
+  });
  29
+
  30
+  ok($item, 'Got an item_rs');
  31
+  isa_ok($item, 'Lystyng::Schema::Result::ListItem');
  32
+
  33
+  is(scalar $list->list_items, 1, 'List has one item');
  34
+
  35
+  my ($item2) = $item_rs->search({
  36
+    list  => $list->id,
  37
+    title => 'test item',
  38
+  });
  39
+
  40
+  ok($item2, 'Got a list item from the database...');
  41
+  is($item2->title, 'test item', '... and it has the correct title');
  42
+
  43
+  $item_rs->delete;
  44
+  $list_rs->delete;
  45
+  $user_rs->delete;
  46
+}
  47
+
  48
+1;
1  t/tests.t
@@ -5,5 +5,6 @@ use Test::Class;
5 5
 use Test::Lystyng::Schema;
6 6
 use Test::Lystyng::Schema::Result::User;
7 7
 use Test::Lystyng::Schema::Result::List;
  8
+use Test::Lystyng::Schema::Result::ListItem;
8 9
 
9 10
 Test::Class->runtests;

0 notes on commit b12260e

Please sign in to comment.
Something went wrong with that request. Please try again.