test disambiguated episode action search

This commit is contained in:
thrillfall 2023-02-24 19:37:50 +01:00
parent 063c19654a
commit a6a19df999
2 changed files with 35 additions and 3 deletions

View File

@ -3,9 +3,6 @@ declare(strict_types=1);
namespace tests\Integration\Controller;
require_once __DIR__ . '/../../Helper/DatabaseTransaction.php';
require_once __DIR__ . '/../../Helper/Writer/TestWriter.php';
use OCA\GPodderSync\Controller\EpisodeActionController;
use OCA\GPodderSync\Core\EpisodeAction\EpisodeActionSaver;
use OCA\GPodderSync\Db\EpisodeAction\EpisodeActionEntity;

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace tests\Integration;
use OCA\GPodderSync\Core\EpisodeAction\EpisodeActionSaver;
use OCA\GPodderSync\Db\EpisodeAction\EpisodeActionRepository;
use OCP\AppFramework\App;
use Test\TestCase;
@ -45,4 +46,38 @@ class EpisodeActionSaverGuidBackwardCompatibilityTest extends TestCase
self::assertNotNull($savedEpisodeActionEntityWithoutGuidFromOldDevice->getGuid());
}
public function testDoNotFailToUpdateEpisodeActionByGuidIfThereIsAnotherWithTheSameValueForEpisodeUrl() : void
{
//arrange
/** @var EpisodeActionSaver $episodeActionSaver */
$episodeActionSaver = $this->container->get(EpisodeActionSaver::class);
$url = uniqid("https://podcast-mp3.dradio.de/");
$urlWithParameter = $url . "?ref=never_know_if_ill_be_removed";
$podcastUrl = uniqid("https://podcast");
$episodeActionSaver->saveEpisodeActions(
[["podcast" => $podcastUrl, "episode" => $url, "guid" => $urlWithParameter, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 35, "position" => 100, "total" => 2252]],
self::USER_ID_0
)[0];
$episodeActionSaver->saveEpisodeActions(
[["podcast" => $podcastUrl, "episode" => $urlWithParameter, "guid" => $url, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 35, "position" => 100, "total" => 2252]],
self::USER_ID_0
)[0];
//act
$episodeActionSaver->saveEpisodeActions(
[["podcast" => $podcastUrl, "episode" => $urlWithParameter, "guid" => $url, "action" => "PLAY", "timestamp" => "2021-08-22T23:58:56", "started" => 35, "position" => 100, "total" => 2252]],
self::USER_ID_0
)[0];
//assert
/** @var EpisodeActionRepository $episodeActionRepository */
$episodeActionRepository = $this->container->get(EpisodeActionRepository::class);
$this->assertSame(100, $episodeActionRepository->findByGuid($urlWithParameter, self::USER_ID_0)->getPosition());
}
}