From cd9564984b42e8a97b2fbe28b509deb2a50369a3 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Fri, 15 May 2009 20:26:18 +0000 Subject: [PATCH] Add a test to prove that an edit link is created correctly when linking to a local image that doesn't exist, yet. --- t/static-copy.t | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/t/static-copy.t b/t/static-copy.t index 506487f7..ffa74eef 100644 --- a/t/static-copy.t +++ b/t/static-copy.t @@ -1,4 +1,4 @@ -# Copyright (C) 2007, 2008 Alex Schroeder +# Copyright (C) 2007, 2008, 2009 Alex Schroeder # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ require 't/test.pl'; package OddMuse; -use Test::More tests => 12; +use Test::More tests => 13; clear_pages(); add_module('static-copy.pl'); @@ -85,10 +85,15 @@ ok(-f "$DataDir/static/Logo.png", "$DataDir/static/Logo.png exists"); # Make sure spaces are translated to underscores (fixed in image.pl) add_module('image.pl'); -xpath_run_tests(split('\n',<<'EOT')); -[[image/right:bar baz]] -//a[@class="image right"][@href="http://localhost/test.pl/bar_baz"]/img[@class="upload"][@src="http://localhost/test.pl/download/bar_baz"][@alt="bar baz"] -EOT +# Now, create real pages. First, we'll use the ordinary image link to +# a non-existing page. This should give us an edit link. +xpath_test(update_page('test_image', '[[image:bar baz]]'), + '//a[@class="edit"][@title="Click to edit this page"][@rel="nofollow"][@href="http://localhost/wiki.pl?action=edit;id=bar_baz;upload=1"]'); +# The same should be true for the image extension. xpath_test(update_page('test_image', '[[image/right:bar baz]]'), - '//a[@class="image right"][@href="http://localhost/wiki.pl/bar_baz"]/img[@class="upload"][@src="/static/bar_baz.html"][@alt="bar baz"]'); + '//a[@class="edit"][@title="Click to edit this page"][@rel="nofollow"][@href="http://localhost/wiki.pl?action=edit;id=bar_baz;upload=1"]'); + +# Next, using a real page. The image type is used appropriately. +xpath_test(update_page('test_image', '[[image/right:Logo]]'), + '//a[@class="image right"][@href="http://localhost/wiki.pl/Logo"]/img[@class="upload"][@src="/static/Logo.png"][@alt="Logo"]');