This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/alias_editor/test.php

87 lines
2.8 KiB
PHP
Raw Normal View History

<?php
class AliasEditorTest extends ShimmieWebTestCase {
function testAliasEditor() {
2012-03-09 22:08:55 +00:00
$this->get_page('alias/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Alias List");
// Check that normal users can't add aliases.
$this->log_in_as_user();
$this->get_page('alias/list');
$this->assert_title("Alias List");
$this->assert_no_text("Add");
$this->log_out();
$this->log_in_as_admin();
2009-07-16 19:20:53 +00:00
# test one to one
2012-03-09 22:08:55 +00:00
$this->get_page('alias/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Alias List");
$this->set_field('oldtag', "test1");
$this->set_field('newtag', "test2");
2014-02-22 08:10:59 +00:00
$this->clickSubmit('Add');
$this->assert_no_text("Error adding alias");
2014-02-19 21:24:47 +00:00
2014-02-19 09:27:29 +00:00
$this->get_page('alias/list');
2014-02-19 23:36:38 +00:00
$this->assert_text("test1");
2014-02-19 21:24:47 +00:00
2009-07-16 19:20:53 +00:00
$this->get_page("alias/export/aliases.csv");
2009-08-19 00:28:48 +00:00
$this->assert_text("test1,test2");
2009-07-16 19:20:53 +00:00
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test1");
$this->get_page("post/view/$image_id"); # check that the tag has been replaced
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: test2");
2009-07-16 19:20:53 +00:00
$this->get_page("post/list/test1/1"); # searching for an alias should find the master tag
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: test2");
2009-07-16 19:20:53 +00:00
$this->get_page("post/list/test2/1"); # check that searching for the main tag still works
2009-08-19 00:28:48 +00:00
$this->assert_title("Image $image_id: test2");
2009-07-16 19:20:53 +00:00
$this->delete_image($image_id);
2012-03-09 22:08:55 +00:00
$this->get_page('alias/list');
2009-07-16 19:20:53 +00:00
$this->click("Remove");
2014-02-17 06:52:30 +00:00
$this->get_page('alias/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Alias List");
$this->assert_no_text("test1");
2009-07-16 19:20:53 +00:00
# test one to many
2012-03-09 22:08:55 +00:00
$this->get_page('alias/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Alias List");
$this->set_field('oldtag', "onetag");
$this->set_field('newtag', "multi tag");
2009-07-16 19:20:53 +00:00
$this->click("Add");
2014-02-19 09:27:29 +00:00
$this->get_page('alias/list');
2009-08-19 00:28:48 +00:00
$this->assert_text("multi");
$this->assert_text("tag");
2009-07-16 19:20:53 +00:00
$this->get_page("alias/export/aliases.csv");
2009-08-19 00:28:48 +00:00
$this->assert_text("onetag,multi tag");
2009-07-16 19:20:53 +00:00
$image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "onetag");
$image_id_2 = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "onetag");
// FIXME: known broken
//$this->get_page("post/list/onetag/1"); # searching for an aliased tag should find its aliases
2009-08-19 00:28:48 +00:00
//$this->assert_title("onetag");
//$this->assert_no_text("No Images Found");
2009-07-16 19:20:53 +00:00
$this->get_page("post/list/multi/1");
2009-08-19 00:28:48 +00:00
$this->assert_title("multi");
$this->assert_no_text("No Images Found");
2009-07-16 19:20:53 +00:00
$this->get_page("post/list/multi%20tag/1");
2009-08-19 00:28:48 +00:00
$this->assert_title("multi tag");
$this->assert_no_text("No Images Found");
2009-07-16 19:20:53 +00:00
$this->delete_image($image_id_1);
$this->delete_image($image_id_2);
2012-03-09 22:08:55 +00:00
$this->get_page('alias/list');
2009-07-16 19:20:53 +00:00
$this->click("Remove");
2014-02-19 09:27:29 +00:00
$this->get_page('alias/list');
2009-08-19 00:28:48 +00:00
$this->assert_title("Alias List");
$this->assert_no_text("test1");
2009-07-16 19:20:53 +00:00
$this->log_out();
2009-09-19 22:03:47 +00:00
2012-03-09 22:08:55 +00:00
$this->get_page('alias/list');
2009-09-19 22:03:47 +00:00
$this->assert_title("Alias List");
$this->assert_no_text("Add");
}
}
?>