Commits

Anonymous committed d8871e8

Nav-Menu:

Added the beginning of the get_cross_host_rel_url test function.

Comments (0)

Files changed (3)

 t/09leading-path.t
 t/10ul-classes.t
 t/11predicate.t
+t/12x-host-rel-url.t
 lib/HTML/Widgets/NavMenu/HeaderRole.pm
 lib/HTML/Widgets/NavMenu/Iterator/Base.pm
 lib/HTML/Widgets/NavMenu/Iterator/Html.pm
-* Encapsulate the propogation of the state 
-    ($x->{'url_type'} || $parent->{'url_type'}) in one place.
-
 * Write a unit-test for HTML::Widgets::NavMenu::get_cross_host_rel_url().
 
 * Include an "url_is_abs" flag that specifies that the url specified in 

module/t/12x-host-rel-url.t

+#!/usr/bin/perl -w
+
+use strict;
+
+use Test::More tests => 3;
+
+use HTML::Widgets::NavMenu;
+
+{
+    my $nav_menu = HTML::Widgets::NavMenu->new(
+        'path_info' => "/path1/path2/",
+        'current_host' => "shlomif",
+        'hosts' => 
+        {
+            'shlomif' =>
+            {
+                'base_url' => "http://www.shlomifish.org/",
+                'trailing_url_base' => "/",
+            },
+            'vipe' =>
+            {
+                'base_url' => "http://vipe.technion.ac.il/~shlomif/",
+                'trailing_url_base' => "/~shlomif/",
+            },
+        },
+        # This is just to settle the constructor
+        'tree_contents' =>
+        {
+            'host' => "shlomif",
+            'text' => "Top 1",
+            'title' => "T1 Title",
+        },
+    );
+    
+    # TEST*3
+    foreach my $url_type (qw(rel site_abs full_abs))
+    {
+        is ( 
+            $nav_menu->get_cross_host_rel_url(
+                'host' => "vipe",
+                'host_url' => "hello/",
+                'url_type' => $url_type,
+            ), "http://vipe.technion.ac.il/~shlomif/hello/",
+            "Testing for cross-host URL of $url_type."
+        );
+    }
+}
+