Adjusted autotagger tests
This commit is contained in:
parent
b4bde94516
commit
70560398e3
1 changed files with 28 additions and 55 deletions
|
@ -1,85 +1,58 @@
|
|||
<?php declare(strict_types=1);
|
||||
class AutoTaggerTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testAutoTagList()
|
||||
public function testAutoTagerList()
|
||||
{
|
||||
$this->get_page('alias/list');
|
||||
$this->get_page('auto_tag/list');
|
||||
$this->assert_response(200);
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_title("Auto-Tag List");
|
||||
}
|
||||
|
||||
public function testAliasListReadOnly()
|
||||
public function testAutoTaggerListReadOnly()
|
||||
{
|
||||
$this->log_in_as_user();
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->get_page('auto_tag/list');
|
||||
$this->assert_title("Auto-Tag");
|
||||
$this->assert_no_text("Add");
|
||||
|
||||
$this->log_out();
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->get_page('auto_tag/list');
|
||||
$this->assert_title("Auto-Tag List");
|
||||
$this->assert_no_text("Add");
|
||||
}
|
||||
|
||||
public function testAliasOneToOne()
|
||||
public function testAutoTag()
|
||||
{
|
||||
$this->log_in_as_admin();
|
||||
|
||||
$this->get_page("alias/export/aliases.csv");
|
||||
$this->get_page("auto_tag/export/auto_tag.csv");
|
||||
$this->assert_no_text("test1");
|
||||
|
||||
send_event(new AddAliasEvent("test1", "test2"));
|
||||
$this->get_page('alias/list');
|
||||
send_event(new AddAutoTagEvent("test1", "test2"));
|
||||
$this->get_page('auto_tag/list');
|
||||
$this->assert_text("test1");
|
||||
$this->get_page("alias/export/aliases.csv");
|
||||
$this->assert_text("test2");
|
||||
$this->get_page("auto_tag/export/auto_tag.csv");
|
||||
$this->assert_text('"test1","test2"');
|
||||
|
||||
$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->assert_title("Image $image_id: test1 test2");
|
||||
$this->delete_image($image_id);
|
||||
|
||||
send_event(new DeleteAliasEvent("test1"));
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("test1");
|
||||
}
|
||||
|
||||
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"');
|
||||
|
||||
$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);
|
||||
|
||||
send_event(new DeleteAliasEvent("onetag"));
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
send_event(new AddAutoTagEvent("test2", "test3"));
|
||||
|
||||
$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: test1 test2 test3");
|
||||
$this->delete_image($image_id);
|
||||
|
||||
send_event(new DeleteAutoTagEvent("test1"));
|
||||
send_event(new DeleteAutoTagEvent("test2"));
|
||||
$this->get_page('auto_tag/list');
|
||||
$this->assert_title("Auto-Tag List");
|
||||
$this->assert_no_text("test1");
|
||||
$this->assert_no_text("test2");
|
||||
$this->assert_no_text("test3");
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue