Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added basic list item tests

  • Loading branch information...
commit b12260e9f374dc43b749721fe1213acc1d227bc9 1 parent f9429d5
@davorg authored
Showing with 49 additions and 0 deletions.
  1. +48 −0 t/Test/Lystyng/Schema/Result/ListItem.pm
  2. +1 −0  t/tests.t
View
48 t/Test/Lystyng/Schema/Result/ListItem.pm
@@ -0,0 +1,48 @@
+package Test::Lystyng::Schema::Result::List::Util;
+
+use base qw(Test::Class);
+use Test::More;
+use Moose;
+
+with 'Test::Role::WithSchema';
+
+sub basic : Tests {
+ my $self = shift;
+
+ my $user_rs = $self->schema->resultset('User');
+ my $list_rs = $self->schema->resultset('List');
+ my $item_rs = $self->schema->resultset('ListItem');
+ my $user = $user_rs->create({
+ username => 'user',
+ password => 'pass',
+ email => 'user@example.com',
+ });
+ $user->add_to_lists({
+ title => 'test list',
+ slug => 'test',
+ });
+
+ my $list = $user->lists->first;
+ my $item = $list->add_to_list_items({
+ title => 'test item',
+ });
+
+ ok($item, 'Got an item_rs');
+ isa_ok($item, 'Lystyng::Schema::Result::ListItem');
+
+ is(scalar $list->list_items, 1, 'List has one item');
+
+ my ($item2) = $item_rs->search({
+ list => $list->id,
+ title => 'test item',
+ });
+
+ ok($item2, 'Got a list item from the database...');
+ is($item2->title, 'test item', '... and it has the correct title');
+
+ $item_rs->delete;
+ $list_rs->delete;
+ $user_rs->delete;
+}
+
+1;
View
1  t/tests.t
@@ -5,5 +5,6 @@ use Test::Class;
use Test::Lystyng::Schema;
use Test::Lystyng::Schema::Result::User;
use Test::Lystyng::Schema::Result::List;
+use Test::Lystyng::Schema::Result::ListItem;
Test::Class->runtests;
Please sign in to comment.
Something went wrong with that request. Please try again.