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

91 lines
3.1 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
class AliasEditorTest extends ShimmiePHPUnitTestCase
{
2024-01-15 14:31:51 +00:00
public function testAliasList(): void
{
$this->get_page('alias/list');
$this->assert_response(200);
$this->assert_title("Alias List");
}
2024-01-15 14:31:51 +00:00
public function testAliasListReadOnly(): void
{
$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
2024-01-15 14:31:51 +00:00
public function testAliasOneToOne(): void
2020-01-29 00:49:21 +00:00
{
$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");
2024-02-11 14:51:55 +00:00
$this->post_page('alias/add', ['c_oldtag' => 'test1', 'c_newtag' => '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
2020-10-26 15:19:14 +00:00
$this->assert_title("Post $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
2024-02-11 14:51:55 +00:00
$this->post_page('alias/remove', ['d_oldtag' => 'test1']);
$this->get_page('alias/list');
$this->assert_title("Alias List");
$this->assert_no_text("test1");
}
2009-07-16 19:20:53 +00:00
2024-01-15 14:31:51 +00:00
public function testAliasOneToMany(): void
2020-01-29 00:49:21 +00:00
{
$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");
2020-10-26 15:19:14 +00:00
$this->assert_no_text("No Posts Found");
$this->get_page("post/list/multi/1");
$this->assert_title("multi");
2020-10-26 15:19:14 +00:00
$this->assert_no_text("No Posts Found");
$this->get_page("post/list/multi tag/1");
$this->assert_title("multi tag");
2020-10-26 15:19:14 +00:00
$this->assert_no_text("No Posts 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");
}
}