| 1 | #!/usr/bin/perl |
|---|
| 2 | # $Id$ |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | |
|---|
| 6 | use lib 't/lib'; |
|---|
| 7 | use lib 'lib'; |
|---|
| 8 | use lib 'extlib'; |
|---|
| 9 | |
|---|
| 10 | use Test::More tests => 31; |
|---|
| 11 | |
|---|
| 12 | use MT; |
|---|
| 13 | use MT::Blog; |
|---|
| 14 | use MT::Entry; |
|---|
| 15 | |
|---|
| 16 | use vars qw( $DB_DIR $T_CFG ); |
|---|
| 17 | |
|---|
| 18 | use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib'; |
|---|
| 19 | use MT::Test qw(:db :data); |
|---|
| 20 | |
|---|
| 21 | my $mt = MT->instance( Config => $T_CFG ) or die MT->errstr; |
|---|
| 22 | isa_ok($mt, 'MT'); |
|---|
| 23 | |
|---|
| 24 | my $blog = MT::Blog->load(1); |
|---|
| 25 | isa_ok($blog, 'MT::Blog'); |
|---|
| 26 | |
|---|
| 27 | my $entry = MT::Entry->load(1); |
|---|
| 28 | isa_ok($entry, 'MT::Entry'); |
|---|
| 29 | is($entry->blog_id, $blog->id, 'blog id'); |
|---|
| 30 | is($entry->status, MT::Entry::RELEASE(), 'status'); |
|---|
| 31 | is($entry->status, 2, 'status 2'); |
|---|
| 32 | is($entry->title, 'A Rainy Day', 'title'); |
|---|
| 33 | is($entry->allow_comments, 1, 'allow_comments 1'); |
|---|
| 34 | is($entry->excerpt, 'A story of a stroll.', 'excerpt'); |
|---|
| 35 | is($entry->text, 'On a drizzly day last weekend,', 'text'); |
|---|
| 36 | is($entry->text_more, 'I took my grandpa for a walk.', 'text_more'); |
|---|
| 37 | |
|---|
| 38 | is(MT::Entry::status_text(1), 'Draft', 'Draft'); |
|---|
| 39 | is(MT::Entry::status_text($entry->status), 'Publish', 'Publish'); |
|---|
| 40 | is(MT::Entry::status_int('Draft'), 1, 'Draft 1'); |
|---|
| 41 | is(MT::Entry::status_int('Publish'), 2, 'Publish 2'); |
|---|
| 42 | is(MT::Entry::status_int('Future'), 4, 'Future 4'); |
|---|
| 43 | |
|---|
| 44 | my $author = $entry->author; |
|---|
| 45 | isa_ok($author, 'MT::Author'); |
|---|
| 46 | is($author->name, 'Chuck D', 'name'); |
|---|
| 47 | #ok($author->id, 1); |
|---|
| 48 | |
|---|
| 49 | ## Test next and previous. |
|---|
| 50 | ## Test category, categories, and is_in_category. |
|---|
| 51 | ## Test permalink, archive_url, archive_file. |
|---|
| 52 | ## Test text_filters. |
|---|
| 53 | ## Test comments, comment_count, ping_count. |
|---|
| 54 | |
|---|
| 55 | ## Test entry auto-generation. |
|---|
| 56 | $entry->excerpt(''); |
|---|
| 57 | is($entry->excerpt, '', 'excerpt empty'); |
|---|
| 58 | is($entry->get_excerpt, $entry->text . '...', 'get_excerpt'); |
|---|
| 59 | $blog->words_in_excerpt(3); |
|---|
| 60 | is($entry->get_excerpt, 'On a drizzly...', 'get_excerpt'); |
|---|
| 61 | $entry->convert_breaks('textile_2'); |
|---|
| 62 | $entry->text("Foo _bar_ baz"); |
|---|
| 63 | is($entry->get_excerpt, 'Foo bar baz...', 'get_excerpt'); |
|---|
| 64 | |
|---|
| 65 | ## Test TrackBack object generation. |
|---|
| 66 | $entry->allow_pings(1); |
|---|
| 67 | ok($entry->save, 'save'); |
|---|
| 68 | my $tb = MT::Trackback->load({ entry_id => $entry->id }); |
|---|
| 69 | isa_ok($tb, 'MT::Trackback'); |
|---|
| 70 | is($tb->entry_id, $entry->id, 'entry_id'); |
|---|
| 71 | is($tb->description, $entry->get_excerpt, 'description'); |
|---|
| 72 | is($tb->title, $entry->title, 'title'); |
|---|
| 73 | is($tb->url, $entry->permalink, 'url'); |
|---|
| 74 | is($tb->is_disabled, 0, 'is_disabled'); |
|---|
| 75 | $entry->allow_pings(0); |
|---|
| 76 | ok($entry->save, 'save'); |
|---|
| 77 | $tb = MT::Trackback->load({ entry_id => $entry->id }); |
|---|
| 78 | is($tb->is_disabled, 1, 'is_disabled'); |
|---|