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

86 lines
3 KiB
PHP
Raw Normal View History

2020-01-26 13:19:35 +00:00
<?php declare(strict_types=1);
class AliasEditorTest extends ShimmiePHPUnitTestCase
{
public function testAliasList()
{
$this->get_page('alias/list');
$this->assert_response(200);
$this->assert_title("Alias List");
}
public function testAliasListReadOnly()
{
$this->log_in_as_user();
$this->get_page('alias/list');
$this->assert_title("Alias List");
$this->assert_no_text("Add");
$this->log_out();
$this->get_page('alias/list');
$this->assert_title("Alias List");
$this->assert_no_text("Add");
}
2009-07-16 19:20:53 +00:00
2020-01-29 00:49:21 +00:00
public function testAliasOneToOne()
{
$this->log_in_as_admin();
2014-02-22 20:33:55 +00:00
$this->get_page("alias/export/aliases.csv");
$this->assert_no_text("test1");
send_event(new AddAliasEvent("test1", "test2"));
$this->get_page('alias/list');
$this->assert_text("test1");
$this->get_page("alias/export/aliases.csv");
$this->assert_text('"test1","test2"');
2009-07-16 19:20:53 +00:00
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test1");
$this->get_page("post/view/$image_id"); # check that the tag has been replaced
$this->assert_title("Image $image_id: test2");
$this->get_page("post/list/test1/1"); # searching for an alias should find the master tag
$this->assert_response(302);
$this->get_page("post/list/test2/1"); # check that searching for the main tag still works
$this->assert_response(302);
$this->delete_image($image_id);
2009-07-16 19:20:53 +00:00
send_event(new DeleteAliasEvent("test1"));
$this->get_page('alias/list');
$this->assert_title("Alias List");
$this->assert_no_text("test1");
}
2009-07-16 19:20:53 +00:00
2020-01-29 00:49:21 +00:00
public function testAliasOneToMany()
{
$this->log_in_as_admin();
$this->get_page("alias/export/aliases.csv");
$this->assert_no_text("multi");
send_event(new AddAliasEvent("onetag", "multi tag"));
$this->get_page('alias/list');
$this->assert_text("multi");
$this->assert_text("tag");
$this->get_page("alias/export/aliases.csv");
$this->assert_text('"onetag","multi tag"');
2009-07-16 19:20:53 +00:00
$image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "onetag");
$image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "onetag");
$this->get_page("post/list/onetag/1"); # searching for an aliased tag should find its aliases
$this->assert_title("multi tag");
$this->assert_no_text("No Images Found");
$this->get_page("post/list/multi/1");
$this->assert_title("multi");
$this->assert_no_text("No Images Found");
$this->get_page("post/list/multi tag/1");
$this->assert_title("multi tag");
$this->assert_no_text("No Images Found");
$this->delete_image($image_id_1);
$this->delete_image($image_id_2);
2009-07-16 19:20:53 +00:00
send_event(new DeleteAliasEvent("onetag"));
$this->get_page('alias/list');
$this->assert_title("Alias List");
$this->assert_no_text("test1");
}
}