Show
Ignore:
Timestamp:
06/24/07 03:10:37 (19 months ago)
Author:
kake
Message:

Fix changeset [1095] - categories and locales weren't getting linkified even if they _did_ exist.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/t/51_display_node.t

    r1095 r1098  
    33use OpenGuides::Config; 
    44use OpenGuides; 
     5use OpenGuides::Test; 
    56use Test::More; 
    67 
     
    1314} 
    1415 
    15 plan tests => 13; 
     16plan tests => 15; 
    1617 
    1718Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/node.db" } ); 
     
    2728                 template_path      => "./templates", 
    2829                 home_name          => "Home", 
     30                 admin_pass         => "password", 
    2931               } 
    3032); 
     
    6365unlike( $output, qr{^\QLocation: }ms, '...but not with redirect=0' ); 
    6466 
    65 $wiki->write_node( "Non-existent categories and locales", "foo", undef, 
    66                                 { category => [ "Does not exist" ], 
    67                                   locale   => [ "Does not exist" ] } ); 
     67# Write a node, then delete one each of its categories and locales. 
     68OpenGuides::Test->write_data( 
     69                              guide => $guide, 
     70                              node => "Non-existent categories and locales", 
     71                              categories => "Does Not Exist\r\nDoes Exist", 
     72                              locales => "Does Not Exist\r\nDoes Exist", 
     73                              return_output => 1, 
     74                            ); 
     75foreach my $id ( ( "Category Does Not Exist", "Locale Does Not Exist" ) ) { 
     76    $guide->delete_node( 
     77                         id => $id, 
     78                         password => "password", 
     79                         return_output => 1, 
     80                       ); 
     81} 
    6882 
     83# Check the display comes up right for the existent and nonexistent. 
    6984$output = $guide->display_node( id => 'Non-existent categories and locales', 
    7085                                return_output => 1 
     
    7287 
    7388unlike( $output, qr{\Q<a href="wiki.cgi?Category_Does_Not_Exist"}, 
    74     'Category name not linked if category does not exist' ); 
     89    "category name not linked if category does not exist" ); 
     90like( $output, qr{\Q<a href="wiki.cgi?Category_Does_Exist"}, 
     91    "...but does when it does exist" ); 
     92unlike( $output, qr{\Q<a href="wiki.cgi?Locale_Does_Not_Exist"}, 
     93    "locale name not linked if category does not exist" ); 
     94like( $output, qr{\Q<a href="wiki.cgi?Locale_Does_Exist"}, 
     95    "...but does when it does exist" ); 
    7596 
    76 $wiki->write_node( "Category_Does_Not_Exist", "bar", undef, undef ); 
     97# Check it works when the case is different too. 
     98OpenGuides::Test->write_data( 
     99                              guide => $guide, 
     100                              node => "Existent categories and locales", 
     101                              categories => "does exist", 
     102                              locales => "does exist", 
     103                              return_output => 1, 
     104                            ); 
    77105 
    78 $output = $guide->display_node( id => 'Non-existent categories and locales', 
     106$output = $guide->display_node( id => "Existent categories and locales", 
    79107                                return_output => 1 
    80108                              ); 
    81  
    82 like( $output, qr{\Q<a href="wiki.cgi?Category_Does_Not_Exist"}, 
    83     'but does when it does exist' ); 
    84  
    85 unlike( $output, qr{\Q<a href="wiki.cgi?Locale_Does_Not_Exist"}, 
    86     'Locale name not linked if category does not exist' ); 
    87  
    88 $wiki->write_node( "Locale_Does_Not_Exist", "wibble", undef, undef ); 
    89  
    90 $output = $guide->display_node( id => 'Non-existent categories and locales', 
    91                                 return_output => 1 
    92                               ); 
    93  
    94 like( $output, qr{\Q<a href="wiki.cgi?Locale_Does_Not_Exist"}, 
    95     'but does when it does exist' ); 
    96  
    97  
     109like( $output, qr{\Q<a href="wiki.cgi?Category_Does_Exist"}, 
     110    "wrongly-cased categories are linked as they should be" ); 
     111like( $output, qr{\Q<a href="wiki.cgi?Locale_Does_Exist"}, 
     112    "wrongly-cased locales are linked as they should be" );