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/favorites/test.php

45 lines
1.3 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
class FavoritesTest extends ShimmiePHPUnitTestCase
{
2024-01-15 14:31:51 +00:00
public function testFavorites(): void
{
global $user;
$this->log_in_as_user();
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test");
2009-07-28 10:45:21 +00:00
# No favourites
$this->get_page("post/view/$image_id");
2020-10-26 15:15:51 +00:00
$this->assert_title("Post $image_id: test");
$this->assert_no_text("Favorited By");
2009-07-28 10:45:21 +00:00
# Add a favourite
send_event(new FavoriteSetEvent($image_id, $user, true));
# Favourite shown on page
$this->get_page("post/view/$image_id");
2020-10-26 15:15:51 +00:00
$this->assert_title("Post $image_id: test");
$this->assert_text("Favorited By");
2009-07-28 10:45:21 +00:00
# Favourite shown on index
$page = $this->get_page("post/list/favorited_by=test/1");
$this->assertEquals(PageMode::REDIRECT, $page->mode);
# Favourite shown on user page
$this->get_page("user/test");
2020-10-26 15:15:51 +00:00
$this->assert_text("Posts favorited</a>: 1");
# Delete a favourite
send_event(new FavoriteSetEvent($image_id, $user, false));
# No favourites
$this->get_page("post/view/$image_id");
2020-10-26 15:15:51 +00:00
$this->assert_title("Post $image_id: test");
$this->assert_no_text("Favorited By");
}
2009-07-28 10:45:21 +00:00
}